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] Add check for orphaned nodes after layout transition to clean up. #336

Merged
merged 1 commit into from
Jun 6, 2017

Conversation

appleguy
Copy link
Member

@appleguy appleguy commented Jun 6, 2017

It is rare that this code has any effect, but I've discovered a case in which it occurs.

This task tracks moving this code to a DEBUG-only assertion: #335

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.

@appleguy Dang this is an annoying issue.

Since this is a reasonably hot code path, let's use [NSHashTable hashTableWithOptions:NSHashTableObjectPointerPersonality] to avoid needless -hash and -isEqual: and then let's land.

Copy link
Member

@nguyenhuy nguyenhuy left a comment

Choose a reason for hiding this comment

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

I think this is a better place to remove orphaned nodes. However, I'm willing to accept this approach.

In the near future, we should aim to address the root cause, which I believe is due to the fact that ASLayoutTransition accepts it previous layout in the initializer, instead of at commit time (i.e -commitTransition). It means that the transition assumes that if it's allowed to proceed on main, the previous layout remains valid which is not true if there was layout pass triggered on main via -setNeedsLayout.

@appleguy appleguy force-pushed the SubnodeRemoval branch 2 times, most recently from 0875e09 to 4fc0dc0 Compare June 6, 2017 18:51
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.

LGTM

NSArray<ASDisplayNode *> *subnodes = [self subnodes];
NSHashTable<ASDisplayNode *> *currentSubnodes =
[[NSHashTable alloc] initWithOptions:NSHashTableObjectPointerPersonality
capacity:subnodes.count];
Copy link
Member

Choose a reason for hiding this comment

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

Totally optional, you can do auto currentSubnodes = [[NSHashTable<ASDisplayNode *> alloc]…] to save some characters.

…sition to clean up.

It is rare that this code has any effect, but I've discovered a case in which it occurs.

This task tracks moving this code to a DEBUG-only assertion: #335
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.

(Diff was amended to be more readable.) Awesome!

auto currentSubnodes = [[NSHashTable alloc] initWithOptions:NSHashTableObjectPointerPersonality
capacity:subnodes.count];
auto layoutSubnodes = [[NSHashTable alloc] initWithOptions:NSHashTableObjectPointerPersonality
capacity:sublayouts.count];;
Copy link
Member

Choose a reason for hiding this comment

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

Except this double-semicolon =)

@appleguy appleguy merged commit 00013aa into master Jun 6, 2017
@appleguy appleguy deleted the SubnodeRemoval branch June 6, 2017 19:38
bernieperez pushed a commit to AtomTickets/Texture that referenced this pull request Apr 25, 2018
…sition to clean up. (TextureGroup#336)

It is rare that this code has any effect, but I've discovered a case in which it occurs.

This task tracks moving this code to a DEBUG-only assertion: TextureGroup#335
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

3 participants