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

[android] avoid View.Context during CollectionView scrolling #8243

Merged
merged 1 commit into from
Jun 22, 2022

Commits on Jun 22, 2022

  1. [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!
    jonathanpeppers committed Jun 22, 2022
    Configuration menu
    Copy the full SHA
    b029fe2 View commit details
    Browse the repository at this point in the history