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

[CollectionView] On iOS switching IsGrouped suddenly crashes app since 4.8.0.1821 #13576

Open jantanis opened 3 years ago

jantanis commented 3 years ago

Description

When upgrading my XF project from 4.8.0.1821 to XF 5 I found this code crashing. I pinned it down to the 4.8.0.1821 version.

Steps to Reproduce

  1. Open and run attached solution

Expected Behavior

Able to switch IsGrouped dynamically

Actual Behavior

App crashes

Basic Information

Environment

Show/Hide Visual Studio info ``` === Visual Studio Enterprise 2019 for Mac === Version 8.8.4 (build 30) Installation UUID: c8ba8fb6-2db8-49eb-ad3a-a2670fb12062 GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638) Package version: 612000113 === Mono Framework MDK === Runtime: Mono 6.12.0.113 (2020-02/4fdfb5b1fd5) (64-bit) Package version: 612000113 === Roslyn (Language Service) === 3.8.0-5.20519.18+4c195c3ac1974edcefa76774d7a59a2350ec55fa === NuGet === Version: 5.8.0.6860 === .NET Core SDK === SDK: /usr/local/share/dotnet/sdk/5.0.101/Sdks SDK Versions: 5.0.101 5.0.100 3.1.404 3.1.403 3.1.402 3.1.401 3.1.302 3.1.301 3.1.300 3.1.202 3.1.200 3.1.102 3.1.101 3.1.100 3.0.101 3.0.100 2.2.100 2.1.810 2.1.809 2.1.701 2.1.700 2.1.505 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.1 5.0.0 3.1.10 3.1.9 3.1.8 3.1.7 3.1.6 3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.1 3.0.0 2.2.0 2.1.23 2.1.22 2.1.21 2.1.20 2.1.19 2.1.18 2.1.17 2.1.16 2.1.15 2.1.14 2.1.13 2.1.12 2.1.11 2.1.9 === .NET Core 3.1 SDK === SDK: 3.1.404 === Xamarin.Profiler === Version: 1.6.12.29 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler === Updater === Version: 11 === Apple Developer Tools === Xcode 12.4 (17801) Build 12D4e === Xamarin.Mac === Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version. === Xamarin.iOS === Version: 14.6.0.15 (Visual Studio Enterprise) Hash: 87a1b18d8 Branch: d16-8 Build date: 2020-11-16 21:39:41-0500 === Xamarin Designer === Version: 16.8.0.510 Hash: 44e3f3ce9 Branch: remotes/origin/d16-8 Build date: 2020-12-10 00:06:14 UTC === Xamarin.Android === Version: 11.1.0.17 (Visual Studio Enterprise) Commit: xamarin-android/d16-8/c0e2b8e Android SDK: /Users/jan/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: 8.1 (API level 27) SDK Tools Version: 26.1.1 SDK Platform Tools Version: 30.0.5 SDK Build Tools Version: 29.0.2 Build Information: Mono: be2226b Java.Interop: xamarin/java.interop/d16-8@79d9533 ProGuard: Guardsquare/proguard/proguard6.2.2@ebe9000 SQLite: xamarin/sqlite/3.32.1@1a3276b Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-8@2fb1cbc === Microsoft OpenJDK for Mobile === Java SDK: /Users/jan/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.8.0.32 Hash: 01a7774 Branch: remotes/origin/d16-8 Build date: 2020-12-10 00:32:24 UTC === Android Device Manager === Version: 16.8.0.46 Hash: 0a81419 Branch: remotes/origin/d16-8 Build date: 2020-12-10 00:32:44 UTC === Build Information === Release ID: 808040030 Git revision: eaa21a8983aa5c4bcf6a665892478b4f3d413418 Build date: 2020-12-10 11:06:12-05 Build branch: release-8.8 Xamarin extensions: eaa21a8983aa5c4bcf6a665892478b4f3d413418 === Operating System === Mac OS X 10.15.7 Darwin 19.6.0 Darwin Kernel Version 19.6.0 Thu Oct 29 22:56:45 PDT 2020 root:xnu-6153.141.2.2~1/RELEASE_X86_64 x86_64 === Enabled user installed extensions === DeepClean 1.2.5 Straight8's SpecFlow Integration 1.11.3.0 NuGet Package Management Extensions 0.24 MFractor 4.4.5 AapIdeExtension.Mac 1.1.64 ```

Reproduction Link

ObservableCollectionView.zip

fraedom-lkwong commented 3 years ago

Also experiencing this on upgrade from 4.8.0.1687 -> 5.0.0.1931

Stacktrace from this rep project for people confirming if this is happening to them

Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Invalid update: invalid number of sections. The number of sections contained in the collection view after the update (2) must be equal to the number of sections contained in the collection view before the update (2), plus or minus the number of sections inserted or deleted (1 inserted, 0 deleted). Native stack trace: 0 CoreFoundation 0x00007fff20420af6 __exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007fff20177e78 objc_exception_throw + 48 2 CoreFoundation 0x00007fff2042091f +[NSException raise:format:] + 0 3 Foundation 0x00007fff2077056a -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191 4 UIKitCore 0x00007fff23d8cf41 -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:collectionViewAnimator:] + 15876 5 UIKitCore 0x00007fff23d8912c -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:] + 60 6 UIKitCore 0x00007fff23d8871a -[UICollectionView _updateSections:updateAction:] + 454 7 UIKitCore 0x00007fff23d887ea -[UICollectionView insertSections:] + 64 8 ObservableCollectionView.iOS 0x000000010b4e9839 xamarin_dyn_objc_msgSend + 217 9 ??? 0x0000000112418490 0x0 + 4601250960

rachelkang commented 3 years ago

Hi, @jantanis - thanks for submitting this issue. I confirm that I'm able to reproduce it - while I see the CV on XF 4.8.0.1687, I don't see it on XF 4.8.0.1821 and up. And on some occasions I see the same Foundation.MonoTouchException @fraedom-lkwong shared, with the described crash which follows.

@hartez what do you think?

It seems this could possibly be related to #13268 too

kgouraw commented 3 years ago

It could be duplicate of https://github.com/xamarin/Xamarin.Forms/issues/13268#issuecomment-801966904