Crash in UICollectionViewData when performing no-op batch update
Originator: | kellerbryan19 | ||
Number: | rdar://48941906 | Date Originated: | 3/15/19 |
Status: | Open | Resolved: | No |
Product: | UIKit | Product Version: | iOS 12 |
Classification: | Crash | Reproducible: | YES |
Summary: There's a crash in UICollectionViewData if you do a no-op move update (move section 1 to 1, for example) and also move an item out of that section (move item at {1, 0} to {0, 0}, for example). I recognize that this batch update is useless, but it's actually easy to write a diffing algorithm between 2 data sets that results in this kind of update. Also, if collection view allows a batch update, then it certainly shouldn't crash :) 2019-03-15 15:43:31.744279-0700 CVDataOOBCrash[32852:5167573] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for index path for global index 1 when there are only 1 items in the collection view' *** First throw call stack: ( 0 CoreFoundation 0x00000001106331bb __exceptionPreprocess + 331 1 libobjc.A.dylib 0x000000010ec11735 objc_exception_throw + 48 2 CoreFoundation 0x0000000110632f42 +[NSException raise:format:arguments:] + 98 3 Foundation 0x000000010e614877 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194 4 UIKitCore 0x000000011284fbb0 -[UICollectionViewData indexPathForItemAtGlobalIndex:] + 285 5 UIKitCore 0x00000001128504f1 -[UICollectionViewData layoutAttributesForGlobalItemIndex:] + 30 6 UIKitCore 0x000000011282f175 -[UICollectionView _viewAnimationsForCurrentUpdate] + 5855 7 UIKitCore 0x0000000112834911 __71-[UICollectionView _updateWithItems:tentativelyForReordering:animator:]_block_invoke.1997 + 173 8 UIKitCore 0x000000011349b235 +[UIView(Animation) performWithoutAnimation:] + 90 9 UIKitCore 0x000000011283365d -[UICollectionView _updateWithItems:tentativelyForReordering:animator:] + 3847 10 UIKitCore 0x000000011282d555 -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:] + 16936 11 UIKitCore 0x0000000112835ee8 -[UICollectionView _endUpdatesWithInvalidationContext:tentativelyForReordering:animator:] + 71 12 UIKitCore 0x000000011283622b -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:animator:] + 434 13 UIKitCore 0x0000000112836056 -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:] + 90 14 UIKitCore 0x0000000112835fd9 -[UICollectionView _performBatchUpdates:completion:invalidationContext:] + 74 15 UIKitCore 0x0000000112835f2e -[UICollectionView performBatchUpdates:completion:] + 53 Steps to Reproduce: 1. Open sample project 2. Tap anywhere to perform the batch update Expected Results: No crash Actual Results: Crash Version/Build: iOS 12 Sample project: https://drive.google.com/file/d/1AzvN9g57fUZK5Z8fFB87-jx528syyKMO/view?usp=sharing
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Fixed in iOS 13.0