This repository has been archived by the owner on Feb 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[ASDisplayNode] Trigger a layout pass whenever a node enters preload state #3263
Merged
Adlai-Holler
merged 9 commits into
facebookarchive:master
from
nguyenhuy:HNBetterPreloadStateIntegration
Apr 13, 2017
Merged
[ASDisplayNode] Trigger a layout pass whenever a node enters preload state #3263
Adlai-Holler
merged 9 commits into
facebookarchive:master
from
nguyenhuy:HNBetterPreloadStateIntegration
Apr 13, 2017
Conversation
This file contains 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
- This ensures that all the subnodes have the correct size to preload their content.
nguyenhuy
force-pushed
the
HNBetterPreloadStateIntegration
branch
from
April 12, 2017 19:18
2dbcfbd
to
644bbc3
Compare
garrettmoon
approved these changes
Apr 13, 2017
Source/ASCollectionNode.mm
Outdated
{ | ||
[super didEnterDisplayState]; | ||
// Since an initial data load was triggered when this node enter preloads state, wait for it to finish | ||
[self waitUntilAllUpdatesAreCommitted]; |
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.
This is the scariest part of the change, @Adlai-Holler can you double check that this makes sense to you as well?
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.
Actually we don't need to do this so I removed it!
bernieperez
pushed a commit
to AtomTickets/AsyncDisplayKit
that referenced
this pull request
Apr 25, 2018
…state (facebookarchive#3263) * Add a thread-safe layoutIfNeeded implementation to ASDisplayNode * Trigger a layout pass when a display node enters preload state - This ensures that all the subnodes have the correct size to preload their content. * ASCollectionNode to trigger its initial data load when it enters preload state * Minor change in _ASCollectionViewCell * Layout sublayouts before dispatch to main for subclass hooks * Update comments * Don't wait until updates are committed when the collection node enters display state * Same deal for table node * Explain the layout trigger in ASDisplayNode
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.
This ensures all subnodes have the correct size to preload their content. This is important for image nodes, as well as collection and table nodes.
For collection node, we can take a step further by telling it load initial data during preload state. Without doing this, the node often loads when it enters display state which is too late. And its cells can't even start prefetching before the loading finishes. Here is a video on pin-to-pin swiping before (left) and after (right) this diff.
Since ASDisplayNode currently doesn't have a
layoutIfNeeded
implementation, I'd have to allocate its view/layer (or call__layout
directly) in order to trigger a layout pass. Instead, I went ahead and implement the method. It's more convenient for users and helps them to avoid prematurely allocate the backing store.I also took the opportunity to revisit the locking situation of some methods inside
ASDisplayNode+UIViewBridge
.