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

Layer backed nodes thrash issue #1086

Conversation

wsdwsd0829
Copy link
Contributor

@wsdwsd0829 wsdwsd0829 commented Aug 28, 2018

Layer backed nodes will get following calls very often (thrashing) during UIKit operations like reloadItemAtIndexPath: or pop a view top view controller will be thrashed!!!):

- (id<CAAction>)actionForLayer:(CALayer *)layer forKey:(NSString *)event
{
  if (event == kCAOnOrderIn) {
    NSLog(@"&&&& entering: %@", self);
    [self __enterHierarchy];
  } else if (event == kCAOnOrderOut) {
    NSLog(@"&&&& exiting: %@", self);
    [self __exitHierarchy];
  }
  ASDisplayNodeAssert(_flags.layerBacked, @"We shouldn't get called back here unless we are layer-backed.");
  return (id)kCFNull;
}

Problems

  • Problem 1: Even though interface coalescing will solve didEnterVisible calls correctly for views, it will not for isLayerBacked nodes.
  • Problem 2: __exitHierarchy will [self._locked_asyncLayer cancelAsyncDisplay]; causing some layerBacked view’s not updated properly during thrashing.

Solutions

  • Sol for 1; during “exiting”, layer will exit visible interface state no matter what, we should update their interface state when entering hierarchy. Since rangedMangedNodes will enter top down, a non-layerbacked ancestor’s pendingInterfaceState seems to be reasonable candidate.
  • Sol for 2: Do not cancel display for layerBackedNodes because they must be descendant of some view backed nodes which will be cancelled correctly as before.

@ghost
Copy link

ghost commented Aug 28, 2018

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

Generated by 🚫 Danger

@wsdwsd0829
Copy link
Contributor Author

The fix is not ideal, may better just remove [self._locked_asyncLayer cancelAsyncDisplay];? (it seems to used before interface state is introduced)

@wsdwsd0829
Copy link
Contributor Author

Will fix them separately with better approaches.

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

1 participant