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

[Crash] Any UICollectionLayoutSectionOrthogonalScrollingBehavior except .none cause crash on iOS 11 #151

Open
jujdu opened this issue Mar 16, 2021 · 2 comments

Comments

@jujdu
Copy link

jujdu commented Mar 16, 2021

Any UICollectionLayoutSectionOrthogonalScrollingBehavior except .none cause crash on iOS 11 if a cell need to be reloaded (i.e. title of cell was changed).
"*** -[__NSDictionaryM setObject:forKey:]: key cannot be nil"

@nolanw
Copy link

nolanw commented May 6, 2021

This looks like the same crash as ra1028/DiffableDataSources#28.

@nolanw
Copy link

nolanw commented May 6, 2021

I'm suspicious of IBPCollectionViewCompositionalLayout not returning attributes for orthogonally-scrolling section items from -layoutAttributesForElementsInRect: and -layoutAttributesForItemAtIndexPath:. The iOS 11 crash backtrace looks like this:

#0	0x0000000104fbd001 in objc_exception_throw ()
#1	0x00000001059680bc in _CFThrowFormattedException ()
#2	0x000000010583b72a in -[__NSDictionaryM setObject:forKey:] ()
#3	0x0000000106f87f07 in -[UICollectionView _setVisibleView:forLayoutAttributes:] ()
#4	0x0000000106fa0dcb in __71-[UICollectionView _updateWithItems:tentativelyForReordering:animator:]_block_invoke.1997 ()
#5	0x000000010657c537 in +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] ()
#6	0x000000010657ca0f in +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:] ()
#7	0x0000000106fa00f5 in -[UICollectionView _updateWithItems:tentativelyForReordering:animator:] ()
#8	0x0000000106f99cc3 in -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:] ()
#9	0x0000000106f95554 in -[UICollectionView _updateRowsAtIndexPaths:updateAction:updates:] ()

and seems to happen when the collection view gets nil for an attributes's index path, then tries to use that nil index path as a key in a dictionary.

For what it's worth, UIKit's layout does return attributes instances for orthogonally-scrolling sections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants