This assert indicates that the UITableView internal state is "corrupted". The most frequent cause is when the table view is performing an update or reload, and is in the middle of a callback to one of the data source or delegate methods, and somehow your code causes unexpected "reentrancy" on the UITableView (e.g. by performing another update/reload or by manually running the main runloop) from inside this callback. This causes UITableView to get into an inconsistent internal state because it's already in the middle of processing another update.
In my case I have a bad interaction between UITableView and the NSAttributedString() init method that using SwiftSoup to converts html to an attributedString. It was being called while updating a tableViewCell and this caused cellForRowAt to be called again while my app code was already processing a cellForRowAt call. And the tableView lost its mind after that.
I fixed this problem by converting html to an attributedString earlier before cellForRowAt run, then cellForRowAt using it.