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

Measure invalidation performance and fixes (batching version) #24823

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

albyrock87
Copy link
Contributor

@albyrock87 albyrock87 commented Sep 18, 2024

Description of Change

This is #24532 plus batching of measure invalidation.

I executed a speedscope on davidortinau/AllTheLists LearningPage using the latest nightly 8.0.99-ci.net8.24468.1 build.

What I noticed is that #23052 OnChildMeasureInvalidatedInternal was showing up and taking 2% of total time (recursive calls).

What I've done:

  • Highly increases general performance when changing BindingContext on attached nodes by batching layout invalidation during binding context change & propagation
    • This is covered by a new suite of unit tests
    • This makes finally predictable the layout invalidation when BindingContext changes, from the leaf to the root
  • Avoids triggering measure invalidated completely while building the MAUI tree in memory (Handler = null)
  • Fixes some iOS SetNeedsLayout propagation issues and cleans up detection of auto SetNeedsLayout parent propagation with IPropagatesSetNeedsLayout internal interface
  • Removes "out-of-layout-pass" measurements from legacy layouts making them fast as new layouts

WinUI Speedscope

Kindly provided by @MartyIX

Before main
image
1726728202.MAIN.speedscope.json

After PR
image
1726728309.PR.speedscope.json

Before main
image
1726728235.MAIN.speedscope.json

After PR
image
1726728360.PR.speedscope.json

Android Speedscope

Before main
image
android-before.speedscope.json

After PR
image
image
after-android.speedscope.json.zip

iOS Speedscope

Before main
image
image
before.speedscope.json.zip

After PR
image
image
after.speedscope.json.zip

Before main

You can notice there are some hiccups while scrolling.

before.mp4

After PR

You can notice there hiccups are basically gone while scrolling, even if in this case I had a lot more nested children.

after.mp4

Issues Fixed

Fixes #24551

@albyrock87 albyrock87 requested a review from a team as a code owner September 18, 2024 18:43
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Sep 18, 2024
frame = control.Frame;
desiredSize = control.DesiredSize;
Assert.Equal(5, frame.X, 0.5d);
Assert.Equal(60, frame.Width, 0.5d);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was failing on ListView and TableView due to the fact they were not propagating SetNeedsLayout to the parent.

@OvrBtn
Copy link

OvrBtn commented Sep 18, 2024

Thank you so much for your work, can't wait to try it out!

Do you think or have you tested if it will also affect performance of rendering pages when navigating/performing first render? Currently navigation can be a lot slower than Xamarin in certain cases, sometimes even with static pages without binding and collections.

@albyrock87
Copy link
Contributor Author

@OvrBtn it improves that a bit if you're using ContentView or legacy layouts.
I have other ideas to improve that scenario, but I didn't want to increase an already big PR.

@albyrock87 albyrock87 changed the title Measure invalidation performance and fixes Measure invalidation performance and fixes (batching version) Sep 18, 2024
@PureWeen
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@bcaceiro
Copy link

@albyrock87 great work! What about android, which seems to be the slowest platform overall so far in .net maui, have you seen even bigger improvements?

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.

Improve measure invalidation and legacy Layout(s) performance
4 participants