Yeah. When I made the first commit, I didn’t realize all the changes were going 
to be necessary. Otherwise, I definitely would have done it on a branch. :-(

We should be good now.

FYI, I summed up the necessary bits here: 
https://apache.github.io/royale-docs/features/strands-and-beads in the 
"Accessing a bead from a strand” section.

> On Jan 3, 2022, at 3:01 PM, Yishay Weiss <yishayj...@hotmail.com> wrote:
> 
> Unfortunately with the current release frequency users  are relying on dev 
> branch so big changes are problematic. Maybe reviews are in order with 
> fundamental changes like this, assuming volunteers are available for that.
> 
>> The rest is code that’s not used unless I’m mistaken.
> 
> I can’t tell from the grep, I haven’t taken the time to look.
> 
> Thanks for improving performance.
> 
> From: Harbs<mailto:harbs.li...@gmail.com>
> Sent: Monday, January 3, 2022 2:53 PM
> To: Apache Royale Development<mailto:dev@royale.apache.org>
> Subject: Re: Bead optimizations
> 
> Sorry. I missed that one.
> 
> Presentation models are not “models".
> 
> The rest is code that’s not used unless I’m mistaken.
> 
>> On Jan 3, 2022, at 2:02 PM, Yishay Weiss <yishayj...@hotmail.com> wrote:
>> 
>> I think I fixed ImageViewBase (not tested), here’s what my grep shows after 
>> pulling the changes.
>> 
>> PS C:\dev\flexjs\royale-asjs\frameworks\projects> git grep 
>> "getBeadByType.*I*Model"
>> Basic/src/main/royale/org/apache/royale/html/beads/AlternatingBackgroundColorSelectableItemRendererBead.as:
>>                      owner = (ir.getBeadByType(ItemRendererOwnerViewBead) as 
>> ItemRendererOwnerViewBead).ownerView.host as IStrandWithModel;
>> Basic/src/main/royale/org/apache/royale/html/beads/DataGridLinesBead.as:     
>>                    var presentationModel:DataGridPresentationModel = 
>> _strand.getBeadByType(DataGridPresentationModel) as 
>> DataGridPresentationModel;
>> Basic/src/main/royale/org/apache/royale/html/beads/HideColorSpectrumThumbWhenEmpty.as:
>>                   (_strand.getBeadByType(ISliderView) as 
>> ISliderView).thumb.visible = !isNaN(colorModel.baseColor);
>> Basic/src/main/royale/org/apache/royale/html/util/getModelByType.as:         
>>    return strand.getBeadByType(type) as IBeadModel;
>> Core/src/main/royale/org/apache/royale/core/TransformBeadBase.as:            
>>            return host.getBeadByType(ITransformModel) as ITransformModel;
>> Core/src/main/royale/org/apache/royale/core/UIButtonBase.as:            if 
>> (getBeadByType(IBeadModel) == null)
>> CreateJS/src/main/royale/org/apache/royale/createjs/core/UIBase.as:          
>>            if (getBeadByType(IBeadModel) == null)
>> GoogleMaps/src/main/royale/org/apache/royale/maps/google/GoogleMap.as:       
>>            // var model:IBeadModel = getBeadByType(IBeadModel) as IBeadModel;
>> GoogleMaps/src/main/royale/org/apache/royale/maps/google/beads/MapView_original.as:
>>                      var model:IBeadModel = 
>> _strand.getBeadByType(IBeadModel) as IBeadModel;
>> GoogleMaps/src/main/royale/org/apache/royale/maps/google/beads/MapView_original.as:
>>                              var model:MapModel = 
>> _strand.getBeadByType(IBeadModel) as MapModel;
>> GoogleMaps/src/main/royale/org/apache/royale/maps/google/beads/MapView_original.as:
>>                              var model:MapModel = 
>> _strand.getBeadByType(IBeadModel) as MapModel;
>> GoogleMaps/src/main/royale/org/apache/royale/maps/google/beads/MapView_original.as:
>>                      var model:MapModel = _strand.getBeadByType(IBeadModel) 
>> as MapModel;
>> GoogleMaps/src/main/royale/org/apache/royale/maps/google/beads/MapView_original.as:
>>                      var model:MapModel = _strand.getBeadByType(IBeadModel) 
>> as MapModel;
>> Jewel/src/main/royale/org/apache/royale/jewel/beads/controllers/DropDownListController.as:
>>         //     var selectionModel:ISelectionModel = 
>> _strand.getBeadByType(ISelectionModel) as ISelectionModel;
>> Jewel/src/main/royale/org/apache/royale/jewel/beads/controllers/DropDownListController.as:
>>         //     var selectionModel:ISelectionModel = 
>> _strand.getBeadByType(ISelectionModel) as ISelectionModel;
>> Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/VirtualListVerticalLayout.as:
>>             // dataProviderModel = host.getBeadByType(IDataProviderModel) as 
>> IDataProviderModel;
>> Jewel/src/main/royale/org/apache/royale/jewel/beads/layouts/VirtualListVerticalLayout.as:
>>         //     listModel = value.getBeadByType(ISelectionModel) as 
>> ISelectionModel;
>> Jewel/src/main/royale/org/apache/royale/jewel/beads/views/VirtualListView.as:
>>                    // var pm:IListPresentationModel = 
>> _strand.getBeadByType(IListPresentationModel) as IListPresentationModel;
>> MXRoyale/src/main/royale/mx/controls/beads/DataGridLinesBeadForICollectionView.as:
>>             var presentationModel:DataGridPresentationModel = 
>> _strand.getBeadByType(DataGridPresentationModel) as 
>> DataGridPresentationModel;
>> MXRoyale/src/main/royale/mx/controls/beads/layouts/DataGridLayout.as:        
>> //        var bbmodel:ButtonBarModel = header.getBeadByType(ButtonBarModel) 
>> as ButtonBarModel;
>> MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/TabsItemRendererFactoryForArrayData.as:
>>             var presentationModel:IListPresentationModel = 
>> _strand.getBeadByType(IListPresentationModel) as IListPresentationModel;
>> MaterialDesignLite/src/main/royale/org/apache/royale/mdl/beads/TabsItemRendererInitializer.as:
>>             var presentationModel:IListPresentationModel = 
>> _strand.getBeadByType(IListPresentationModel) as IListPresentationModel;
>> SparkRoyale/src/main/royale/spark/components/DataGroup.as:        var 
>> presModel:IListPresentationModel = getBeadByType(IListPresentationModel) as 
>> IListPresentationModel;
>> SparkRoyale/src/main/royale/spark/components/SkinnableDataContainer.as:      
>>   var presModel:IListPresentationModel = 
>> getBeadByType(IListPresentationModel) as IListPresentationModel;
>> 
>> From: Yishay Weiss<mailto:yishayj...@hotmail.com>
>> Sent: Monday, January 3, 2022 1:33 PM
>> To: dev@royale.apache.org<mailto:dev@royale.apache.org>
>> Subject: RE: Bead optimizations
>> 
>> This breaks some SDK code. Our client is complaining about 
>> ImageViewBase.strand not letting the app run.
>> 
>> Did you scan for occurences of getBeadByType(IBeadModel) in the SDK?
>> 
>> From: Harbs<mailto:harbs.li...@gmail.com>
>> Sent: Monday, January 3, 2022 1:15 PM
>> To: dev@royale.apache.org<mailto:dev@royale.apache.org>
>> Subject: Bead optimizations
>> 
>> I committed some changes to when/how bead lookups work to improve 
>> performance. Here’s the details:
>> 
>> For the most part, not much has changed from a use-perspective. The only 
>> caveat is when it comes to models. We had a type check **every** time a bead 
>> was added to check if it was a model bead and we always tried to load a 
>> model bead whether it’s needed or not. Needless to say this wasn’t very 
>> PAYG. I changed models to only be loaded the first time it was actually 
>> requested. Since models don’t actually dispatch events when loaded this is 
>> not a problem. The only issue comes up if you use 
>> strand.getBeadByType(IBeadModel). This will fail because the model was not 
>> added yet. strand.getBeadByType(IBeadModel) is actually not a great way to 
>> get a model int he first place because you’re looping through the beads to 
>> find the model every time you access it. Since we have a model getter, 
>> that’s a much better way to get the model. And with the new change, it’s 
>> kind of necessary to do it that way because the getter will load the model 
>> if it wasn’t yet loaded.
>> 
>> Sometimes components have more than one model. In that case there’s “the” 
>> model and other models which is not the main one. It might not be clear to 
>> the user which is the main model. To solve that issue, there’s now 
>> getModelByType(strand,type) which returns the model and makjes sure it’s 
>> initialized if it’s the right type. Otherwise it will find the correct bead 
>> and return that. When in doubt, always use this function instead of 
>> strand.getBeadByType.
>> 
>> Views, Controllers and Layouts had a similar issue to models. Not all 
>> components need a view or a controller or a layout. There’s now a function 
>> needsView() and needsController() in UIBase. It defaults to true for now 
>> because I didn’t want to break things, but subclasses can override and 
>> change it to false. This will prevent the view and controller from being 
>> loaded. This improves performance on those components. The HTML component 
>> set all has this set to false.
>> 
>> Similarly, GroupBase now has needsLayout() which also defaults to true and 
>> can likewise be overridden to return false. Likewise, the HTML component set 
>> sets this to false.
>> 
>> HTH,
>> Harbs
>> 
> 

Reply via email to