maui icon indicating copy to clipboard operation
maui copied to clipboard

[iOS] Improve background layer frame mapping performance

Open albyrock87 opened this issue 5 months ago • 15 comments

Important

This PR Obsoletes a couple of methods.

static Microsoft.Maui.Controls.Platform.BrushExtensions.UpdateBackgroundLayer(this UIKit.UIView view) -> void
static Microsoft.Maui.Platform.ViewExtensions.UpdateBackgroundLayerFrame(this UIKit.UIView! view) -> void

Description of Change

Using https://github.com/davidortinau/AllTheLists app, and scrolling through collection view with Border inside we can clearly see that a good amount of time is spent in UpdateBackgroundLayerFrame which is needed to sync the sublayer with the UIView.Layer.

image

This has an impact on both MappingFrame and ContentView.LayoutSubviews: image

Which translated to these timings image image

This PR gets rid of all mapping frame code and simply adds an observer on the sublayer.

As a result we get a lot of improvement (80%): image image

While the new observer is super fast image

Issues Fixed

Fixes #24847

albyrock87 avatar Sep 20 '24 14:09 albyrock87