Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] CollectionView Group Header & Footer Templates cause immediate crash on iOS 18 #25139

Closed
claytonone opened this issue Oct 8, 2024 · 18 comments
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@claytonone
Copy link

claytonone commented Oct 8, 2024

Description

When building with Xcode 16 and running on iOS 18 devices or simulators, the app will crash immediately if CollectionView Group Header or Footer Templates are used on a page.

This did not happen before upgrading to Xcode 16.

Steps to Reproduce

  1. Add a collection view that is grouped
  2. Add either a group header or footer template
  3. The app will crash immediately when the page loads

Link to public reproduction project repository

https://github.com/claytonone/CollectionViewGroupHeaderFooterBug

Version with bug

8.0.91 SR9.1

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 18

Did you find any workaround?

No

Relevant log output

SIGABRT: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Expected dequeued view to be returned to the collection view in preparation for display. When the collection view's data source is asked to provide a view for a given index path, ensure that a single view is dequeued and returned to the collection view. Avoid dequeuing views without a request from the collection view. For retrieving an existing view in the collection view, use -[UICollectionView cellForItemAtIndexPath:] or -[UICollectionView supplementaryViewForElementKind:atIndexPath:]. Dequeued view: <Microsoft_Maui_Controls_Handlers_Items_VerticalSupplementaryView: 0x1232f7000; baseClass = UICollectionViewCell; frame = (0 0; 0 0); alpha = 0; layer = <CALayer: 0x302f01d60>>; Collection view: <Microsoft_Maui_Controls_Handlers_Items_MauiCollectionView: 0x1179d9c00; baseClass = UICollectionView; frame = (0 0; 361 694.333); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x3024a9650>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x302f71c60>; contentOffset: {0, 0}; contentSize: {361, 792.33333333333326}; adjustedContentInset: {0, 0, 0, 0}; layout: <Microsoft_Maui_Controls_Handlers_Items_ListViewLayout: 0x11f741e00>; dataSource: <Microsoft_Maui_Controls_Handlers_Items_ReorderableItemsViewController_1: 0x1141d4000>> Native stack trace: 0 CoreFoundation 0x000000018eea5098 4250D45C-51A9-3AC5-8C3D-69DE936FAD46 + 540824 1 libobjc.A.dylib 0x000000018c1a72e4 objc_exception_throw + 88 2 Foundation 0x000000018e27615c 6D058A2D-05CF-3A29-8BEB-B1030AE97282 + 8528220 3 UIKitCore 0x0000000191fdcd44 187C890E-8E4C-32F2-A97E-FA905A55F094 + 10423620 4 UIKitCore 0x00000001927161e4 187C890E-8E4C-32F2-A97E-FA905A55F094 + 17998308 5 UIKitCore 0x00000001917a4cac 187C890E-8E4C-32F2-A97E-FA905A55F094 + 1805484 6 UIKitCore 0x00000001918fd3c4 187C890E-8E4C-32F2-A97E-FA905A55F094 + 3216324 7 UIKitCore 0x00000001915fc248 187C890E-8E4C-32F2-A97E-FA905A55F094 + 66120 8 QuartzCore 0x0000000190941630 E592F77A-3E20-3854-96AB-4CEDCA39FFF7 + 493104 9 QuartzCore 0x00000001909411bc E592F77A-3E20-3854-96AB-4CEDCA39FFF7 + 491964 10 QuartzCore 0x0000000190998268 E592F77A-3E20-3854-96AB-4CEDCA39FFF7 + 848488 11 QuartzCore 0x00000001909170a0 E592F77A-3E20-3854-96AB-4CEDCA39FFF7 + 319648 12 QuartzCore 0x000000019095a364 E592F77A-3E20-3854-96AB-4CEDCA39FFF7 + 594788 13 UIKitCore 0x000000019169a848 187C890E-8E4C-32F2-A97E-FA905A55F094 + 714824 14 UIKitCore 0x0000000191697e44 187C890E-8E4C-32F2-A97E-FA905A55F094 + 704068 15 UIKitCore 0x0000000191697cb8 187C890E-8E4C-32F2-A97E-FA905A55F094 + 703672 16 UIKitCore 0x0000000191697908 187C890E-8E4C-32F2-A97E-FA905A55F094 + 702728 17 UIKitCore 0x000000019169887c 187C890E-8E4C-32F2-A97E-FA905A55F094 + 706684 18 CoreFoundation 0x000000018ee78088 4250D45C-51A9-3AC5-8C3D-69DE936FAD46 + 356488 19 CoreFoundation 0x000000018ee7801c 4250D45C-51A9-3AC5-8C3D-69DE936FAD46 + 356380 20 CoreFoundation 0x000000018ee75b08 4250D45C-51A9-3AC5-8C3D-69DE936FAD46 + 346888 21 CoreFoundation 0x000000018ee74d04 4250D45C-51A9-3AC5-8C3D-69DE936FAD46 + 343300 22 CoreFoundation 0x000000018ee745b8 CFRunLoopRunSpecific + 572 23 GraphicsServices 0x00000001da90a1c4 GSEventRunModal + 164 24 UIKitCore 0x00000001919ca2c0 187C890E-8E4C-32F2-A97E-FA905A55F094 + 4055744 25 UIKitCore 0x0000000191a78ddc UIApplicationMain + 340 26 Parkrun.iOS 0x0000000107babff0 xamarin_UIApplicationMain + 24 27 Parkrun.iOS 0x00000001037370a0 Parkrun.iOS + 17068192 28 Parkrun.iOS 0x0000000107a7bb28 Parkrun.iOS + 87604008 29 Parkrun.iOS 0x0000000105851d90 Parkrun.iOS + 51781008 30 Parkrun.iOS 0x0000000107df7250 AppleCryptoNative_X509ImportCertificate + 2300932 31 Parkrun.iOS 0x0000000107da2f6c AppleCryptoNative_X509ImportCertificate + 1956128 32 Parkrun.iOS 0x0000000107da8fb0 AppleCryptoNative_X509ImportCertificate + 1980772 33 Parkrun.iOS 0x0000000107dfc61c AppleCryptoNative_X509ImportCertificate + 2322384 34 Parkrun.iOS 0x0000000107bb7180 xamarin_log + 4676 35 Parkrun.iOS 0x0000000107ede228 AppleCryptoNative_X509ImportCertificate + 3247068 36 dyld 0x00000001b4648d34 5DB83988-2EE6-3756-BD07-B8D67B1133A5 + 212276
@claytonone claytonone added the t/bug Something isn't working label Oct 8, 2024
Copy link

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

@mrwcjoughin
Copy link

I also got this which forced us to go back to workload 8.0.42 and to target iOS 17.5 again. This needs to be fixed before we can use iOS 18 target as we use CollectionView Group Headers in many different pages

@Brosten
Copy link

Brosten commented Oct 9, 2024

We are having the same issue!
@mrwcjoughin : What do you mean by targeting ios 17.5?

@drasticactions
Copy link
Contributor

Stack Trace

ObjCRuntime.ObjCException: Objective-C exception thrown.  Name: NSInternalInconsistencyException Reason: Expected dequeued view to be returned to the collection view in preparation for display. When the collection view's data source is asked to provide a view for a given index path, ensure that a single view is dequeued and returned to the collection view. Avoid dequeuing views without a request from the collection view. For retrieving an existing view in the collection view, use -[UICollectionView cellForItemAtIndexPath:] or -[UICollectionView supplementaryViewForElementKind:atIndexPath:]. Dequeued view: <Microsoft_Maui_Controls_Handlers_Items_VerticalSupplementaryView: 0x1052407a0; baseClass = UICollectionViewCell; frame = (0 0; 0 0); alpha = 0; layer = <CALayer: 0x600000a935a0>>; Collection view: <Microsoft_Maui_Controls_Handlers_Items_MauiCollectionView: 0x10393fa00; baseClass = UICollectionView; frame = (0 0; 820 1067); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x600000c13f30>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x600000a12720>; contentOffset: {0, 0}; contentSize: {820, 592}; adjustedContentInset: {0, 0, 0, 0}; layout: <Microsoft_Maui_Controls_Handlers_Items_ListViewLayout: 0x1052283e0>; dataSource: <Microsoft_Maui_Controls_Handlers_Items_ReorderableItemsViewController_1: 0x105210e30>>
Native stack trace:
	0   CoreFoundation                      0x00000001804b70ec __exceptionPreprocess + 172
	1   libobjc.A.dylib                     0x000000018008ede8 objc_exception_throw + 72
	2   Foundation                          0x0000000180e73aa8 _userInfoForFileAndLine + 0
	3   UIKitCore                           0x00000001851ae220 __43-[UICollectionView _updateVisibleCellsNow:]_block_invoke.444 + 136
	4   UIKitCore                           0x0000000185a9b60c -[_UICollectionViewSubviewManager removeAllDequeuedViewsWithEnumerator:] + 188
	5   UIKitCore                           0x00000001851adce8 -[UICollectionView _updateVisibleCellsNow:] + 4000
	6   UIKitCore                           0x00000001851b2af0 -[UICollectionView layoutSubviews] + 284
	7   UIKitCore                           0x000000018601c0c4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2404
	8   QuartzCore                          0x000000018b06ceb0 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 432
	9   QuartzCore                          0x000000018b077c34 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 124
	10  QuartzCore                          0x000000018afacc58 _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 464
	11  QuartzCore                          0x000000018afdb468 _ZN2CA11Transaction6commitEv + 652
	12  UIKitCore                           0x0000000185abb7b4 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 32
	13  CoreFoundation                      0x000000018041b0ec __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 20
	14  CoreFoundation                      0x000000018041a824 __CFRunLoopDoBlocks + 352
	15  CoreFoundation                      0x00000001804150c8 __CFRunLoopRun + 812
	16  CoreFoundation                      0x0000000180414960 CFRunLoopRunSpecific + 536
	17  GraphicsServices                    0x0000000190183b10 GSEventRunModal + 160
	18  UIKitCore                           0x0000000185aa2b40 -[UIApplication _run] + 796
	19  UIKitCore                           0x0000000185aa6d38 UIApplicationMain + 124
	20  libxamarin-dotnet-debug.dylib       0x0000000102c871e4 xamarin_UIApplicationMain + 60
	21  libmonosgen-2.0.dylib               0x000000010343ca54 do_icall + 316
	22  libmonosgen-2.0.dylib               0x000000010343b2f4 do_icall_wrapper + 356
	23  libmonosgen-2.0.dylib               0x000000010342fd44 mono_interp_exec_method + 2836
	24  libmonosgen-2.0.dylib               0x000000010342d8e4 interp_runtime_invoke + 244
	25  libmonosgen-2.0.dylib               0x0000000103346af0 mono_jit_runtime_invoke + 1116
	26  libmonosgen-2.0.dylib               0x0000000103501c3c mono_runtime_invoke_checked + 148
	27  libmonosgen-2.0.dylib               0x000000010350921c mono_runtime_exec_main_checked + 116
	28  libmonosgen-2.0.dylib               0x000000010339ad78 mono_jit_exec + 364
	29  libxamarin-dotnet-debug.dylib       0x0000000102cc7984 xamarin_main + 2324
	30  MauiApp1                            0x0000000101b9647c main + 72
	31  dyld                                0x00000001023e1410 start_sim + 20
	32  ???                                 0x000000010254a274 0x0 + 4334068340

   at ObjCRuntime.Runtime.ThrowException(IntPtr gchandle) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 2719
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 64
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 96
   at MauiApp1.Program.Main(String[] args) in /Users/drasticactions/Developer/Apps/CollectionViewGroupHeaderFooterBug/MauiApp1/Platforms/iOS/Program.cs:line 13
