Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential fix for invalidation crashes #14

Merged
merged 2 commits into from
Nov 16, 2020

Conversation

JosephDuffy
Copy link
Member

As mentioned in #13 and #8 there are some scenarios where the collection view’s data is out-of-sync with the data in composed.

As mentioned in #13 calling layoutIfNeeded can trigger the data to be in sync again. In this I have added it to mappingWillBeginUpdating(_:) which appears to solve the problem.

It might be needed in replace(sectionProvider:) (because reloadData is called) and/or mappingDidInvalidate(_:) (for the same reason) but I’m still investigating.

I have validated this fix against #8 and it fixes the crash.

#13 still needs to be investigated and may require layoutIfNeeded to be called in mappingDidInvalidate. Marking as a draft until this is checked.

As mentioned in #13 and #8 there are some scenarios where the collection view’s data is out-of-sync with the data in composed.

As mentioned in #13 calling `layoutIfNeeded` can trigger the data to be in sync again. In this I have added it to `mappingWillBeginUpdating(_:)` which _appears_ to solve the problem.

It might be needed in `replace(sectionProvider:)` (because `reloadData` is called) and/or `mappingDidInvalidate(_:)` (for the same reason) but I’m still investigating.
@JosephDuffy JosephDuffy requested a review from shaps80 November 3, 2020 14:11
Copy link
Collaborator

@shaps80 shaps80 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JosephDuffy JosephDuffy marked this pull request as ready for review November 16, 2020 20:35
@JosephDuffy
Copy link
Member Author

I've been using this in an app that performs a lot of updates. Animations are working and it doesn't crash any more. Hopefully this was the last crash with the layout (assuming no misuse)

@JosephDuffy JosephDuffy merged commit cc1d8e4 into master Nov 16, 2020
@JosephDuffy JosephDuffy deleted the potential-fix-for-crashes branch November 16, 2020 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants