Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

[ASDisplayNode] Allow measure always be off the main thread #1839

Merged
merged 3 commits into from
Jul 8, 2016
Merged

[ASDisplayNode] Allow measure always be off the main thread #1839

merged 3 commits into from
Jul 8, 2016

Conversation

maicki
Copy link
Contributor

@maicki maicki commented Jul 1, 2016

Currently measurement always needs to happen on the main thread if implicit hierarchy management is enabled as adding and removing from nodes needs to happen on the main thread. We now will trampoline to the main thread to do the insertion and deletion of nodes.

This also resolves the issue that can occur if a node is already loaded deep in the layout hierarchy in the layout that the node is transforming to. Before insertion or deletion is happening we need to crawl the layout hierarchy to check that though.

Open things:

  • This theoretically that would enable us always measure nodes in the data controller asynchronous
  • Furthermore this also would us allow to get rid of the shouldMeasureAsync parameter in transitionLayoutWithAnimation:shouldMeasureAsync:measurementCompletion: that I think should not be exposed at all - @levi any thoughts on that?
  • Do we need to check somehow the transition id in _applyLayout:layoutTransition: to abort the insertion or deletion of nodes if the block runs on the main thread?
  • Would it be worth to have it's own transition queue instead of always using one of the global background queues?

@appleguy @Adlai-Holler @levi Would be great if I could get a review and thoughts

@ghost ghost added the CLA Signed label Jul 1, 2016
@Adlai-Holler
Copy link
Contributor

If applyLayout:layoutTransition is called on a background thread, is it possible that a subnode involved in the transition could get its node loaded on the main thread after ASLayoutCanTransitionAsynchronous but before applySubnodeTransition?

Currently measurement always needs to happen on the main thread if implicit hierarchy management is enabled as adding and removing from nodes needs to happen on the main thread. We now will trampoline to the main thread to do the insertion and deletion of nodes.

This also resolves the issue that can occur if a node is already loaded deep in the layout hierarchy in the layout that the node is transforming to. Before insertion or deletion is happening we need to crawl the layout hierarchy to check that though.
@@ -838,8 +846,8 @@ - (void)setUsesImplicitHierarchyManagement:(BOOL)value

- (BOOL)_hasTransitionInProgress
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be _isTransitionInProgress

@maicki
Copy link
Contributor Author

maicki commented Jul 4, 2016

@Adlai-Holler Theoretically this can happen, in fact this can already happen with the current implementation too. So in this nothing will change. I don't know at the moment a good way to fix that, but we definitely should consider it in the broader refactoring around layout transitions that I'm working on.

@levi Addressed your comments

@levi @appleguy @Adlai-Holler Can I get another look on it. Thanks!

@Adlai-Holler
Copy link
Contributor

Awesome! Time to 🚢

@Adlai-Holler Adlai-Holler merged commit a2d4dc5 into facebookarchive:master Jul 8, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants