UICollectionView crash with confusing message after batch updates and reload
Originator: | n.morev | ||
Number: | rdar://29328986 | Date Originated: | November 18 2016, 11:49 AM |
Status: | CLOSED DUPLICATE OF 28496311 CLOSED | Resolved: | |
Product: | UIKit | Product Version: | iOS 10.1 |
Classification: | Crash | Reproducible: | Always |
Area: UIKit Summary: If you perform updates on a UICollectionView in one iteration of run loop in the following order: 1. Batch updates. 2. Reload and layout. 3. Batch updates. Steps to Reproduce: See the attached project. Run its unit tests to reproduce the issue. Expected Results: The collection view updates its contents correctly without any crashes. Actual Results: You get crash with the following error message: 2016-11-18 11:40:09.411 CollectionViewUpdateCrash[56136:10665323] *** Assertion failure in -[UICollectionViewData indexPathForItemAtGlobalIndex:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.5.2/UICollectionViewData.m:652 /Users/n.morev/Developer/Playground/CollectionViewUpdateCrash/CollectionViewUpdateCrashTests/CollectionViewUpdateCrashTests.m:87: error: -[CollectionViewUpdateCrashTests testConsecutiveUpdatesFollowedByReloads] : failed: caught "NSInternalInconsistencyException", "request for index path for global index 9223372036854775806 when there are only 1 items in the collection view" ( 0 CoreFoundation 0x000000010364334b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x00000001011f121e objc_exception_throw + 48 2 CoreFoundation 0x0000000103647442 +[NSException raise:format:arguments:] + 98 3 Foundation 0x0000000100d87e4d -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195 4 UIKit 0x0000000102068851 -[UICollectionViewData indexPathForItemAtGlobalIndex:] + 294 5 UIKit 0x0000000102069051 -[UICollectionViewData layoutAttributesForGlobalItemIndex:] + 30 6 UIKit 0x000000010201f928 -[UICollectionView _viewAnimationsForCurrentUpdate] + 8094 7 UIKit 0x00000001020247e1 __71-[UICollectionView _updateWithItems:tentativelyForReordering:animator:]_block_invoke.1983 + 197 8 UIKit 0x00000001017796e6 +[UIView(Animation) performWithoutAnimation:] + 90 9 UIKit 0x0000000102023337 -[UICollectionView _updateWithItems:tentativelyForReordering:animator:] + 3942 10 UIKit 0x000000010201d369 -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:] + 17765 11 UIKit 0x0000000102025dba -[UICollectionView _endUpdatesWithInvalidationContext:tentativelyForReordering:animator:] + 71 12 UIKit 0x00000001020260fc -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:animator:] + 432 13 UIKit 0x0000000102025f29 -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:] + 91 14 UIKit 0x0000000102025eab -[UICollectionView _performBatchUpdates:completion:invalidationContext:] + 74 15 UIKit 0x0000000102025e00 -[UICollectionView performBatchUpdates:completion:] + 53 16 CollectionViewUpdateCrashTests 0x000000010d484443 -[CollectionViewUpdateCrashTests testConsecutiveUpdatesFollowedByReloads] + 3923 17 CoreFoundation 0x00000001035ca05c __invoking___ + 140 18 CoreFoundation 0x00000001035c9ee1 -[NSInvocation invoke] + 289 19 XCTest 0x000000010d0b1f77 __24-[XCTestCase invokeTest]_block_invoke_2 + 481 20 XCTest 0x000000010d0ea7df -[XCTestContext performInScope:] + 190 21 XCTest 0x000000010d0b1d83 -[XCTestCase invokeTest] + 255 22 XCTest 0x000000010d0b259c -[XCTestCase performTest:] + 457 23 XCTest 0x000000010d0af664 -[XCTestSuite performTest:] + 491 24 XCTest 0x000000010d0af664 -[XCTestSuite performTest:] + 491 25 XCTest 0x000000010d0af664 -[XCTestSuite performTest:] + 491 26 XCTest 0x000000010d09b618 __25-[XCTestDriver _runSuite]_block_invoke + 51 27 XCTest 0x000000010d0bcd2b -[XCTestObservationCenter _observeTestExecutionForBlock:] + 602 28 XCTest 0x000000010d09b4b5 -[XCTestDriver _runSuite] + 436 29 XCTest 0x000000010d09c302 -[XCTestDriver _checkForTestManager] + 287 30 XCTest 0x000000010d0ebd67 _XCTestMain + 628 31 CoreFoundation 0x00000001035e825c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12 32 CoreFoundation 0x00000001035cd304 __CFRunLoopDoBlocks + 356 33 CoreFoundation 0x00000001035cca75 __CFRunLoopRun + 901 34 CoreFoundation 0x00000001035cc494 CFRunLoopRunSpecific + 420 35 GraphicsServices 0x00000001054e8a6f GSEventRunModal + 161 36 UIKit 0x00000001016c0964 UIApplicationMain + 159 37 CollectionViewUpdateCrash 0x0000000100c21bff main + 111 38 libdyld.dylib 0x000000010456668d start + 1 39 ??? 0x0000000000000005 0x0 + 5 ) The error message is confusing because nowhere I refer to number 9223372036854775806 (or -1). Version: Version 8.1 (8B62) Notes: Configuration: iOS 10.1 Simulator
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!
Apple Developer Relations December 6 2016, 6:34 PM The original report on this issue, Bug ID 28496311, is closed. If you still see the issue in a newer release, like iOS 11, please file a new bug report.