maui icon indicating copy to clipboard operation
maui copied to clipboard

[iOS] CollectionView with GroupHeader/GroupFooter crashes

Open Kink77 opened this issue 11 months ago • 4 comments

Description

Only happens if you have GroupHeaders and/or GroupFooters If you set the CollectionView's ItemsLayout to "VerticalList", it doesn't crash but you get a bunch of asserts in the logs. If you set the CollectionView's ItemsLayout to "VerticalGrid, 2", it crashes

<CollectionView ItemsLayout="VerticalList" ..../> <CollectionView ItemsLayout="VerticalGrid, 2" ..../>

Steps to Reproduce

Load the solution maui-samples/8.0/UserInterface/Views/CollectionViewDemos/CollectionViewDemos.sln Then edit the file Views/Grouping/VerticalListGroupingPage.xaml and add ItemsLayout="VerticalGrid, 2" to the CollectionView : <CollectionView ItemsLayout="VerticalGrid, 2"

Run the project and choose Grouping -> Vertical list with DataTemplates It will crash.

Link to public reproduction project repository

https://github.com/dotnet/maui-samples

Version with bug

8.0.7

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

7.0.101

Affected platforms

iOS

Affected platform versions

All iOS versions

Did you find any workaround?

Nope

Relevant log output

...
2024-03-21 10:33:46.204678-0400 CollectionViewDemos[3418:49104] [Assert] UICollectionView internal inconsistency: attempting to apply nil layout attributes to view. View: <Microsoft_Maui_Controls_Handlers_Items_VerticalSupplementaryView: 0x119fd4cb0; baseClass = UICollectionViewCell; frame = (0 0; 0 0); layer = <CALayer: 0x60000443bfe0>>; current attributes from view: (null); collection view: <UICollectionView: 0x110387e00; frame = (0 0; 353 700.333); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x600000c87ed0>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x60000085bba0>; contentOffset: {0, 0}; contentSize: {353, 2843.333333333333}; adjustedContentInset: {0, 0, 0, 0}; layout: <Microsoft_Maui_Controls_Handlers_Items_GridViewLayout: 0x1028e0360>; dataSource: <Microsoft_Maui_Controls_Handlers_Items_ReorderableItemsViewController_1: 0x1028c1cc0>>
2024-03-21 10:33:46.236196-0400 CollectionViewDemos[3418:49104] [UICollectionViewFeedbackLoopDebugger] Collection view <UICollectionView 0x600000e6ef70> is stuck in its update loop. This can happen when self-sizing views do not return consistent sizes, or the collection views frame/bounds/contentOffset is being constantly adjusted. To debug this issue, check the Console app for logs in the "UICollectionViewFeedbackLoopDebugger" category.
Collection view: <UICollectionView: 0x110387e00; frame = (0 0; 353 700.333); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x600000c87ed0>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x60000085bba0>; contentOffset: {0, 0}; contentSize: {353, 2843.333333333333}; adjustedContentInset: {0, 0, 0, 0}; layout: <Microsoft_Maui_Controls_Handlers_Items_GridViewLayout: 0x1028e0360>; dataSource: <Microsoft_Maui_Controls_Handlers_Items_ReorderableItemsViewController_1: 0x1028c1cc0>>
...
2024-03-21 10:33:46.241940-0400 CollectionViewDemos[3418:49104] [UICollectionViewFeedbackLoopDebugger] For layout pass 84, tracked invalidation with index 0 had 0 change(s). Reason: "Unspecified"; invalidatedSupplementaries: ["UICollectionElementKindSectionFooter": [[0, 0]]].
UIKitCore/_UICollectionViewFeedbackLoopDebugger.swift:81: Fatal error: <UICollectionView 0x600000e6ef70> is stuck in its recursive layout loop. This can happen when self-sizing views do not return consistent sizes, or the collection views frame/bounds/contentOffset is being constantly adjusted. To debug this issue, check the Console app for logs in the "UICollectionViewFeedbackLoopDebugger" category.
Collection view: <UICollectionView: 0x110387e00; frame = (0 0; 353 700.333); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x600000c87ed0>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x60000085bba0>; contentOffset: {0, 0}; contentSize: {353, 2843.333333333333}; adjustedContentInset: {0, 0, 0, 0}; layout: <Microsoft_Maui_Controls_Handlers_Items_GridViewLayout: 0x1028e0360>; dataSource: <Microsoft_Maui_Controls_Handlers_Items_ReorderableItemsViewController_1: 0x1028c1cc0>>
2024-03-21 10:33:46.242449-0400 CollectionViewDemos[3418:49104] UIKitCore/_UICollectionViewFeedbackLoopDebugger.swift:81: Fatal error: <UICollectionView 0x600000e6ef70> is stuck in its recursive layout loop. This can happen when self-sizing views do not return consistent sizes, or the collection views frame/bounds/contentOffset is being constantly adjusted. To debug this issue, check the Console app for logs in the "UICollectionViewFeedbackLoopDebugger" category.
Collection view: <UICollectionView: 0x110387e00; frame = (0 0; 353 700.333); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x600000c87ed0>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x60000085bba0>; contentOffset: {0, 0}; contentSize: {353, 2843.333333333333}; adjustedContentInset: {0, 0, 0, 0}; layout: <Microsoft_Maui_Controls_Handlers_Items_GridViewLayout: 0x1028e0360>; dataSource: <Microsoft_Maui_Controls_Handlers_Items_ReorderableItemsViewController_1: 0x1028c1cc0>>

Kink77 avatar Mar 21 '24 14:03 Kink77

@Kink77 Please try with https://github.com/dotnet/maui/discussions/21353 this could possibly fix your issue.

phillippschmedt avatar Mar 21 '24 14:03 phillippschmedt

Hi @phillippschmedt Tried 8.0.14 and it's still crashing unfortunately!

Kink77 avatar Mar 21 '24 22:03 Kink77

Verified this issue with Visual Studio 17.10.0 Preview 2 (8.0.14/8.0.0-rc.2.9511). Can repro on iOS platform with sample project.

kevinxufei avatar Mar 22 '24 02:03 kevinxufei

We're encountering an issue on the release version of our app for both Android and iOS. The CollectionView group header appears as just a label and isn't rendered properly. It seems to be related to a binding problem that's only present in release mode, as everything appears fine when running in Debug mode. When we manually set a static value for the header, it displays correctly.

<CollectionView.GroupHeaderTemplate> <DataTemplate x:DataType="models:Item"> <Label FontAttributes="Bold" FontSize="12" Padding="20,16,20,8" Text="{Binding Name}" TextColor="#475467" /> </DataTemplate> </CollectionView.GroupHeaderTemplate>

AliKarimiENT avatar Apr 16 '24 12:04 AliKarimiENT