UICollectionView was deallocated while an update was in flight

Originator:steipete
Number:rdar://46156228 Date Originated:18-Nov-2018 05:21 PM
Status:Open Resolved:
Product:iOS + SDK Product Version:iOS 12
Classification:Crash/Hang/Data Loss Reproducible:Sometimes
 
Summary:
We see crashers in the crash reporting of PDF Viewer in the form of UICollectionView (…) was deallocated while an update was in flight.

This seems to be an implementation detail in UIKit that is leaking out to developers. It’s not clear what “update in flight” means - did we forget to close an update group? Is an update scheduled and we have to wait a runloop before deallocating the view?

So far we are not able to reliably reproduce this issue, thus the radar has no sample project attached (sorry!)

Our preferred fix would be to hide this implementation detail and allow to deallocate UICollectionView no matter in what state is currently is in.


Stack Trace (this is from an iOS 10 system, but this also happens on iOS 11 and iOS 12.*)

Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x1b537b3d __exceptionPreprocess
1  libobjc.A.dylib                0x1a7bf067 objc_exception_throw
2  CoreFoundation                 0x1b537a19 +[NSException raise:format:]
3  Foundation                     0x1be2d52d (Missing)
4  UIKit                          0x208de4df -[UICollectionView dealloc]
5  CoreFoundation                 0x1b5291bb common_removeAllObjects
6  CoreFoundation                 0x1b44cc85 -[__NSArrayM dealloc]
7  libobjc.A.dylib                0x1a7d9259 objc_object::sidetable_release(bool)
8  libobjc.A.dylib                0x1a7d97a1 (anonymous namespace)::AutoreleasePoolPage::pop(void*)
9  UIKit                          0x2076202d -[UIView dealloc]
10 libobjc.A.dylib                0x1a7d97a1 (anonymous namespace)::AutoreleasePoolPage::pop(void*)
11 CoreFoundation                 0x1b444f49 _CFAutoreleasePoolPop
12 CoreFoundation                 0x1b4f1e23 __CFRunLoopRun
13 CoreFoundation                 0x1b4451af CFRunLoopRunSpecific
14 CoreFoundation                 0x1b444fd1 CFRunLoopRunInMode
15 GraphicsServices               0x1cbefb41 GSEventRunModal
16 UIKit                          0x207c7a53 UIApplicationMain
17 Viewer                         0x25aa1 main (main.swift:12)
18 libdyld.dylib                  0x1ac324eb start

Steps to Reproduce:
-

Expected Results:
-

Actual Results:
-

Version:
iOS 12

Notes:
Googling for this property looks like countless developer hours have been wasted, trying to work around these issues:

https://github.com/facebookarchive/AsyncDisplayKit/issues/2612
https://github.com/GitHawkApp/GitHawk/issues/1433
https://github.com/GitHawkApp/GitHawk/issues/1441
https://github.com/Instagram/IGListKit/issues/1127
https://github.com/Citrrus/MBContactPicker/issues/66
https://stackoverflow.com/questions/28713337/uicollectionview-delegate-deallocated-while-performing-reload
https://stackoverflow.com/questions/39597503/crash-collection-view-layout-mylayout-was-deallocated-while-an-update-was-i

(Internal link for my own reference: https://console.firebase.google.com/u/1/project/pspdfkit-pdf-viewer/crashlytics/app/ios:com.pspdfkit.viewer/issues/5b811de56007d59fcdc50cbc?time=last-seven-days&sessionId=e32e3fa31d69437cbe1356cda6ce856d_DNE_0_v2)

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!