#trivial Shouldn't hold the lock while adding subnodes (#1091)

* Shouldn't hold the lock while adding subnodes

* Add comments, good call @nguyenhuy
This commit is contained in:
Garrett Moon 2018-08-30 22:04:40 -07:00 committed by Huy Nguyen
parent b556b2f775
commit 1fe241df91
2 changed files with 5 additions and 1 deletions

View File

@ -295,7 +295,9 @@ CGRect _ASControlNodeGetExpandedBounds(ASControlNode *controlNode);
// only show tap-able areas for views with 1 or more addTarget:action: pairs
if ([ASControlNode enableHitTestDebug] && _debugHighlightOverlay == nil) {
ASPerformBlockOnMainThread(^{
// do not use ASPerformBlockOnMainThread here, if it performs the block synchronously it will continue
// holding the lock while calling addSubnode.
dispatch_async(dispatch_get_main_queue(), ^{
// add a highlight overlay node with area of ASControlNode + UIEdgeInsets
self.clipsToBounds = NO;
_debugHighlightOverlay = [[ASImageNode alloc] init];

View File

@ -251,6 +251,8 @@ typedef void (^ASImageNodeDrawParametersBlock)(ASWeakMapEntry *entry);
// For debugging purposes we don't care about locking for now
if ([ASImageNode shouldShowImageScalingOverlay] && _debugLabelNode == nil) {
// do not use ASPerformBlockOnMainThread here, if it performs the block synchronously it will continue
// holding the lock while calling addSubnode.
dispatch_async(dispatch_get_main_queue(), ^{
_debugLabelNode = [[ASTextNode alloc] init];
_debugLabelNode.layerBacked = YES;