-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[ASDisplayNode] Always layout nodes on a background thread #1907
[ASDisplayNode] Always layout nodes on a background thread #1907
Conversation
[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]]; |
There was a problem hiding this comment.
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]
There was a problem hiding this comment.
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
@@ -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); |
There was a problem hiding this comment.
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?
@maicki very impressive combination of code simplification and performance improvement! Thank you! |
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:
@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.