maui icon indicating copy to clipboard operation
maui copied to clipboard

Measure invalidation performance and fixes (batching version)

Open albyrock87 opened this issue 5 months ago • 9 comments

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 image 1726728235.MAIN.speedscope.json

After PR image image 1726728360.PR.speedscope.json

Android Speedscope

Before main image android-before.speedscope.json

After PR 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.

https://github.com/user-attachments/assets/41a64507-a9af-4fa3-bd0a-c98b0bfaea3c

After PR

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

https://github.com/user-attachments/assets/178466de-83bf-40a6-8426-c0b1a90cac6f

Issues Fixed

Fixes #24551

albyrock87 avatar Sep 18 '24 18:09 albyrock87