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

[ASCollectionNode/ASTableNode] Fix a crash occurs while remeasuring cell nodes #917

Merged
merged 4 commits into from
May 15, 2018

Conversation

nguyenhuy
Copy link
Member

@nguyenhuy nguyenhuy commented May 11, 2018

According to the stack trace below, this crash happened when _cellsForLayoutUpdates was mutated while being enumerated in -[ASCollectionView layoutSubviews]. Fix by making a copy of _cellsForLayoutUpdates (and immediately clear it) before passing it to -[ASDataController relayoutNodes:nodesSizeChanged:.

Apply the same fix to ASTableView.

screen shot 2018-05-11 at 4 40 21 pm

Internal JIRA ticket

@nguyenhuy nguyenhuy changed the title [ASCollectionView] Fix a crash occurs while remeasuring cell nodes [ASCollectionNode/ASTableNode] Fix a crash occurs while remeasuring cell nodes May 11, 2018
Copy link
Member

@Adlai-Holler Adlai-Holler left a comment

Choose a reason for hiding this comment

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

Fix seems perfectly sane. Re-entrancy, big problem!

Does it seem like the cause is, cell nodes calling -setNeedsLayout during the remeasure? It seems like that's the only re-entrant path by which _cellsForLayoutUpdates could be invalidated during a remeasure.

If so, would the ideal (costly) solution be to catch this case in general, and do our measuring in a loop like CA? Measure – check if they called setNeedsLayout – measure – check if they called etc. etc. and assert after some limit on the recursive dirtying?

@nguyenhuy
Copy link
Member Author

@Adlai-Holler Indeed, the only re-entrant path I can think of is -setNeedsLayout and -layoutIfNeeded being called during the re-measurement.

I agree that your solution sounds like the ideal behavior. However, since it'll be a bigger and riskier change, I'd propose to merge this diff as is and follow up on another diff. What do you think?

@Adlai-Holler
Copy link
Member

Yep thats the way

@nguyenhuy
Copy link
Member Author

Thanks!

@nguyenhuy nguyenhuy merged commit 0830f6c into TextureGroup:master May 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants