question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CollectionView slow/jittering scroll

See original GitHub issue

Description

When there is a complex layout Scroll does not work efficiently.

Steps to Reproduce

I have this layout, as you can see I have used the recommended bindings OneTime and CompressedLayout.IsHeadless="True".

ItemSizingStrategy has to be in mode: MeasureAllItems. Each element can have a different height.

There are like 30-40 elements, the Scroll is unacceptable, both in debug/release mode. Thus, the application cannot be released to production.

I don’t know if I can improve my design, but i can’t get it. Any help is welcome.

Link to public reproduction project repository

https://github.com/angelru/CvSlowJittering

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 12

Did you find any workaround?

No response

Relevant log output

No response

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Reactions:11
  • Comments:49 (24 by maintainers)

github_iconTop GitHub Comments

5reactions
jonathanpepperscommented, May 10, 2023

I believe we have enough changes to close this one, testing the above sample with my script here:

https://github.com/jonathanpeppers/maui-scrolling-performance

.NET 7:

05-09 09:11:49.830 16727 16727 I DOTNET  : Frame(s) that took ~5ms, count: 5
05-09 09:11:49.831 16727 16727 I DOTNET  : Frame(s) that took ~6ms, count: 24
05-09 09:11:49.831 16727 16727 I DOTNET  : Frame(s) that took ~7ms, count: 5
05-09 09:11:49.831 16727 16727 I DOTNET  : Frame(s) that took ~8ms, count: 37
05-09 09:11:49.831 16727 16727 I DOTNET  : Frame(s) that took ~9ms, count: 29
05-09 09:11:49.831 16727 16727 I DOTNET  : Frame(s) that took ~10ms, count: 2
05-09 09:11:49.831 16727 16727 I DOTNET  : Frame(s) that took ~11ms, count: 2
05-09 09:11:49.831 16727 16727 I DOTNET  : Frame(s) that took ~12ms, count: 3
05-09 09:11:49.831 16727 16727 I DOTNET  : Frame(s) that took ~14ms, count: 1
05-09 09:11:49.832 16727 16727 I DOTNET  : Frame(s) that took ~19ms, count: 2
05-09 09:11:49.832 16727 16727 I DOTNET  : Frame(s) that took ~21ms, count: 2
05-09 09:11:49.832 16727 16727 I DOTNET  : Average frame time: 8.33ms
05-09 09:11:49.832 16727 16727 I DOTNET  : No. of slow frames: 4

.NET 8 net8.0 branch + main on top:

05-09 09:15:10.010 17241 17241 I DOTNET  : Frame(s) that took ~4ms, count: 1
05-09 09:15:10.011 17241 17241 I DOTNET  : Frame(s) that took ~5ms, count: 8
05-09 09:15:10.011 17241 17241 I DOTNET  : Frame(s) that took ~6ms, count: 31
05-09 09:15:10.011 17241 17241 I DOTNET  : Frame(s) that took ~7ms, count: 3
05-09 09:15:10.011 17241 17241 I DOTNET  : Frame(s) that took ~8ms, count: 12
05-09 09:15:10.011 17241 17241 I DOTNET  : Frame(s) that took ~9ms, count: 2
05-09 09:15:10.011 17241 17241 I DOTNET  : Frame(s) that took ~10ms, count: 3
05-09 09:15:10.011 17241 17241 I DOTNET  : Frame(s) that took ~11ms, count: 3
05-09 09:15:10.011 17241 17241 I DOTNET  : Frame(s) that took ~12ms, count: 1
05-09 09:15:10.011 17241 17241 I DOTNET  : Frame(s) that took ~15ms, count: 2
05-09 09:15:10.011 17241 17241 I DOTNET  : Frame(s) that took ~18ms, count: 1
05-09 09:15:10.011 17241 17241 I DOTNET  : Average frame time: 7.28ms
05-09 09:15:10.011 17241 17241 I DOTNET  : No. of slow frames: 1

Scrolling feels a lot better. I tested these on a Pixel 5 (released in Oct 2020).

The list of performance changes, I think led to the improvement here:

The recent fixes for memory leaks, likely also helped.

We can always make this even better, but I think this is enough to close this one for now. Thanks!

What do I do if my app still scrolls slowly?

First, try it on the latest .NET 8 release and see if things have improved.

If not, file a new issue with a sample app, and we can profile the app and see what we find. You can also try the instructions at https://aka.ms/profile-maui to profile it yourself.

5reactions
jonathanpepperscommented, Mar 10, 2023

The memory leak here may have been fixed by: https://github.com/dotnet/maui/pull/13656

No idea about the performance of it, though.

Need to retest this issue, but I’ve been working on this all week instead: https://github.com/dotnet/maui/pull/13833

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why my collectionview is slow when scrolling down or up? ...
The first step is to find out whether it is the Image s or your DataTemplate that is causing the slowdown. Test: Remove...
Read more >
Improving CollectionView Scrolling
I found that two things were causing the UI to jitter when the user scrolls a CollectionView: Bindings; Garbage Collection. I was able...
Read more >
The Collectionview Scroll Jank/Jitter thread!!!
Hi, I'd like to start a small discussion on this very issue which makes even web view frameworks (e.g. ionic, native script) eat...
Read more >
Poor performance of CollectionView with SwipeView
The scrolling is not smooth only when the List has SwipeView inside, even with the simplest layout for SwipveView.Content. The scrolling is ...
Read more >
CollectionView performance - Microsoft Q&A
Recreating controls while scrolling will lead to bad performance , I suggest you use a ScrollView to add all kinds of the subviews...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found