performBatchUpdates completion block not invoked

Originator:kellerbryan19
Number:rdar://48941363 Date Originated:3/15/19
Status:Open Resolved:No
Product:UIKit Product Version:iOS 12
Classification:Bug Reproducible:Yes
 
Area:
UIKit

Summary:
Certain batch updates, which UICollectionView happily accepts without asserting, can cause the collection view to not call the completion handler of performBatchUpdates.

To be more specific, moving an item out of an existing section and into an appearing / inserted section causes no warning or assertion, but  internally results in reloadData getting called, rather than the incremental batch update path.

The place that reloadData is called (rather than continuing down the batch update path) is `[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:]`. It seems like UICollectionView internally understands that you shouldn't move an  item into an inserting section, and silently falls back to the sledgehammer approach - reloadData.

Since reloadData ends up getting called, the UIView animator object's completion handler never gets called, meaning performBatchUpdate's completion handler doesn't get called either. If a batch update that  results in an  animation eventually runs, then all previous completion handlers will be invoked (seems they're getting stored off internally).

Steps to Reproduce:
1. Download sample code
2. Tap anywhere to do the batch update

Expected Results:
- UICollectionView should tell me I'm doing something wrong (warning in the console at a minimum) AND the performBatchUpdates  documentation contains information about this limitation AND the completion handler should be invoked despite the lack of animation
<OR>
- UICollectionView should handle this correctly and allow a move from an existing section into a new section

Actual Results:
No warning, no error, no completion block

Version/Build:
iOS 12

Configuration:





Sample project: https://drive.google.com/file/d/1LQVo3WqeQOcTilIgZcwWddVgZhpI6g-d/view?usp=sharing

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!