UITableViewAlertForCellForRowAtIndexPathAccessDuringUpdate when selected cells are reused.

I'm getting this message in console:

Code Block
[Assert] Attempted to call -cellForRowAtIndexPath: on the table view while it was in the process of updating its visible cells, which is not allowed. Make a symbolic breakpoint at UITableViewAlertForCellForRowAtIndexPathAccessDuringUpdate to catch this in the debugger and see what caused this to occur. Perhaps you are trying to ask the table view for a cell from inside a table view callback about a specific row? Table view: <UITableView: 0x10c04a000; frame = (0 0; 414 659); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x280262bb0>; layer = <CALayer: 0x280d302c0>; contentOffset: {0, 183.5}; contentSize: {414, 3068}; adjustedContentInset: {0, 0, 0, 0}; dataSource: <MyApp.MyDataSource: 0x282930ea0>>

It happens when my table view is in editing mode, some cells are selected and are about to be reused (I'm scrolling the table and selected cells leave the visible area).

I don't call -cellForRowAtIndexPath: or visibleCells directly in my code.

Here's the stack trace when this happens:

Code Block
Thread 1 Queue : com.apple.main-thread (serial)
#0 0x0000000185303650 in UITableViewAlertForCellForRowAtIndexPathAccessDuringUpdate ()
#1 0x0000000185303378 in -[UITableView _cellForRowAtIndexPath:usingPresentationValues:] ()
#2 0x00000001852f1bb0 in -[UITableView _updateSelectionGroupingForCell:atIndexPath:] ()
#3 0x00000001852f1e78 in -[UITableView _updateSelectionGroupingForVisibleCells] ()
#4 0x00000001852af9d0 in -[UITableViewCell showSelectedBackgroundView:animated:] ()
#5 0x00000001852b045c in -[UITableViewCell setSelected:animated:] ()
#6 0x00000001852adf5c in -[UITableViewCell prepareForReuse] ()
#7 0x000000018530b2b4 in -[UITableView _dequeueReusableViewOfType:withIdentifier:] ()
#8 0x000000018530b908 in -[UITableView _dequeueReusableCellWithIdentifier:forIndexPath:usingPresentationValues:] ()
#9 0x000000018530b764 in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] ()
#10 0x000000010103a4cc in MyDataSource.tableView(_:cellForRowAt:) at /../MyDataSource.swift:87
#11 0x000000010103a9f4 in @objc MyDataSource.tableView(_:cellForRowAt:) ()
#12 0x00000001853241ec in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] ()
#13 0x00000001852eff84 in -[UITableView _updateVisibleCellsNow:] ()
#14 0x000000018530e394 in -[UITableView layoutSubviews] ()
#15 0x0000000185643d90 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
#16 0x0000000185b59384 in -[CALayer layoutSublayers] ()
#17 0x0000000185b59858 in CA::Layer::layout_if_needed(CA::Transaction*) ()
#18 0x0000000185b6dff8 in CA::Layer::layout_and_display_if_needed(CA::Transaction*) ()
#19 0x0000000185ab3ee0 in CA::Context::commit_transaction(CA::Transaction*, double, double*) ()
#20 0x0000000185adf36c in CA::Transaction::commit() ()
#21 0x0000000185ae06fc in CA::Transaction::observer_callback(CFRunLoopObserver*, unsigned long, void*) ()
#22 0x00000001826c3358 in CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION ()
#23 0x00000001826bd5c4 in CFRunLoopDoObservers ()
#24 0x00000001826bdb74 in __CFRunLoopRun ()
#25 0x00000001826bd21c in CFRunLoopRunSpecific ()
#26 0x000000019973c784 in GSEventRunModal ()
#27 0x00000001850f6200 in -[UIApplication _run] ()
#28 0x00000001850fba74 in UIApplicationMain ()
#29 0x000000010111a824 in main at /.../MyApp/AppDelegate.swift:17
#30 0x000000018237d6c0 in start ()


This only happens in iOS 14.2, no such problem on iOS 13.7.

Does it look like an UIKit bug? Does anyone know how to solve it?


Answered by Frameworks Engineer in 650270022
Thanks for reporting this issue — you are correct that there should not be an error message logged in this case, and it is indeed a bug in UIKit. For this specific backtrace, the error message is harmless and does not indicate a real problem, so you can safely ignore it for now until the bug causing this error message is fixed in a future update.
Accepted Answer
Thanks for reporting this issue — you are correct that there should not be an error message logged in this case, and it is indeed a bug in UIKit. For this specific backtrace, the error message is harmless and does not indicate a real problem, so you can safely ignore it for now until the bug causing this error message is fixed in a future update.
I can confirm that I am also running into this issue with the same console message and near identical stack trace.
  • The error stops if the tableview has allowsMultipleSelection set to false or if the cell has selectionStyle set to .none

Neither answer is really practical for my needs, but it may help someone if they need a temporary workaround until the issue is fixed.
This issue should be resolved in iOS 14.5 (you can verify using the latest developer beta).

I am seeing this message while using the visionOS simulator, but not while using the iPhone simulator doing the same steps.

UITableViewAlertForCellForRowAtIndexPathAccessDuringUpdate when selected cells are reused.
 
 
Q