UICollectionView crashes in -performBatchUpdates: when header view is nil

Originator:paulmelnikow
Number:rdar://13326239 Date Originated:3/1/13
Status:Open Resolved:
Product:iPad SDK Product Version:6.1
Classification:Crash Reproducible:Always
 
Summary:
UICollectionView crashes in -performBatchUpdates: when header view is nil

Steps to Reproduce:
1) Run the attached project in the simulator

Or

1) Set a header size in UICollectionView, but don't provide a supplementary view
2) Invoke -performBatchUpdates with an empty block

Expected Results:
Leaves space for a header view without actually drawing it. This is identical to what would happen if you don't call -performBatchUpdates.

Actual Results:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: <_UICollectionViewItemKey: 0x109440b0> Type = SV Kind = UICollectionElementKindSectionHeader IndexPath = <NSIndexPath 0x10944080> 2 indexes [0, 0])'

* thread #1: tid = 0x1f03, 0x010d0e52 libobjc.A.dylib`objc_exception_throw, stop reason = breakpoint 1.3
    frame #0: 0x010d0e52 libobjc.A.dylib`objc_exception_throw
    frame #1: 0x01d160de CoreFoundation`-[__NSDictionaryM setObject:forKey:] + 158
    frame #2: 0x00515aa0 UIKit`-[UICollectionView _setVisibleSupplementaryView:forKind:indexPath:] + 93
    frame #3: 0x005258f9 UIKit`-[UICollectionView _viewAnimationsForCurrentUpdate] + 6745
    frame #4: 0x005266f8 UIKit`-[UICollectionView _updateWithItems:] + 1615
    frame #5: 0x00523bdb UIKit`-[UICollectionView _endItemAnimations] + 13286
    frame #6: 0x005275f5 UIKit`-[UICollectionView _endUpdates] + 48
    frame #7: 0x005276b9 UIKit`-[UICollectionView performBatchUpdates:completion:] + 191
    frame #8: 0x00003627 UICollectionViewBug`-[ViewController setItems:](self=0x075504c0, _cmd=0x005bce1d, items=0x07551190) + 231 at ViewController.m:59
    frame #9: 0x0000322f UICollectionViewBug`-[ViewController viewDidLoad](self=0x075504c0, _cmd=0x005c7a77) + 463 at ViewController.m:34
    frame #10: 0x000f61c7 UIKit`-[UIViewController loadViewIfRequired] + 536
    frame #11: 0x000f6232 UIKit`-[UIViewController view] + 33
    frame #12: 0x000453d5 UIKit`-[UIWindow addRootViewControllerViewIfPossible] + 66
    frame #13: 0x0004576f UIKit`-[UIWindow _setHidden:forced:] + 368
    frame #14: 0x00045905 UIKit`-[UIWindow _orderFrontWithoutMakingKey] + 49
    frame #15: 0x0004e917 UIKit`-[UIWindow makeKeyAndVisible] + 65
    frame #16: 0x00002c55 UICollectionViewBug`-[AppDelegate application:didFinishLaunchingWithOptions:](self=0x0754ada0, _cmd=0x005abc21, application=0x07649cf0, launchOptions=0x00000000) + 661 at AppDelegate.m:21
    frame #17: 0x00012157 UIKit`-[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 266
    frame #18: 0x00012747 UIKit`-[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1248
    frame #19: 0x0001394b UIKit`-[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 805
    frame #20: 0x00024cb5 UIKit`-[UIApplication handleEvent:withNewEvent:] + 1022
    frame #21: 0x00025beb UIKit`-[UIApplication sendEvent:] + 85
    frame #22: 0x00017698 UIKit`_UIApplicationHandleEvent + 9874
    frame #23: 0x01beedf9 GraphicsServices`_PurpleEventCallback + 339
    frame #24: 0x01beead0 GraphicsServices`PurpleEventCallback + 46
    frame #25: 0x01c08bf5 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
    frame #26: 0x01c08962 CoreFoundation`__CFRunLoopDoSource1 + 146
    frame #27: 0x01c39bb6 CoreFoundation`__CFRunLoopRun + 2118
    frame #28: 0x01c38f44 CoreFoundation`CFRunLoopRunSpecific + 276
    frame #29: 0x01c38e1b CoreFoundation`CFRunLoopRunInMode + 123
    frame #30: 0x0001317a UIKit`-[UIApplication _run] + 774
    frame #31: 0x00014ffc UIKit`UIApplicationMain + 1211
    frame #32: 0x0000298d UICollectionViewBug`main(argc=1, argv=0xbffff364) + 141 at main.m:16
    frame #33: 0x000028b5 UICollectionViewBug`start + 53

Regression:
The results occur on iOS 6.1.

Notes:
In ViewController.m, set WANT_CRASH to 0 to skip the call to -performBatchUpdates:, which prevents the crash.

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!