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

[ASDisplayNode] Always layout nodes on a background thread #1907

Merged
merged 5 commits into from
Jul 15, 2016
Merged

[ASDisplayNode] Always layout nodes on a background thread #1907

merged 5 commits into from
Jul 15, 2016

Conversation

maicki
Copy link
Contributor

@maicki maicki commented Jul 13, 2016

Some crazy idea and follow up to #1839. We will push the layout of nodes to always be on a background thread as based on the work in #1839 we will trampoline the layout automatically to the main thread if at least one node is loaded.

Furthermore there needs to be some more improvements to it:

  • Moving away from dispatching to global dispatch queues in layout transition and ASDataController
  • Remove the semaphore in ASDataController
  • Adding tests

@Adlai-Holler @nguyenhuy @appleguy @levi What do you guys think about that? We have to carefully think about that and check for any gotchas that could happen, if we really want to go forward with that.

@ghost ghost added the CLA Signed label Jul 13, 2016
[indexPaths addObject:context.indexPath];
// Nil out buffer indexes to allow arc to free the stored cells.
for (int i = 0; i < batchCount; i++) {
[allocatedNodes addObject:allocatedNodeBuffer[i]];
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's replace allocatedNodes with an immutable array created right here like NSArray *allocatedNodes = [NSArray arrayWithObjects:allocatedNodeBuffer count:batchCount]

Copy link
Contributor

@Adlai-Holler Adlai-Holler Jul 13, 2016

Choose a reason for hiding this comment

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

We can do something like that with the index paths. I think remove allocatedContextBuffer and make indexPathBuffer and then create an NSArray directly with that

@ghost ghost added the CLA Signed label Jul 14, 2016
@ghost ghost added the CLA Signed label Jul 14, 2016
@@ -791,7 +791,7 @@ - (void)transitionLayoutWithSizeRange:(ASSizeRange)constrainedSize
};

// TODO ihm: Can we always push the measure to the background thread and remove the parameter from the API?
if (shouldMeasureAsync) {
if (ASDisplayNodeThreadIsMain()) {
ASPerformBlockOnBackgroundThread(transitionBlock);
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this code already checks if it is on a background thread and performs it inline if so - maybe not?

@appleguy
Copy link
Contributor

@maicki very impressive combination of code simplification and performance improvement! Thank you!

@appleguy appleguy added this to the 1.9.9 milestone Jul 15, 2016
@appleguy appleguy merged commit a8c5ac1 into facebookarchive:master Jul 15, 2016
@ghost ghost added the CLA Signed label Jul 15, 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