Diffable Data Source Warning: Non-Thread Confined Updates

Hello,

I’ve encountered a warning while working with UITableViewDiffableDataSource. Here’s the exact message:

Warning: applying updates in a non-thread confined manner is dangerous and can lead to deadlocks. Please always submit updates either always on the main queue or always off the main queue - view=<UITableView: 0x7fd79192e200; frame = (0 0; 375 667); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x600003f3c9f0>; backgroundColor = <UIDynamicProviderColor: 0x60000319bf80; provider = <NSMallocBlock: 0x600003f0ce70>>; layer = <CALayer: 0x6000036e8fa0>; contentOffset: {0, -116}; contentSize: {375, 20}; adjustedContentInset: {116, 0, 49, 0}; dataSource: <TtGC5UIKit29UITableViewDiffableDataSourceOC17ArticleManagement21DiscardItemsViewModel17SectionIdentifierSS: 0x600003228270>>

OS: iOS Version: iOS 17+, Xcode Version: 16.0, Frameworks: UIKit, Diffable Data Source, View: UITableView used with a UITableViewDiffableDataSource.

Steps to Reproduce:

  1. Using a diffable data source with a table view.
  2. Applying snapshot updates in the data source from a main thread.
  3. Warning occurs intermittently during snapshot application.

Expected Behavior: The snapshot should apply without warnings, provided the updates are on a main thread.

Actual Behavior: The warning suggests thread safety issues when applying updates on non-thread-confined queues.

Questions:

  • Is there a recommended best practice to handle apply calls in diffable data sources with thread safety in mind?
  • Could this lead to potential deadlocks if not addressed?

Note :- I confirm I am always reloading / reconfiguring data source on main thread. Please find the attached screenshots for the reference.

Any guidance or clarification would be greatly appreciated!

Diffable Data Source Warning: Non-Thread Confined Updates
 
 
Q