Post

Replies

Boosts

Views

Activity

Crash while using UICollectionViewCompositionalLayout with pinned headers
Hi, I've implemented a 2D Grid View using UICollectionViewCompositionalLayout. Implementation Overview: Each row in the grid represented by a NSCollectionLayoutSection which contains a single instance of NSCollectionLayoutGroup. Each row also has a sticky header implemented using NSCollectionLayoutBoundarySupplementaryItem shown on leading edge of the row. It is set as a boundary item for the section. This row header is pinned to the visible bounds via pinToVisibleBounds property to make it sticky. I've also created a global sticky header for the 2D Grid View by creating an array of NSCollectionLayoutBoundarySupplementaryItem instance items(one for each column of the grid) and adding them to overall layout via UICollectionViewCompositionalLayoutConfiguration. These grid view header items are all pinned to the visible bounds via pinToVisibleBounds property to make them sticky while scrolling through rows. Although, it mostly worked with few tweaks by overriding UICollectionLayout methods, i am running into a random crash while scrolling through the grid view. Here's the crash 2022-04-09 00:28:56.335279-0700 *****[88274:5668805] *** Assertion failure in CGRect _UIPinnedFrameForFrameWithContainerFrameVisibleFrame(CGRect, CGRect, CGRect, NSRectAlignment)(), _UICollectionLayoutHelpers.m:688 2022-04-09 00:28:56.341980-0700 ******[88274:5668805] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Frame {{377, 0}, {0, 627}} does not intersect {{377, 0}, {0, 627}}' *** First throw call stack: ( 0  CoreFoundation           0x000000010aa45d44 __exceptionPreprocess + 242 1  libobjc.A.dylib           0x0000000107671a65 objc_exception_throw + 48 2  Foundation             0x00000001089357d9 -[NSMutableDictionary(NSMutableDictionary) classForCoder] + 0 3  UIKitCore              0x00000001187a09cb _UIPinnedNonOverlappingFramesForContentFrameVisibleFrame + 3154 4  UIKitCore              0x00000001187b7ff4 -[_UICollectionLayoutAuxillaryItemSolver _solveForPinning:visibleRect:] + 5748 5  UIKitCore              0x00000001187824ed -[_UICollectionCompositionalLayoutSolver updatePinnedSectionSupplementaryItemsForVisibleBounds:] + 723 6  UIKitCore              0x000000011877e542 -[UICollectionViewCompositionalLayout _updatePinnedSectionSupplementaryItemsForCurrentVisibleBounds] + 381 7  UIKitCore              0x000000011877f148 -[UICollectionViewCompositionalLayout _solveForPinnedSupplementaryItemsIfNeededWithContext:] + 121 8  UIKitCore              0x000000011877a203 -[UICollectionViewCompositionalLayout invalidateLayoutWithContext:] + 802 9  UIKitCore              0x000000011888770d -[UICollectionViewLayout _invalidateLayoutUsingContext:] + 56 10 UIKitCore              0x00000001188202e5 -[UICollectionView setBounds:] + 757 11 UIKitCore              0x0000000119713ab2 -[UIScrollView setContentOffset:] + 1047 12 UIKitCore              0x0000000118839f2e -[UICollectionView setContentOffset:] + 42 13 UIKitCore              0x0000000119728b6e -[UIScrollView _smoothScrollSyncWithUpdateTime:] + 3152 14 UIKitCore              0x0000000119727b55 -[UIScrollView _smoothScrollWithUpdateTime:] + 313 15 UIKitCore              0x0000000119728f06 -[UIScrollView _smoothScrollDisplayLink:] + 613 16 QuartzCore             0x0000000113937474 _ZN2CA7Display11DisplayLink14dispatch_itemsEyyy + 932 17 QuartzCore             0x0000000113a369c6 _ZL22display_timer_callbackP12__CFMachPortPvlS1_ + 395 18 CoreFoundation           0x000000010a97eb42 __CFMachPortPerform + 157 19 CoreFoundation           0x000000010a9b3125 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41 20 CoreFoundation           0x000000010a9b24cc __CFRunLoopDoSource1 + 617 21 CoreFoundation           0x000000010a9ac901 __CFRunLoopRun + 2420 22 CoreFoundation           0x000000010a9aba90 CFRunLoopRunSpecific + 562 23 GraphicsServices          0x0000000110617c8e GSEventRunModal + 139 24 UIKitCore              0x00000001191e490e -[UIApplication _run] + 928 25 UIKitCore              0x00000001191e9569 UIApplicationMain + 101 26 SEAnalyticsSDKSample        0x0000000106ec8b05 main + 229 27 dyld                0x0000000107140f21 start_sim + 10 28 ???                 0x000000011063d51e 0x0 + 4569945374 ) libc++abi: terminating with uncaught exception of type NSException *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Frame {{377, 0}, {0, 627}} does not intersect {{377, 0}, {0, 627}}' terminating with uncaught exception of type NSException I'm trying to understand what is causing this crash and how to prevent this crash from happening..
5
0
1.2k
Apr ’22