-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 18] Grouped CollectionView with header template and templateselector crashes immediately on iOS 18, works on iOS 17 #25514
Comments
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.
|
I've tried with the .NET 8 latest version 8.0.403/8.0.10 which is the last version available for .NET 8 but still didn't help at all with this issue and I'm still getting the same crash and exception. |
Same problem here. Works great on Droid. Crashes on IOS 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: 0x127bc0c00; baseClass = UICollectionViewCell; frame = (0 0; 0 0); alpha = 0; layer = <CALayer: 0x304105c60>>; Collection view: <Microsoft_Maui_Controls_Handlers_Items_MauiCollectionView: 0x114649c00; baseClass = UICollectionView; frame = (0 0; 375 132.5); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x300889050>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x3040c8460>; contentOffset: {0, 0}; contentSize: {375, 133}; adjustedContentInset: {0, 0, 0, 0}; layout: <Microsoft_Maui_Controls_Handlers_Items_ListViewLayout: 0x114568a00>; dataSource: <Microsoft_Maui_Controls_Handlers_Items_ReorderableItemsViewController_1: 0x11451a800>> |
Looks like this should be fixed with .NET MAUI 8.0.92, please try that one and let us know if that helps? |
I'm still getting the same problem on both an iPhone 7 running 18.01 and a sim running 17.2. Here are my packages
Seems to only happen on a collection view with grouped header. My other collection views are working fine. |
Do you have a reproduction for me? Because I just tried this in our sample app here in the repository, go to the grouped CollectionView page and it all seems to work fine, so there seems to be something specific to your case that seems to be going wrong. |
I created a test project and found my problem while doing it. I was using an ObservableCollection. I changed it to a List and it works fine now. |
I have the same problem, but I'm using a Telerik RadListView instead of a standard CollectionView. I also tried to change the source to List instead of ObservableCollection, but that didn't help. Maybe Telerik is converting it under the hood to an ObservableCollection. However, IMHO it should of course be possible to use an ObservableCollection as source. It works fine on Android but crashes on iOS. |
@jfversluis Here is the test app I created if it helps any. In InvoiceContentViewModel.cs just change the List to an ObservableCollection and it will recreate the issue.GroupedCollectionTest.zip |
Description
I've released my Maui app on App Store with multiple grouped CollectionView being used for different screens and it has been working fine till now on all iOS version, except the latest iOS 18. As customers have upgraded to iOS 18, and they're trying to use our app in iOS 18, it just keep crashing immediately as the landing page of the app has Grouped CollectionView implemented with TemplateSelector for different cell designs and it is one of the main page of the app. It is throwing this exception:
Unhandled managed exception: 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: 0x11907c600; baseClass = UICollectionViewCell; frame = (0 0; 0 0); alpha = 0; layer = <CALayer: 0x30b09c8a0>>; Collection view: <Microsoft_Maui_Controls_Handlers_Items_MauiCollectionView: 0x1179fea00; baseClass = UICollectionView; frame = (0 0; 390 669); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x303758900>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x307d03e00>; contentOffset: {0, 0}; contentSize: {390, 1464}; adjustedContentInset: {0, 0, 0, 0}; layout: <Microsoft_Maui_Controls_Handlers_Items_GridViewLayout: 0x11ca79900>; dataSource: <Microsoft_Maui_Controls_Handlers_Items_ReorderableItemsViewController_1: 0x11aff5400>>
(ObjCRuntime.ObjCException)
at ObjCRuntime.Runtime.ThrowException(IntPtr gchandle) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 2708
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
I've upgraded the MacOS to Mac Sequoia 15.0.1 and Xcode to 16, so now cannot downgraded to using Xcode 15.4. And infact I've release the app to store using Xcode 15.4 before this upgrade, but still it was crashing in iOS 18 devices.
I've also tried now to upgrade the MAUI packages to latest version to check if there's any fix for this issue in the latest MAUI version but still it's crashing.
We're completely stuck as the app is live on store and customers are reporting this issue and not able to use the app at all, so it's quite embarrassing and bad impression for the company as a provider. We need a fix for this ASAP.
Steps to Reproduce
Link to public reproduction project repository
No response
Version with bug
8.0.40 SR5
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
8.0.40 SR5
Affected platforms
iOS
Affected platform versions
iOS 18.0.1
Did you find any workaround?
Didn't find any workaround yet. Have tried upgrading the nuget packages to latest versions but that also didn't work.
Relevant log output
Unhandled managed exception: 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: 0x11907c600; baseClass = UICollectionViewCell; frame = (0 0; 0 0); alpha = 0; layer = <CALayer: 0x30b09c8a0>>; Collection view: <Microsoft_Maui_Controls_Handlers_Items_MauiCollectionView: 0x1179fea00; baseClass = UICollectionView; frame = (0 0; 390 669); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x303758900>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x307d03e00>; contentOffset: {0, 0}; contentSize: {390, 1464}; adjustedContentInset: {0, 0, 0, 0}; layout: <Microsoft_Maui_Controls_Handlers_Items_GridViewLayout: 0x11ca79900>; dataSource: <Microsoft_Maui_Controls_Handlers_Items_ReorderableItemsViewController_1: 0x11aff5400>>
(ObjCRuntime.ObjCException)
at ObjCRuntime.Runtime.ThrowException(IntPtr gchandle) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 2708
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
The text was updated successfully, but these errors were encountered: