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

[ASDisplayNode+Layout] In layoutThatFits:, check and use _pending layout if valid. #413

Merged
merged 2 commits into from
Jul 5, 2017

Conversation

appleguy
Copy link
Member

@appleguy appleguy commented Jul 4, 2017

I believe this check is supposed to be here. Unit tests pass with it in place.
Without it, calling layoutThatFits: (as ASDataController does) and then calling
it again later (as ASCollectionNode does when answering the sizeForItem: call)
will recompute the layout, potentially on main.

This seems to have more of an impact / benefit for Yoga layouts, but I don't think
its benefit is exclusive to them.

…out if valid.

I believe this check is supposed to be here. Unit tests pass with it in place.
Without it, calling layoutThatFits: (as ASDataController does) and then calling
it again later (as ASCollectionNode does when answering the sizeForItem: call)
will recompute the layout, potentially on main.

This seems to have more of an impact / benefit for Yoga layouts, but I don't think
its benefit is exclusive to them.
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.

Whoa! Makes sense to me. Explains why I'm seeing a lot of extra layout calculations for collection updates.

@ghost
Copy link

ghost commented Jul 4, 2017

🚫 CI failed with log

@ghost
Copy link

ghost commented Jul 4, 2017

1 Warning
⚠️ Any source code changes should have an entry in CHANGELOG.md or have #trivial in their title.

Generated by 🚫 Danger

@nguyenhuy
Copy link
Member

Just to be clear, the extra layout pass will occur if there is a valid pending layout but -layoutThatFits: is called before it's applied to the node?

If that is the case then this diff actually makes perfect sense. I recall getting a report from a friend about extra layout passes triggered on main, in -performBatchUpdates: that in turn asked for -sizeForItem:.

Why didn't we have catch this earlier? Or was the check there before but somehow removed?

@nguyenhuy nguyenhuy merged commit fb6cad9 into master Jul 5, 2017
@appleguy appleguy deleted the PendingLayout branch July 5, 2017 20:56
bernieperez pushed a commit to AtomTickets/Texture that referenced this pull request Apr 25, 2018
…out if valid. (TextureGroup#413)

I believe this check is supposed to be here. Unit tests pass with it in place.
Without it, calling layoutThatFits: (as ASDataController does) and then calling
it again later (as ASCollectionNode does when answering the sizeForItem: call)
will recompute the layout, potentially on main.

This seems to have more of an impact / benefit for Yoga layouts, but I don't think
its benefit is exclusive to them.
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.

None yet

4 participants