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

Clean up timing of layout tree flattening/ copying of unflattened tree for Weaver #1157

Merged
merged 6 commits into from
Oct 3, 2018

Conversation

mikezucc
Copy link
Contributor

@mikezucc mikezucc commented Oct 2, 2018

Before display, a node's layout tree is flattened in order to calculate display information such as position. In almost all cases, this happens early in the layout transition lifecycle (during calculateLayoutThatFits: ). However, there are special cases where this layout tree is not flattened until the very last opportunity so that debugging tools (Weaver) can inspect the layout tree.

With the move to use const references instead of shared_ptr's for the pending layout tree used in the layout transition, the flattened layout tree was accessible to changes in the pending stage of the transition, causing layout specs to sneak into the final step of the layout transition: moving subnodes.

Huy simplified this diff to just a few lines.

@CLAassistant
Copy link

CLAassistant commented Oct 2, 2018

CLA assistant check
All committers have signed the CLA.

@mikezucc mikezucc changed the title Copy pending layout during transition lifecycle Clean up timing of layout tree flattening/ copying of unflattened tree for Weaver Oct 2, 2018
@@ -993,12 +993,6 @@ - (void)_pendingLayoutTransitionDidComplete
_pendingLayoutTransition = nil;
}

- (void)_setCalculatedDisplayNodeLayout:(const ASDisplayNodeLayout &)displayNodeLayout
Copy link
Member

@nguyenhuy nguyenhuy Oct 2, 2018

Choose a reason for hiding this comment

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

For the record, this method is not called anywhere.

if (! [ASDisplayNode shouldStoreUnflattenedLayouts]) {
layout = [layout filteredNodeLayoutTree];
if ([ASDisplayNode shouldStoreUnflattenedLayouts]) {
_unflattenedLayout = layout;
Copy link
Member

@nguyenhuy nguyenhuy Oct 2, 2018

Choose a reason for hiding this comment

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

As discussed offline, there is a risk that the layout here will not be used/applied later on, and Weaver (or any other users of this API) will end up with a wrong unflattened layout. But given it's a debugging feature and should not be used in producation, the risk is small and doesn't warrant the complexity of previous implementation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add some comment about this fact?

if (! [ASDisplayNode shouldStoreUnflattenedLayouts]) {
layout = [layout filteredNodeLayoutTree];
if ([ASDisplayNode shouldStoreUnflattenedLayouts]) {
_unflattenedLayout = layout;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add some comment about this fact?

@mikezucc
Copy link
Contributor Author

mikezucc commented Oct 3, 2018

I will rebase with the correct author, no worry

@nguyenhuy nguyenhuy merged commit 9588692 into TextureGroup:master Oct 3, 2018
mikezucc added a commit to mikezucc/Texture that referenced this pull request Nov 7, 2018
…e for Weaver (TextureGroup#1157)

* Simpler Huy fix for more efficient delayed flattening of the layout tree

* Nit

* Remove pbx changes

* Update CHANGELOG.md

* Add note about change in timing of _flattenedLayout capture
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.

4 participants