Native stack trace:
	0   CoreFoundation                      0x00000001804b70ec __exceptionPreprocess + 172
	1   libobjc.A.dylib                     0x000000018008ede8 objc_exception_throw + 72
	2   Foundation                          0x0000000180e73aa8 _userInfoForFileAndLine + 0
	3   UIKitCore                           0x00000001851ae220 __43-[UICollectionView _updateVisibleCellsNow:]_block_invoke.444 + 136
	4   UIKitCore                           0x0000000185a9b60c -[_UICollectionViewSubviewManager removeAllDequeuedViewsWithEnumerator:] + 188
	5   UIKitCore                           0x00000001851adce8 -[UICollectionView _updateVisibleCellsNow:] + 4000
	6   UIKitCore                           0x00000001851b2af0 -[UICollectionView layoutSubviews] + 284
	7   UIKitCore                           0x000000018601c0c4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2404
	8   QuartzCore                          0x000000018b06ceb0 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 432
	9   QuartzCore                          0x000000018b077c34 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 124
	10  QuartzCore                          0x000000018afacc58 _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 464
	11  QuartzCore                          0x000000018afdb468 _ZN2CA11Transaction6commitEv + 652
	12  UIKitCore                           0x0000000185abb7b4 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 32
	13  CoreFoundation                      0x000000018041b0ec __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 20
	14  CoreFoundation                      0x000000018041a824 __CFRunLoopDoBlocks + 352
	15  CoreFoundation                      0x00000001804150c8 __CFRunLoopRun + 812
	16  CoreFoundation                      0x0000000180414960 CFRunLoopRunSpecific + 536
	17  GraphicsServices                    0x0000000190183b10 GSEventRunModal + 160
	18  UIKitCore                           0x0000000185aa2b40 -[UIApplication _run] + 796
	19  UIKitCore                           0x0000000185aa6d38 UIApplicationMain + 124
	20  libxamarin-dotnet-debug.dylib       0x0000000102c871e4 xamarin_UIApplicationMain + 60
	21  libmonosgen-2.0.dylib               0x000000010343ca54 do_icall + 316
	22  libmonosgen-2.0.dylib               0x000000010343b2f4 do_icall_wrapper + 356
	23  libmonosgen-2.0.dylib               0x000000010342fd44 mono_interp_exec_method + 2836
	24  libmonosgen-2.0.dylib               0x000000010342d8e4 interp_runtime_invoke + 244
	25  libmonosgen-2.0.dylib               0x0000000103346af0 mono_jit_runtime_invoke + 1116
	26  libmonosgen-2.0.dylib               0x0000000103501c3c mono_runtime_invoke_checked + 148
	27  libmonosgen-2.0.dylib               0x000000010350921c mono_runtime_exec_main_checked + 116
	28  libmonosgen-2.0.dylib               0x000000010339ad78 mono_jit_exec + 364
	29  libxamarin-dotnet-debug.dylib       0x0000000102cc7984 xamarin_main + 2324
	30  MauiApp1                            0x0000000101b9647c main + 72
	31  dyld                                0x00000001023e1410 start_sim + 20
	32  ???                                 0x000000010254a274 0x0 + 4334068340

@drasticactions
Copy link
Contributor

drasticactions commented Oct 9, 2024

Trying with .NET 9 RC2, it works. So my guess is something regressed in 8.0.402/8.0.403, looking...

e. Current theory is #24873 regressed it.

@Zhanglirong-Winnie Zhanglirong-Winnie added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Oct 9, 2024
@Zhanglirong-Winnie
Copy link

This issue has been verified using Visual Studio 17.12.0 Preview 2.1(8.0.91 & 8.0.82). Can repro this issue on iOS18 platform. iOS17.5 works fine.

@MitchBomcanhao
Copy link

e. Current theory is #24873 regressed it.

@drasticactions but that PR hasn't made it to production yet (I think)?

@drasticactions
Copy link
Contributor

drasticactions commented Oct 9, 2024

e. Current theory is #24873 regressed it.

@drasticactions but that PR hasn't made it to production yet (I think)?

You're right, I was mistaken.

#25030

The dates threw me. The current 8.0 branch has the original code, so it's going into GetViewForSupplementaryElement and blowing up. Where net9.0 and main goes into MeasureSupplementaryView and works. So it is back ported, but didn't land in the release. And it probably wasn't caught as an iOS 18 bug (going by the original issues) because this was during the Xcode 16 release.

So nothing in MAUI itself "regressed" (in that, there was no recent code change), it didn't work in iOS 18 with what was originally there. Using net 9.0 RC2 or the main net8.0 nightly builds should get it working again.

@haavamoa
Copy link

haavamoa commented Oct 9, 2024

Looks like this issue has something to do with changes in iOS 18 and UICollectionView:
https://forums.developer.apple.com/forums/thread/756645?answerId=790296022#790296022

Another workaround is to downgrade .NET iOS workload to 17.5.8020/8.0.100 and make sure to use Xcode 15.4 to build for iOS 18. This works for us, but it's very unfortunate as we want to use Xcode 16 before .NET 9 launches. We want to use Xcode 16 with MAUI because it, at least for me, solves issues with debugger randomly disconnecting.

We downgrade our pipeline by doing this:

sudo dotnet workload install android ios --from-rollback-file sdk-versions.json

with the json file (sdk-versions.json) in the repo like this:

{
    "microsoft.net.sdk.android": "34.0.113/8.0.100",
    "microsoft.net.sdk.ios": "17.5.8020/8.0.100"
}
  

Our developers also has to run this on their mac's to make sure we run the same workload as our agents when developing.

But when this being said, I hope that the MAUI team will take a look at this issue as it do block us from running the latest version of macOS with Xcode 16 running against iOS 18, due to this template issue for collectionview.

@PureWeen
Copy link
Member

PureWeen commented Oct 9, 2024

Can you test with the latest nightly build?
https://github.com/dotnet/maui/wiki/Nightly-Builds

I wasn't able to reproduce on nightly so it looks like this will get resolved with SR9.2

@PureWeen PureWeen added the s/try-latest-version Please try to reproduce the potential issue on the latest public version label Oct 9, 2024
@samhouts samhouts added platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending labels Oct 9, 2024
@haavamoa
Copy link

Can you test with the latest nightly build? https://github.com/dotnet/maui/wiki/Nightly-Builds

I wasn't able to reproduce on nightly so it looks like this will get resolved with SR9.2

Yeah, upgrading to latest .NET 9 RC fixes it ✅

It would be very helpful if you could backport this fix to latest .NET 8 so people who are using grouped templates for collectionview can upgrade safely to latest macOS with Xcode 16 and latest iOS workload, without having to wait for RC 9 to go to go-live.

@drasticactions
Copy link
Contributor

drasticactions commented Oct 10, 2024

It already is backported and in the net8.0 service branch. It'll go out when that gets published.

@claytonone
Copy link
Author

@drasticactions Do we roughly know when sr9.2 will be released?

@dotnet-policy-service dotnet-policy-service bot removed the s/try-latest-version Please try to reproduce the potential issue on the latest public version label Oct 10, 2024
@ChrisDox
Copy link

For different reason i m on XCode 16 and latest Macos and latest maui Worklaod and i can't downgrade to XCode 15.4.
This wasn't planned but I have to update an app in production..So now i can't due to this iOS bug ....I have grouped collectionView in my app for iOS .
I'm currently blocked...When will an update for .Net 8 be released?

@PureWeen
Copy link
Member

Ideally in the next week

I pushed a nightly preview of 8.0.92

If you check nightly you'll see

8.0.92-*

That will match what we plan to release

@github-project-automation github-project-automation bot moved this from Todo to Done in MAUI SDK Ongoing Oct 10, 2024
@kaniosm
Copy link

kaniosm commented Oct 11, 2024

For those that would like to test with the nightly builds...
Nightly at the moment I'm writing is at 8.0.99-ci.net8.24511.3 and 8.0.92-ci.net8.24510.7 both published today...
8.0.99 crashes with error "xamarin_get_block_descriptor", but 8.0.92-ci.net8.24510.7 works fine for me.

@ChrisDox
Copy link

For those that would like to test with the nightly builds... Nightly at the moment I'm writing is at 8.0.99-ci.net8.24511.3 and 8.0.92-ci.net8.24510.7 both published today... 8.0.99 crashes with error "xamarin_get_block_descriptor", but 8.0.92-ci.net8.24510.7 works fine for me.

I don't know how to test with nightly builds.

@kaniosm
Copy link

kaniosm commented Oct 12, 2024

Hi @ChrisDox ,

Just follow the guide here: https://github.com/dotnet/maui/wiki/Nightly-Builds

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests