[UITableView _updateVisibleCellsNow:] IOS 13 Crash

Hello Apple Developer, we recently found that on some devices of IOS 13, there is a [UITableView _updateVisibleCellsNow:] Crash recursive call, the following is the stack



Thread 1 Queue : com.apple.main-thread (serial)

#0 0x00000001a1bb02fc in lookUpImpOrForward ()
#1 0x00000001a1ba1110 in object_getMethodImplementation ()
#2 0x00000001a16a2084 in _NSIsNSString ()
#3 0x00000001a1581f04 in -[NSTaggedPointerString isEqual:] ()
#4 0x00000001a1615850 in CFEqual ()
#5 0x00000001a16b407c in CFBasicHashFindBucket ()
#6 0x00000001a15dd19c in CFDictionaryGetValue ()
#7 0x00000001a974071c in -[UIView(Rendering) contentMode] ()
#8 0x00000001a8fada64 in -[_UIImageContentLayout initWithSource:target:] ()
#9 0x00000001a8fad7b4 in +[_UIImageContentLayout layoutForSource:inTarget:] ()
#10 0x00000001a97013bc in -[UIImageView _layoutForImage:] ()
#11 0x00000001a9701fe4 in -[UIImageView _setImageViewContents:] ()
#12 0x00000001a9702f38 in -[UIImageView _updateState] ()
#13 0x00000001a9704830 in -[UIImageView _setViewGeometry:forMetric:] ()
#14 0x00000001a96e18f0 in -[UIScrollView _layoutVerticalScrollIndicatorWithBounds:effectiveInset:contentOffset:fraction:additionalInset:cornerAdjust:showing:recalcSize:] ()
#15 0x00000001a96e129c in -[UIScrollView _adjustScrollerIndicators:alwaysShowingThem:] ()
#16 0x00000001a96cfc84 in -[UIScrollView setContentOffset:] ()
#17 0x00000001a94a0e2c in -[UITableView setContentOffset:] ()
#18 0x00000001a96ec9f8 in -[UIScrollView _adjustContentOffsetIfNecessary] ()
#19 0x00000001a9492688 in -[UITableView _restoreOrAdjustContentOffsetWithRowCount:initialContentInsetTop:] ()
#20 0x00000001a9481e64 in -[UITableView _updateVisibleCellsNow:] ()
#21 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#22 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#23 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#24 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#25 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#26 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#27 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#28 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#29 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#30 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#31 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#32 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#33 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#34 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#35 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#36 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#37 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#38 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#39 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#40 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#41 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#42 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#43 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#44 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
.............
#2185 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#2186 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#2187 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#2188 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#2189 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#2190 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#2191 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#2192 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#2193 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#2194 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#2195 0x00000001a9481e8c in -[UITableView _updateVisibleCellsNow:] ()
#2196 0x00000001a949e8d0 in -[UITableView layoutSubviews] ()
#2197 0x00000001a9752a94 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
#2198 0x00000001a4059818 in -[CALayer layoutSublayers] ()
#2199 0x00000001a405e03c in CA::Layer::layout_if_needed(CA::Transaction*) ()
#2200 0x00000001a4069800 in CA::Layer::layout_and_display_if_needed(CA::Transaction*) ()
#2201 0x00000001a3fc0804 in CA::Context::commit_transaction(CA::Transaction*, double) ()
#2202 0x00000001a3fea680 in CA::Transaction::commit() ()
#2203 0x00000001a93026a8 in _afterCACommitHandler ()
#2204 0x00000001a1612b24 in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#2205 0x00000001a160da24 in __CFRunLoopDoObservers ()
#2206 0x00000001a160dff0 in __CFRunLoopRun ()
#2207 0x00000001a160d7ac in CFRunLoopRunSpecific ()
#2208 0x00000001a080f180 in GSEventRunModal ()
#2209 0x00000001a92da244 in UIApplicationMain ()

This Crash has some strange phenomena:

1. Appears only on some devices: I have a lot of devices, this Crash only appears on the iPhone 6Plus

2. If you interrupt the debugging during the debugging process, there is a certain probability that Crash does not appear, unless you delete the app and rebuild it, you can continue to reproduce Crash

3. It seems that the problem is in the layoutSubView: method of the UITableView


In addition, I noticed that iOS 13 seems to have modified the implementation of [UITableView layoutSubViews]. In iOS 12,it call

[UITableView _updateVisibleCellsNow:isRecursive:]


and in IOS 13,it Call

[UITableView _updateVisibleCellsNow:]



This problem has been bothering me for a long time, please give me some help.

Yes, we have the same problem but related to UICollectionView only. Xcode 11 beta 6 - the problem still exists.

The same problem

We have observed significant increase of crashes on iOS 13 in [UICollectionView layoutSubviews], which calls `_updateVisibleCellsNow:`. We don't see the recursive calls, but the app crashes with NSInternalInconsistency "returned cell is invalid" even though we haven't touched that part of code for a long time.

The problem still exists for UICollectionView now.
All the crashing devices are iOS 13 and iOS 14.0. Has anyone found what the problem is?
same problem

we have 2 sections and this happens when booth footer (anchor bottom) supplementary items are visible... (not happening with headers tho)
We found the same problem on iOS 14.

I too am having this same problem in iOS 14.6. Has anyone found a solution, or are confident this is an Apple bug at this time? Has a radar been filed by OP?

How do we summon Eskimo?! :)

Having the same issue, any progress iOS 15.2

Hello. In my case, problem was be with orthogonalScrollingBehavior when collection has active heightAnchor. I find two solutions:

  1. Switch this property to default and use configuration.scrollDirection instead
  2. Change heightAnchor to intrinsticContentSize of collection

I have the same problem. In my case, I observe scrollview.contentOffset to control scrollview scroll to special position. when tableview update many visible cells, tableview will cause many scrollview.contentOffset change, and stack is over, and crash.

[UITableView _updateVisibleCellsNow:] IOS 13 Crash
 
 
Q