This repository was archived by the owner on Feb 2, 2023. It is now read-only.
[ASDisplayNode] Always layout nodes on a background thread - #1907
Merged
appleguy merged 5 commits intoJul 15, 2016
Merged
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]]; |
Contributor
There was a problem hiding this comment.
Let's replace allocatedNodes with an immutable array created right here like NSArray *allocatedNodes = [NSArray arrayWithObjects:allocatedNodeBuffer count:batchCount]
Contributor
There was a problem hiding this comment.
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
| // 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); |
Contributor
There was a problem hiding this comment.
I believe this code already checks if it is on a background thread and performs it inline if so - maybe not?
Contributor
|
@maicki very impressive combination of code simplification and performance improvement! Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.