xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.63k stars 1.87k forks source link

[Bug] CollectionView on Android has a Jank/jitter on first scroll gesture #14233

Open azrinsani opened 3 years ago

azrinsani commented 3 years ago

Description

CollectionView on Android has a Jank on first scroll gesture. After that it is somewhat smooth (but not perfect off course). This jank happens everytime the View Model ItemsSource in the collection view is refreshed. See video here => [https://www.youtube.com/watch?v=ojjIFnx_W9U](https://www.youtube.com/watch?v=ojjIFnx_W9U and here too (on a higher end phone) => https://youtu.be/e7l2oLngUlk )

I've done almost everything in google searches to improve Xamarin Scroll Performance and the Xamarin Team has definitely done a lot of good work to solve this scrolling issue. Personally this is the only issue I find with Xamarin Forms Scrolling. Everything else looks good!

What I've done but did not work =>

  1. I removed all images, still early jitter is seen
  2. I removed all animations, still early jitter is seen
  3. Increased Android Nursery Size (as mentioned in https://codetraveler.io/2020/07/12/improving-collectionview-scrolling/)
  4. Enabled Xaml Compilation
  5. Optimized Layouts
  6. Enabled Startup Tracing in Android Project Options

Steps to Reproduce

my github page => https://github.com/azrinsani/UIDesign

  1. Clone project
  2. Build and run under release (I am using Visual Studio 2019 Community Edition)
  3. Scroll down
  4. the Jank/Jitter should be seen
  5. After that everything is ok.

Expected Behavior

Scrolling should not have an initial jank

Actual Behavior

An initial 'jank'/jitter is experienced on the first scroll down gesture. See video https://youtu.be/e7l2oLngUlk

angelru commented 3 years ago

try https://github.com/xamarin/Xamarin.Forms/issues/8718

azrinsani commented 3 years ago

try

8718

I actually came from that thread before creating this thread. Did everything mentioned on that thread and it did help a lot, however, the initial jitter on scroll is still there.

jsuarezruiz commented 3 years ago

To reproduce the issue, could you share a small example or the code that defines the template of each item along with the basic properties used in the CollectionView?.

azrinsani commented 3 years ago

Ok I've preapred a small project to demonstrate this

You can clone it from my github page => https://github.com/azrinsani/UIDesign

Just run the project under vs2019 release. You can see that there is a jitter/jank at the first gesture of the collecitonview scroll.

Here is another video demonstrating this =>https://youtu.be/e7l2oLngUlk (I am running this on a Xiaomi Pocophone F1)

After that, scrolling is silky smooth. I have to admit, Xamarin Forms have greatly improved! It's just this last annoying thing which I am trying to resolve.

I also like to point out that I've done the following to Optimize the Collection View in the project I prepared

hunsra commented 2 years ago

I have the same issue with CollectionView on Android.

roubachof commented 2 years ago

maybe rule n°2 could help here: https://www.sharpnado.com/xamarin-forms-maui-collectionview-performance-the-10-golden-rule/