Fix number of sections being out of bounds crash #108
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Details
layoutAttributesForItemAt:
can be invoked with an out-of-bounds index path. Previous comments in code seem to indicate that this is not a new issue.I believe the root of all of these issues is that the layout can be invalidated in between when the data source counts change (from a batch update), and when the layout actually receives an invalidate context specifying that data source counts have changed. This behavior sucks, and I don't see a clear way to work around this. This is something that I chatted about with a UICollectionView engineer back in 2019, and that person made it sound like they were using some private APIs in the layout to work around this 😩
Related Issue
N/A
Motivation and Context
Crash / assertion "fix" / workaround
How Has This Been Tested
Example project
Types of changes
Checklist