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

Commit 1d07759

Browse files
committed
[ASDisplayNode+AsyncDisplay] Add locking for _flags (although write-once-on-init, this quiets the Thread Sanitizer).
1 parent 3efd01a commit 1d07759

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

AsyncDisplayKit/Private/ASDisplayNode+AsyncDisplay.mm

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,11 @@ - (void)_recursivelyRasterizeSelfAndSublayersWithIsCancelledBlock:(asdisplaynode
182182
- (asyncdisplaykit_async_transaction_operation_block_t)_displayBlockWithAsynchronous:(BOOL)asynchronous isCancelledBlock:(asdisplaynode_iscancelled_block_t)isCancelledBlock rasterizing:(BOOL)rasterizing
183183
{
184184
asyncdisplaykit_async_transaction_operation_block_t displayBlock = nil;
185-
185+
ASDisplayNodeFlags flags;
186+
_propertyLock.lock();
187+
flags = _flags;
188+
_propertyLock.unlock();
189+
186190
ASDisplayNodeAssert(rasterizing || !(_hierarchyState & ASHierarchyStateRasterized), @"Rasterized descendants should never display unless being drawn into the rasterized container.");
187191

188192
if (!rasterizing && self.shouldRasterizeDescendants) {
@@ -226,7 +230,7 @@ - (asyncdisplaykit_async_transaction_operation_block_t)_displayBlockWithAsynchro
226230

227231
return image;
228232
};
229-
} else if (_flags.implementsInstanceImageDisplay || _flags.implementsImageDisplay) {
233+
} else if (flags.implementsInstanceImageDisplay || flags.implementsImageDisplay) {
230234
// Capture drawParameters from delegate on main thread
231235
id drawParameters = [self drawParameters];
232236

@@ -242,7 +246,7 @@ - (asyncdisplaykit_async_transaction_operation_block_t)_displayBlockWithAsynchro
242246
UIImage *result = nil;
243247
//We can't call _willDisplayNodeContentWithRenderingContext or _didDisplayNodeContentWithRenderingContext because we don't
244248
//have a context. We rely on implementors of displayWithParameters:isCancelled: to call
245-
if (_flags.implementsInstanceImageDisplay) {
249+
if (flags.implementsInstanceImageDisplay) {
246250
result = [self displayWithParameters:drawParameters isCancelled:isCancelledBlock];
247251
} else {
248252
result = [[self class] displayWithParameters:drawParameters isCancelled:isCancelledBlock];
@@ -251,7 +255,7 @@ - (asyncdisplaykit_async_transaction_operation_block_t)_displayBlockWithAsynchro
251255
return result;
252256
};
253257

254-
} else if (_flags.implementsInstanceDrawRect || _flags.implementsDrawRect) {
258+
} else if (flags.implementsInstanceDrawRect || flags.implementsDrawRect) {
255259

256260
CGRect bounds = self.bounds;
257261
if (CGRectIsEmpty(bounds)) {
@@ -281,7 +285,7 @@ - (asyncdisplaykit_async_transaction_operation_block_t)_displayBlockWithAsynchro
281285
_willDisplayNodeContentWithRenderingContext(currentContext);
282286
}
283287

284-
if (_flags.implementsInstanceDrawRect) {
288+
if (flags.implementsInstanceDrawRect) {
285289
[self drawRect:bounds withParameters:drawParameters isCancelled:isCancelledBlock isRasterizing:rasterizing];
286290
} else {
287291
[[self class] drawRect:bounds withParameters:drawParameters isCancelled:isCancelledBlock isRasterizing:rasterizing];

0 commit comments

Comments
 (0)