Open jujdu opened 3 years ago
This looks like the same crash as https://github.com/ra1028/DiffableDataSources/issues/28.
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.
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"