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

Commit 3a1a987

Browse files
maickiAdlai Holler
authored andcommitted
Fix not propagating updating and propagating down the layout transition id if a subnode is added (#2018)
If a node was added to a supernode, the supernode could be in a layout pending state. All of the hierarchy state properties related to the transition need to be copied over as well as propagated down the subtree. This is especially important as with Implicit Hierarchy Management adding subnodes can happen while a transition is in fly
1 parent 735b4eb commit 3a1a987

1 file changed

Lines changed: 28 additions & 5 deletions

File tree

AsyncDisplayKit/ASDisplayNode.mm

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,18 +1877,35 @@ - (void)__setSupernode:(ASDisplayNode *)newSupernode
18771877
}
18781878
if (newSupernode) {
18791879
[self enterHierarchyState:stateToEnterOrExit];
1880+
1881+
// If a node was added to a supernode, the supernode could be in a layout pending state. All of the hierarchy state
1882+
// properties related to the transition need to be copied over as well as propagated down the subtree.
1883+
// This is especially important as with Implicit Hierarchy Management adding subnodes can happen while a transition
1884+
// is in fly
1885+
if (ASHierarchyStateIncludesLayoutPending(stateToEnterOrExit)) {
1886+
int32_t pendingTransitionId = newSupernode.pendingTransitionID;
1887+
if (pendingTransitionId != ASLayoutableContextInvalidTransitionID) {
1888+
{
1889+
ASDN::MutexLocker l(__instanceLock__);
1890+
_pendingTransitionID = pendingTransitionId;
1891+
1892+
// Propagate down the new pending transition id
1893+
ASDisplayNodePerformBlockOnEverySubnode(self, ^(ASDisplayNode * _Nonnull node) {
1894+
node.pendingTransitionID = _pendingTransitionID;
1895+
});
1896+
}
1897+
}
1898+
}
1899+
1900+
// Now that we have a supernode, propagate its traits to self.
1901+
ASEnvironmentStatePropagateDown(self, [newSupernode environmentTraitCollection]);
18801902
} else {
18811903
// If a node will be removed from the supernode it should go out from the layout pending state to remove all
18821904
// layout pending state related properties on the node
18831905
stateToEnterOrExit |= ASHierarchyStateLayoutPending;
18841906

18851907
[self exitHierarchyState:stateToEnterOrExit];
18861908
}
1887-
1888-
// now that we have a supernode, propagate its traits to self.
1889-
if (newSupernode != nil) {
1890-
ASEnvironmentStatePropagateDown(self, [newSupernode environmentTraitCollection]);
1891-
}
18921909
}
18931910
}
18941911

@@ -2160,6 +2177,12 @@ - (void)setPendingTransitionID:(int32_t)pendingTransitionID
21602177
ASDisplayNodeAssertTrue(_pendingTransitionID < pendingTransitionID);
21612178
_pendingTransitionID = pendingTransitionID;
21622179
}
2180+
2181+
- (int32_t)pendingTransitionID
2182+
{
2183+
ASDN::MutexLocker l(__instanceLock__);
2184+
return _pendingTransitionID;
2185+
}
21632186

21642187
- (void)setPreferredFrameSize:(CGSize)preferredFrameSize
21652188
{

0 commit comments

Comments
 (0)