Skip to content

Defer invalidatation until all batch updates are finished#931

Closed
rnystrom wants to merge 3 commits into
masterfrom
defer-invalidate
Closed

Defer invalidatation until all batch updates are finished#931
rnystrom wants to merge 3 commits into
masterfrom
defer-invalidate

Conversation

@rnystrom
Copy link
Copy Markdown
Contributor

@rnystrom rnystrom commented Sep 13, 2017

Changes in this pull request

Added a mechanism to IGListAdapter to defer (queue or execute) blocks around asking the updater to do batch updates. I discovered a crash where the _updateCompletionHandler (private ivar) of UICollectionView was not being niled when two batch updates collide. There is an assert in -[UICollectionView dealloc] that fires if this block != nil. Took some reverse eng to track down what is happening.

Sadly I cannot reproduce the issue in a unit test or sample app. However I can 100% repro this in my GitHawk app. Applying this patch fixes the problem. I added a unit test that got me close to the state of the crash. Consider this new test future-proofing (also covers the enter/exit/defer stuff).

Also dumping the UICollectionView internals confirms that the bad state (_updateCompletionHandler != nil) is no longer true.

Issue fixed: #929

Depends on #930

Checklist

  • All tests pass. Demo project builds and runs.
  • I added tests, an experiment, or detailed why my change isn't tested.
  • I added an entry to the CHANGELOG.md for any breaking changes, enhancements, or bug fixes.

@rnystrom rnystrom added this to the 3.2.0 milestone Sep 13, 2017
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@rnystrom updated the pull request - view changes

@weyert
Copy link
Copy Markdown
Contributor

weyert commented Sep 13, 2017

I am still quite new to iOS development. May I ask what you mean with 'dumping the UICollectionView internals confirms'. How would this work or is it done? Are you dumping the assembly?

@rnystrom
Copy link
Copy Markdown
Contributor Author

@weyert chisel for advanced lldb and Hopper for disassembling (assembly to pseudocode).

Comment thread CHANGELOG.md

- Weakly reference the `UICollectionView` in coalescence so that it can be released if the rest of system is destroyed. [Ryan Nystrom](https://github.com/rnystrom) [(#tbd)](https://github.com/Instagram/IGListKit/pull/tbd)

- Avoid crash when invalidating the layout while inside `-[UICollectionView performBatchUpdates:completion:]. [Ryan Nystrom](https://github.com/rnystrom) [(#tbd)](https://github.com/Instagram/IGListKit/pull/tbd)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

missed backtick here `

Copy link
Copy Markdown
Contributor

@jessesquires jessesquires left a comment

Choose a reason for hiding this comment

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

@rnystrom rnystrom changed the title Defer invalidate Defer invalidatation until all batch updates are finished Sep 13, 2017
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@rnystrom has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalidating layout while in the middle of an update can cause a crash

4 participants