forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[android] avoid View.Context during ContextView scrolling
Context: dotnet#8012 Context: https://github.com/Kalyxt/Test_CollectionView We had some reports of poor `CollectionView` performance while scrolling on an older Android device. Reviewing `dotnet trace` output, I did find some issues similar to dotnet#8001: 317.42ms (1.1%) mono.android!Android.Views.View.get_Context() 1% of the time is spent in repeated calls to `View.Context` inside the `ItemContentView` class. Making a new overload for `ContextExtensions.FromPixel()`, I was able to remove all of these calls. This results in only a couple `View.Context` calls on startup now, much better: 1.30ms (0.01%) mono.android!Android.Views.View.get_Context() Using the "janky frames" metric from the latest profiler in Android Studio Dolphin: https://developer.android.com/studio/profile/jank-detection With my slowest Android 12+ device, a Pixel 4a, I could actually see a few "janky frames" while scrolling the sample. With these changes in place, I only see 1 "janky frame" now. I also compared the before and after with the visual GPU profiler: https://developer.android.com/topic/performance/rendering/inspect-gpu-rendering It appears at a glance that these changes are better. I am unsure at what point the performance will be good enough to close dotnet#8012, but this helps!
- Loading branch information
1 parent
f5b3c9f
commit b029fe2
Showing
3 changed files
with
25 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters