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

Commit 11e07ff

Browse files
garrettmoonmaicki
authored andcommitted
Need to trampoline to main to make contents check safe if nodes are loaded. (#2545)
1 parent 62a0296 commit 11e07ff

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

AsyncDisplayKit/ASDisplayNode.mm

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,15 @@ - (void)_completePendingLayoutTransition
11431143
[self setCalculatedDisplayNodeLayout:_pendingLayoutTransition.pendingLayout];
11441144
[self _completeLayoutTransition:_pendingLayoutTransition];
11451145
}
1146-
[self _pendingLayoutTransitionDidComplete];
1146+
1147+
// Trampoline to the main thread if necessary
1148+
if (_pendingLayoutTransition && _pendingLayoutTransition.isSynchronous == NO) {
1149+
[self _pendingLayoutTransitionDidComplete];
1150+
} else {
1151+
ASPerformBlockOnMainThread(^{
1152+
[self _pendingLayoutTransitionDidComplete];
1153+
});
1154+
}
11471155
}
11481156

11491157
/*
@@ -1158,7 +1166,7 @@ - (void)_completeLayoutTransition:(ASLayoutTransition *)layoutTransition
11581166
}
11591167

11601168
// Trampoline to the main thread if necessary
1161-
if (ASDisplayNodeThreadIsMain() || layoutTransition.isSynchronous == NO) {
1169+
if (layoutTransition.isSynchronous == NO) {
11621170
[layoutTransition commitTransition];
11631171
} else {
11641172
// Subnode insertions and removals need to happen always on the main thread if at least one subnode is already loaded
@@ -1186,7 +1194,7 @@ - (void)_pendingLayoutTransitionDidComplete
11861194
if (CGSizeEqualToSize(layoutSize, CGSizeZero)) {
11871195
return;
11881196
}
1189-
1197+
11901198
if (!_placeholderImage) {
11911199
_placeholderImage = [self placeholderImage];
11921200
}

0 commit comments

Comments
 (0)