Crash in NSDiffableDataSourceSnapshot.deleteItems

The following crash is happening in iOS 16 when we call snapshot.reconfigureItems(ids).

We get the ids to reload by calling the CollectionView's indexPathsForVisibleItems, where the idea is to refresh the currently visible items.

#0	(null) in __exceptionPreprocess ()
#1	(null) in objc_exception_throw ()
#2	(null) in -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] ()
#3	(null) in -[__UIDiffableDataSourceSnapshot _validateReloadUpdateThrowingIfNeeded:] ()
#4	(null) in -[__UIDiffableDataSourceSnapshot _commitUpdateAtomic:] ()
#5	(null) in -[__UIDiffableDataSourceSnapshot reconfigureItemsWithIdentifiers:] ()
#6	(null) in NSDiffableDataSourceSnapshot.deleteItems(_:) ()

We are also seeing a slight variation of the same crash:

#0	(null) in __exceptionPreprocess ()
#1	(null) in objc_exception_throw ()
#2	(null) in -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] ()
#3	(null) in -[_UIDiffableDataSourceUpdate initWithIdentifiers:sectionIdentifiers:action:desinationIdentifier:relativePosition:destinationIsSection:] ()
#4	(null) in -[_UIDiffableDataSourceUpdate initWithReconfiguredItemIdentifiers:] ()
#5	(null) in -[__UIDiffableDataSourceSnapshot reconfigureItemsWithIdentifiers:] ()
#6	(null) in NSDiffableDataSourceSnapshot.deleteItems(_:) ()

These two crashes taken together currently account for 50% of all our app's crashes. According to the data we have, it is specific to iOS 16.

Some questions:

  • Is there anything we can do to mitigate this crash?
  • Can we safely call snapshot.reloadItems(ids) instead? If so, how much of a performance hit would we expect to get?

Same crash here. iOS 16.6

Crash in NSDiffableDataSourceSnapshot.deleteItems
 
 
Q