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
This is an alternative fix / approach to fixing the data source count / internal model state mismatch that occurs when
UICollectionView
requests layout attributes before the layout has been notified about incoming batch updates.This bug became an issue after the layout loop fix PR was merged last week. That PR changed how we create layout attributes (no longer done in
prepareLayout
, and instead done lazily as layout attributes are requested for specific index paths). This behavior change assumed thatUICollectionView
would never try to request layout attributes for out-of-bounds index paths. Unfortunately, this is not a safe assumption.This PR changes our layout attributes creation code so that it returns
nil
if we detect an out-of-bounds index path. This is effectively howMagazineLayout
behaved prior to the layout loop fix PR. Reverting this behavior has no impact on the layout loop fix, which will continue to work.Also note that I'm not bumping the version / pushing a new release. I'll verify this works properly in the Airbnb iOS app, and if all looks good, then I'll push a new tag / make a new release.
Related Issue
N/A
Motivation and Context
Fix a crash.
How Has This Been Tested
Example app
Types of changes
Checklist