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] Go backwards crash the app while CollectionView scrolling #15637

Closed petthreer closed 1 year ago

petthreer commented 1 year ago

Description

Button which trigger shell backwards navigation causes the app to crash while CollectionView performs a scrolling animation. Happens on iOS >= 15.0

Steps to Reproduce

  1. Create ContentPage with the possibility go back
  2. Set Shell.NavBarIsVisible="False"
  3. Create StackLayout with Button which on click does Shell.Current.GoToAsync("..") and CollectionView with multiple Items.
  4. Create enough items so when you swipe you can see scroll animation
  5. Swipe to scroll items and while items are scrolling click the button (do this multiple times and app will crash)

Expected Behavior

App does not crash

Actual Behavior

On iOS app crashes

Basic Information

StackTrace

System.NullReferenceException: Object reference not set to an instance of an object at Xamarin.Forms.Platform.iOS.ItemsViewController1[TItemsView].UpdateTemplatedCell (Xamarin.Forms.Platform.iOS.TemplatedCell cell, Foundation.NSIndexPath indexPath) [0x00031] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:278 at Xamarin.Forms.Platform.iOS.ItemsViewController1[TItemsView].GetCell (UIKit.UICollectionView collectionView, Foundation.NSIndexPath indexPath) [0x00033] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:94 at (wrapper managed-to-native) UIKit.UIApplication.xamarin_UIApplicationMain(int,string[],intptr,intptr,intptr&) at UIKit.UIApplication.UIApplicationMain (System.Int32 argc, System.String[] argv, System.IntPtr principalClassName, System.IntPtr delegateClassName) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.72/src/Xamarin.iOS/UIKit/UIApplication.cs:57 at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) [0x0003b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.72/src/Xamarin.iOS/UIKit/UIApplication.cs:92 at collectionviewtest.iOS.Application.Main (System.String[] args) [0x00001] in Desktop/collectionviewtest/collectionviewtest/collectionviewtest.iOS/Main.cs:17

https://user-images.githubusercontent.com/106705985/208873059-7f3a4d01-dff6-472c-9a6a-543e21679793.mov

Reproduction Link

collectionviewtest.zip