Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Improve background layer frame mapping performance #24848

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

albyrock87
Copy link
Contributor

@albyrock87 albyrock87 commented Sep 20, 2024

Important

This PR contains a breaking change: it removes two public utility methods:

*REMOVED*~static Microsoft.Maui.Controls.Platform.BrushExtensions.UpdateBackgroundLayer(this UIKit.UIView view) -> void
*REMOVED*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 albyrock87 requested a review from a team as a code owner September 20, 2024 14:56
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Sep 20, 2024
Copy link
Contributor

Hey there @albyrock87! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@PureWeen
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@albyrock87
Copy link
Contributor Author

Failing tests definitely unrelated :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community ✨ Community Contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[iOS/MacCatalyst] Background layer frame mapping has poor performance
2 participants