xamarin / Xamarin.Forms

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

[Bug] Fatal: CollectionView scroll issue is back #14429

Open Tommigun1980 opened 3 years ago

Tommigun1980 commented 3 years ago

Description

@hartez @jsuarezruiz Please see a video of the issue at https://streamable.com/w8v4ta.

The issue is that the CollectionView jitters and jumps around, and sometimes adds a random amount of space between its items. This issue is a regression introduced in XF 5.0.1.1876 (originally filed at https://github.com/xamarin/Xamarin.Forms/issues/13719) and fixed in the commit https://github.com/xamarin/Xamarin.Forms/blob/68c17772d89c6e080e6a8cc53bd490f67dcc1bb0/Xamarin.Forms.Platform.iOS/CollectionView/ItemsViewLayout.cs#L20

The above fix has never worked properly for me. It works for a few months and then breaks for a few months, even when the application is not updated.

Now I again encountered this issue on my phone in an app I had not updated for a couple of weeks, where the app was working normally the last time I used it. I have encountered this issue in XF 5.0.0.2012 and XF 5.0.0.2083, both in the simulator and on an actual device.

I need to stress that the issue came back on its own out of the blue into an app that had not been updated for a couple of weeks.

My suspicion is that the very small magical constant at https://github.com/xamarin/Xamarin.Forms/blob/68c17772d89c6e080e6a8cc53bd490f67dcc1bb0/Xamarin.Forms.Platform.iOS/CollectionView/ItemsViewLayout.cs#L20 sometimes happens to work and sometimes not.

This issue is completely breaking my app so I'd urge you to try to get a proper fix in.

Steps to Reproduce

  1. Add a CollectionView to a page.
  2. Fill it with content.
  3. Run on iOS device or in the iOS simulator.
  4. Try to scroll the CollectionView.

Expected Behavior

The CollectionView should scroll normally.

Actual Behavior

The CollectionView jitters and jumps around on its own when filled and when scrolled. There is sometimes random space between the items when this happens. The scroll bar seems to randomly jump between getting cut off at 50% and 100% of the screen's height when this happens.

Basic Information

Environment

Show/Hide Visual Studio info ``` === Visual Studio Community 2019 for Mac === Version 8.10.6 (build 10) Installation UUID: b6d726f4-7ab5-4527-9d02-885c0173688c GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638) Package version: 612000140 === Mono Framework MDK === Runtime: Mono 6.12.0.140 (2020-02/51d876a041e) (64-bit) Package version: 612000140 === Roslyn (Language Service) === 3.10.0-4.21269.26+029847714208ebe49668667c60ea5b0a294e0fcb === NuGet === Version: 5.9.0.7134 === .NET Core SDK === SDK: /usr/local/share/dotnet/sdk/5.0.302/Sdks SDK Versions: 5.0.302 5.0.301 3.1.411 3.1.410 MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks === .NET Core Runtime === Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 5.0.8 5.0.7 3.1.17 3.1.16 === .NET Core 3.1 SDK === SDK: 3.1.411 === Xamarin.Profiler === Version: 1.6.15.68 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler === Updater === Version: 11 === Apple Developer Tools === Xcode 12.5.1 (18212) Build 12E507 === Xamarin.Mac === Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version. === Xamarin.iOS === Version: 14.20.0.24 (Visual Studio Community) Hash: c4b89cddb Branch: d16-10 Build date: 2021-06-15 22:03:01-0400 === Xamarin Designer === Version: 16.10.0.119 Hash: 36a2d986f Branch: remotes/origin/d16-10 Build date: 2021-06-02 19:41:34 UTC === Xamarin.Android === Version: 11.3.0.4 (Visual Studio Community) Commit: xamarin-android/d16-10/ae14caf Android SDK: /Users/tommikiviniemi/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: None installed SDK Tools Version: 26.1.1 SDK Platform Tools Version: 30.0.4 SDK Build Tools Version: 30.0.2 Build Information: Mono: b4a3858 Java.Interop: xamarin/java.interop/d16-10@f39db25 ProGuard: Guardsquare/proguard/v7.0.1@912d149 SQLite: xamarin/sqlite/3.35.4@85460d3 Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-10@c5732a0 === Microsoft OpenJDK for Mobile === Java SDK: /Users/tommikiviniemi/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25 1.8.0-25 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL === Android SDK Manager === Version: 16.10.0.12 Hash: e240b8c Branch: remotes/origin/d16-10 Build date: 2021-06-01 18:26:34 UTC === Android Device Manager === Version: 16.10.0.14 Hash: e340248 Branch: remotes/origin/d16-10 Build date: 2021-06-01 18:26:52 UTC === Build Information === Release ID: 810060010 Git revision: 263d2fc9398e8092c231fa5d310cd72205cd627c Build date: 2021-07-08 14:37:29-04 Build branch: release-8.10 === Operating System === Mac OS X 10.16.0 Darwin 20.5.0 Darwin Kernel Version 20.5.0 Sat May 8 05:10:33 PDT 2021 root:xnu-7195.121.3~9/RELEASE_X86_64 x86_64 ```

Screenshots

Video of the issue is at https://streamable.com/w8v4ta.

Huaba93 commented 3 years ago

I have never seen this in our apps, but I am afraid that we also have this problem.

Can you add an example of how to reproduce this?

Tommigun1980 commented 3 years ago

I have never seen this in our apps, but I am afraid that we also have this problem.

Can you add an example of how to reproduce this?

The original report at https://github.com/xamarin/Xamarin.Forms/issues/13719 has a repro sample, it should be reproducible with it by updating it to the latest XF version. Please let me know if it happens for you? But as I said it's random -- it works for a few weeks and then stops working for a few weeks, even if the app is not updated. So it may not be reproducible for you this week.

unamed000 commented 3 years ago

I'm using CollectionView for my chat app as well but didn't face the same issues. But the issue I'm facing is when the new items is loaded in the top, the CollectionView will automatically jump to the top of the list instead of maintaining the scroll position. So I've to cheat like programmatically scroll to position before more items are loaded into the List, which make it a little bit jitter ....

But one of the common pattern I faced this issue before in the CollectionView is related to the content in the each item in the CollectionView, so these might help with your problem:

jsuarezruiz commented 3 years ago

@Tommigun1980 Tried https://drive.google.com/file/d/1J6tuLyoOwjSIlKBMMT9zJaSpQf_iTcQX/view with the latest version, 5.0.0.2083, and cannot see the behavior from the video. Will do more tests, but, could you try with the latest package and share your feedback?. Thanks in advanced.

memis1970 commented 2 years ago

FWIW I have a grouped CollectionView that is jittery when scrolled in Debug but seems fine in Release.

Tommigun1980 commented 2 years ago

Hi @jsuarezruiz. I tested with the latest version and scroll is still broken. I have put my app on hold until this is fixed.

Tommigun1980 commented 2 years ago

Hi @jfversluis! Thanks for fixing so many issues in Xamarin.Forms!

I was wondering if you could have a look at this issue? The CollectionView is still broken for me, which has made me stop developing my application until it is resolved.

The bug comes and goes. The issue started to happen a few months back and everything was fine at first, but suddenly after a restart of my app (without anything changing) this issue started to happen. Now it has happened for a few months.

I get it both in the simulator and on device. https://github.com/xamarin/Xamarin.Forms/issues/13719 which is an older version of this bug report has a repro project.

As mentioned in this bug report, I think that it's the magical constant that was added a while back that is at fault as it started to happen when it was introduced. Whatever the https://github.com/xamarin/Xamarin.Forms/blob/68c17772d89c6e080e6a8cc53bd490f67dcc1bb0/Xamarin.Forms.Platform.iOS/CollectionView/ItemsViewLayout.cs#L20 threshold thinks it's doing breaks down whenever the value is not within that threshold. I think that magical constant is extremely dangerous as it makes it seem like you fixed the bug in Xamarin.Forms but it just works sometimes.

I'd love to release my application but I can't before this is fixed.

Thank you.

Tommigun1980 commented 2 years ago

FWIW I have a grouped CollectionView that is jittery when scrolled in Debug but seems fine in Release.

It's broken for me both in debug and release. It's random, sometimes it works and sometimes it doesn't. I think you were just lucky in debug and unlucky in release.

Tommigun1980 commented 2 years ago

@jsuarezruiz I am certain that you were just unlucky that it didn't happen for you in that version. The bug is random. It may work for a few weeks and then stop working, even with the same code base and same content. I suspect it's the magical constant mentioned at https://github.com/xamarin/Xamarin.Forms/issues/14429#issuecomment-1006263601 that is at fault.

bondarenkod commented 2 years ago

Hi @Tommigun1980, The CV is broken not only for you. I've tried to use CV in the project, but after a while I quickly abandoned this idea due to the same/similar issues.

jfversluis commented 2 years ago

Hey @Tommigun1980 thanks for the kind words, appreciate it!

The CollectionView is still broken for me, which has made me stop developing my application until it is resolved.

Please don't take this the wrong way, I'm genuinely curious. If this is the case, what is stopping you from getting the Forms codebase and fix it? Or at least try to play with the magical constant to see if that indeed actually fixes your issue?

For the sake of moving this issue forward I have reverted that change in #15078 would you be able to test the resulting NuGet from that?

Note: I don't think this will be the solution moving forward, this code was added for a reason so simply reverting it is often not a solution, but this will at least confirm this is indeed the cause. From there we can see how we can move forward.

Thanks!

E75 commented 2 years ago

@jfversluis Any updates about this bug? This seems to be happening also in the latest version of X.Forms (iPhone 13, IOS 16)..

unamed000 commented 2 years ago

@jfversluis Any updates about this bug? This seems to be happening also in the latest version of X.Forms (iPhone 13, IOS 16)..

Just forget about it, they will never fix it for Xamarin.Forms, let's hope that in MAUI it will get better, for now the CollectionView is not usable unless your cell is fixed size.

For now to make the app looks less bad, i'm using https://github.com/roubachof/Sharpnado.CollectionView, the drawback of this control is you have to define the size of the cell yourself, so your cell won't be able to dynamic. But of course, not all the places have the fixed size cell. Especially like the Chat or Home page in most of applications nowadays.

I just hope that someday Xamarin or MAUI really get this problem solved, because most of apps use CollectionView, which is a very important control to use. All of the apps i developed use this control, which I have never had a problem (or can workaround) with RN or Flutter. I can't express how much important of this control in a framework.