HomeiOS Developmentios - App hangs when eradicating all gadgets from part of UICollectionViewDiffableDataSource

ios – App hangs when eradicating all gadgets from part of UICollectionViewDiffableDataSource


Ran right into a bizarre regression(?) this week with UICollectionViewDiffableDataSource. I’ve a set view with a number of sections. I initially configure the datasource with the primary part empty, after which add the gadgets to it later. When refreshing the gathering view, I take away all gadgets from the primary part, however the different sections are usually not modified. I apply the snapshot on the primary thread (I ensure that to all the time apply snapshots on the identical thread).

var snapshot = dataSource.snapshot(for: .content material)
snapshot.deleteAll()
dataSource.apply(snapshot, to: .content material, animatingDifferences: false)

For some motive (am I loopy?) making use of this snapshot causes the app to hold. It does not crash, there isn’t a exception or stack hint, it simply freezes the primary thread completely–the identical method as if it have been caught in an infinite loop.

It solely does this when eradicating all gadgets from the part. I attempted eradicating all however one merchandise and it performs with out concern.

var snapshot = dataSource.snapshot(for: .content material)
let lastItem = snapshot.gadgets.final!
snapshot.deleteAll()
snapshot.append([lastItem])
dataSource.apply(snapshot, to: .content material, animatingDifferences: false)

I additionally tried eradicating and re-adding the part itself, and it additionally has the hanging habits.

var snapshot = dataSource.snapshot()
snapshot.deleteSections([.content])
snapshot.insertSections([.content], afterSection: .header)
dataSource.apply(snapshot, animatingDifferences: false)

The brand new applySnapshotUsingReloadData API additionally hangs.

var snapshot = dataSource.snapshot()
snapshot.deleteSections([.content])
snapshot.insertSections([.content], afterSection: .header)
dataSource.applySnapshotUsingReloadData(snapshot)

Is that this an odd iOS bug or am I lacking one thing? I not too long ago up to date my check gadget to iOS 17 and am undecided if that has something to do with it or is solely coincidence.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments