fabulous-dev / Fabulous

Declarative UI framework for cross-platform mobile & desktop apps, using MVU and F# functional programming
https://fabulous.dev
Apache License 2.0
1.15k stars 122 forks source link

Xamarin.Forms batch updates #785

Closed Liminiens closed 2 years ago

Liminiens commented 4 years ago

Hi, I accidentally found an api in Xamarin Forms which is probably meant to process batch updates on views. BatchBegin and BatchCommit. Maybe this methods should be used when updating views? I am not completely positive that this methods are meant for this, but people on the internet are using them in this way.

https://docs.microsoft.com/en-gb/dotnet/api/xamarin.forms.visualelement.batchbegin?view=xamarin-forms

Probably this can give some speed up on updates.

TimLariviere commented 4 years ago

Hi. Thanks for the pointer. I took a look at those BatchBegin/BatchCommitted methods.

From the sources, It appears to trigger a BatchCommitted event. https://github.com/xamarin/Xamarin.Forms/blob/d99264507dc1623aecb83daf81aadd2effae62ae/Xamarin.Forms.Core/VisualElement.cs#L593-L594

This event is listened on the platforms and treated as a redraw. It seems to force a relayout of the native control. https://github.com/xamarin/Xamarin.Forms/blob/6d3c41fb2dc0911979cbddda4987e8f76ef7845f/Xamarin.Forms.Platform.iOS/VisualElementTracker.cs#L141

But it doesn't batch the properties changes, so I don't think it will really benefit Fabulous.

Will try to play with it in a C# XF app to see if it has any impact.