UICollectionView custom layout cells missing after inactive state

I have a collection view with a custom layout and a diffable datasource.
  • The collection view displays and behaves correctly when the app is launched intially.

  • I then switch over to another app and then switch back to my app.

  • Once dataSource.apply(snapshot, animatingDifferences: false) is executed things haywire:

    • The cells, supplementary views and decoration views go missing.

    • When I look at the view debugger, the collection view is in the view hierarchy but there are no child views


UIApplication.didBecomeActiveNotification is received.
The following functions from my custom layout are called:
  • prepare()

  • layoutAttributesForElements(in rect: CGRect) - attributes for cells are being returned

  • layoutAttributesForItem(at indexPath: IndexPath)

  • layoutAttributesForSupplementaryView(ofKind elementKind: String, at indexPath: IndexPath)

  • layoutAttributesForDecorationView(ofKind elementKind: String, at indexPath: IndexPath)

I have verified that these methods do return layout attributes for cells and the other views.

However, the datasource callback requests for cells are not being called and the cells are not displayed.

Any ideas what is going on? This only happens on device and not in the simulator.

This is on iOS 13.5
UICollectionView custom layout cells missing after inactive state
 
 
Q