From b7fed2f9aab8dd445595e8c79e2a93c6f3402dd3 Mon Sep 17 00:00:00 2001 From: Huy Nguyen Date: Fri, 19 Apr 2019 23:22:53 -0700 Subject: [PATCH] Disable ASAssertLocked and ASAssertUnlocked (#1412) --- Source/ASDisplayNode+Layout.mm | 27 ++++--- Source/ASDisplayNode+LayoutSpec.mm | 2 +- Source/ASDisplayNode.mm | 83 ++++++++++---------- Source/ASImageNode+AnimatedImage.mm | 14 ++-- Source/ASImageNode.mm | 2 +- Source/ASMultiplexImageNode.mm | 6 +- Source/ASNetworkImageNode.mm | 8 +- Source/ASTextNode.mm | 10 +-- Source/ASTextNode2.mm | 4 +- Source/ASVideoPlayerNode.mm | 12 +-- Source/Details/ASThread.h | 4 +- Source/Private/ASDisplayNode+UIViewBridge.mm | 2 +- 12 files changed, 86 insertions(+), 88 deletions(-) diff --git a/Source/ASDisplayNode+Layout.mm b/Source/ASDisplayNode+Layout.mm index 728df9429..bec21bf56 100644 --- a/Source/ASDisplayNode+Layout.mm +++ b/Source/ASDisplayNode+Layout.mm @@ -40,6 +40,7 @@ - (ASLayoutElementStyle *)style - (ASLayoutElementStyle *)_locked_style { + DISABLED_ASAssertLocked(__instanceLock__); if (_style == nil) { _style = [[ASLayoutElementStyle alloc] init]; } @@ -182,7 +183,7 @@ - (ASSizeRange)constrainedSizeForCalculatedLayout - (ASSizeRange)_locked_constrainedSizeForCalculatedLayout { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); if (_pendingDisplayNodeLayout.isValid(_layoutVersion)) { return _pendingDisplayNodeLayout.constrainedSize; } @@ -218,7 +219,7 @@ @implementation ASDisplayNode (ASLayoutInternal) - (void)_u_setNeedsLayoutFromAbove { ASDisplayNodeAssertThreadAffinity(self); - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); as_activity_create_for_scope("Set needs layout from above"); @@ -243,7 +244,7 @@ - (void)_u_setNeedsLayoutFromAbove - (void)_rootNodeDidInvalidateSize { ASDisplayNodeAssertThreadAffinity(self); - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); __instanceLock__.lock(); @@ -273,7 +274,7 @@ - (void)_rootNodeDidInvalidateSize - (void)displayNodeDidInvalidateSizeNewSize:(CGSize)size { ASDisplayNodeAssertThreadAffinity(self); - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); // The default implementation of display node changes the size of itself to the new size CGRect oldBounds = self.bounds; @@ -295,8 +296,8 @@ - (void)displayNodeDidInvalidateSizeNewSize:(CGSize)size - (void)_u_measureNodeWithBoundsIfNecessary:(CGRect)bounds { - ASAssertUnlocked(__instanceLock__); - + DISABLED_ASAssertUnlocked(__instanceLock__); + ASDN::MutexLocker l(__instanceLock__); // Check if we are a subnode in a layout transition. // In this case no measurement is needed as it's part of the layout transition @@ -429,7 +430,7 @@ - (ASSizeRange)_locked_constrainedSizeForLayoutPass // logic seems correct. For what case does -this method need to do the CGSizeEqual checks? // IF WE CAN REMOVE BOUNDS CHECKS HERE, THEN WE CAN ALSO REMOVE "REQUESTED FROM ABOVE" CHECK - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); CGSize boundsSizeForLayout = ASCeilSizeValues(self.threadSafeBounds.size); @@ -455,8 +456,8 @@ - (ASSizeRange)_locked_constrainedSizeForLayoutPass - (void)_layoutSublayouts { ASDisplayNodeAssertThreadAffinity(self); - ASAssertUnlocked(__instanceLock__); - + DISABLED_ASAssertUnlocked(__instanceLock__); + ASLayout *layout; { ASDN::MutexLocker l(__instanceLock__); @@ -514,7 +515,7 @@ - (BOOL)_isLayoutTransitionInvalid - (BOOL)_locked_isLayoutTransitionInvalid { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); if (ASHierarchyStateIncludesLayoutPending(_hierarchyState)) { ASLayoutElementContext *context = ASLayoutElementGetCurrentContext(); if (context == nil || _pendingTransitionID != context.transitionID) { @@ -895,7 +896,7 @@ - (void)_completeLayoutTransition:(ASLayoutTransition *)layoutTransition if (ASDisplayNodeThreadIsMain() || layoutTransition.isSynchronous == NO) { // Committing the layout transition will result in subnode insertions and removals, both of which must be called without the lock held // TODO: Disabled due to PR: https://github.com/TextureGroup/Texture/pull/1204 - // ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); [layoutTransition commitTransition]; } else { // Subnode insertions and removals need to happen always on the main thread if at least one subnode is already loaded @@ -956,7 +957,7 @@ - (void)_pendingLayoutTransitionDidComplete // Subclass hook // TODO: Disabled due to PR: https://github.com/TextureGroup/Texture/pull/1204 - // ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); [self calculatedLayoutDidChange]; // Grab lock after calling out to subclass @@ -1000,7 +1001,7 @@ - (void)_setCalculatedDisplayNodeLayout:(const ASDisplayNodeLayout &)displayNode - (void)_locked_setCalculatedDisplayNodeLayout:(const ASDisplayNodeLayout &)displayNodeLayout { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); ASDisplayNodeAssertTrue(displayNodeLayout.layout.layoutElement == self); ASDisplayNodeAssertTrue(displayNodeLayout.layout.size.width >= 0.0); ASDisplayNodeAssertTrue(displayNodeLayout.layout.size.height >= 0.0); diff --git a/Source/ASDisplayNode+LayoutSpec.mm b/Source/ASDisplayNode+LayoutSpec.mm index b4ecb2e55..0fb30605e 100644 --- a/Source/ASDisplayNode+LayoutSpec.mm +++ b/Source/ASDisplayNode+LayoutSpec.mm @@ -117,7 +117,7 @@ - (ASLayout *)calculateLayoutLayoutSpec:(ASSizeRange)constrainedSize - (id)_locked_layoutElementThatFits:(ASSizeRange)constrainedSize { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); BOOL measureLayoutSpec = _measurementOptions & ASDisplayNodePerformanceMeasurementOptionLayoutSpec; diff --git a/Source/ASDisplayNode.mm b/Source/ASDisplayNode.mm index 7c93140fe..6055884e1 100644 --- a/Source/ASDisplayNode.mm +++ b/Source/ASDisplayNode.mm @@ -459,13 +459,13 @@ - (void)dealloc - (BOOL)_locked_shouldLoadViewOrLayer { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); return !_flags.isDeallocating && !(_hierarchyState & ASHierarchyStateRasterized); } - (UIView *)_locked_viewToLoad { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); UIView *view = nil; if (_viewBlock) { @@ -505,7 +505,7 @@ - (UIView *)_locked_viewToLoad - (CALayer *)_locked_layerToLoad { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); ASDisplayNodeAssert(_flags.layerBacked, @"_layerToLoad is only for layer-backed nodes"); CALayer *layer = nil; @@ -524,7 +524,7 @@ - (CALayer *)_locked_layerToLoad - (void)_locked_loadViewOrLayer { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); if (_flags.layerBacked) { TIME_SCOPED(_debugTimeToCreateView); @@ -554,7 +554,7 @@ - (void)_locked_loadViewOrLayer - (void)_didLoad { ASDisplayNodeAssertMainThread(); - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); ASDisplayNodeLogEvent(self, @"didLoad"); as_log_verbose(ASNodeLog(), "didLoad %@", self); TIME_SCOPED(_debugTimeForDidLoad); @@ -594,7 +594,7 @@ - (BOOL)isNodeLoaded - (BOOL)_locked_isNodeLoaded { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); return _loaded(self); } @@ -695,7 +695,7 @@ - (_ASDisplayLayer *)asyncLayer - (_ASDisplayLayer *)_locked_asyncLayer { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); return [_layer isKindOfClass:[_ASDisplayLayer class]] ? (_ASDisplayLayer *)_layer : nil; } @@ -754,7 +754,7 @@ - (CGRect)threadSafeBounds - (CGRect)_locked_threadSafeBounds { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); return _threadSafeBounds; } @@ -1018,8 +1018,8 @@ - (void)invalidateCalculatedLayout - (void)__layout { ASDisplayNodeAssertThreadAffinity(self); - ASAssertUnlocked(__instanceLock__); - + DISABLED_ASAssertUnlocked(__instanceLock__); + BOOL loaded = NO; { ASDN::UniqueLock l(__instanceLock__); @@ -1069,7 +1069,7 @@ - (void)layoutDidFinish { // Hook for subclasses ASDisplayNodeAssertMainThread(); - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); ASDisplayNodeAssertTrue(self.isNodeLoaded); } @@ -1141,7 +1141,7 @@ - (void)layout { // Hook for subclasses ASDisplayNodeAssertMainThread(); - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); ASDisplayNodeAssertTrue(self.isNodeLoaded); [self enumerateInterfaceStateDelegates:^(id del) { [del nodeDidLayout]; @@ -1193,7 +1193,7 @@ - (BOOL)displaysAsynchronously */ - (BOOL)_locked_displaysAsynchronously { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); return checkFlag(Synchronous) == NO && _flags.displaysAsynchronously; } @@ -2090,7 +2090,7 @@ - (void)_insertSubnode:(ASDisplayNode *)subnode atSubnodeIndex:(NSInteger)subnod { ASDisplayNodeAssertThreadAffinity(self); // TODO: Disabled due to PR: https://github.com/TextureGroup/Texture/pull/1204 - // ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); as_log_verbose(ASNodeLog(), "Insert subnode %@ at index %zd of %@ and remove subnode %@", subnode, subnodeIndex, self, oldSubnode); @@ -2300,7 +2300,7 @@ - (void)_insertSubnode:(ASDisplayNode *)subnode belowSubnode:(ASDisplayNode *)be { ASDisplayNodeAssertThreadAffinity(self); // TODO: Disabled due to PR: https://github.com/TextureGroup/Texture/pull/1204 - // ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); if (subnode == nil) { ASDisplayNodeFailAssert(@"Cannot insert a nil subnode"); @@ -2365,7 +2365,7 @@ - (void)_insertSubnode:(ASDisplayNode *)subnode aboveSubnode:(ASDisplayNode *)ab { ASDisplayNodeAssertThreadAffinity(self); // TODO: Disabled due to PR: https://github.com/TextureGroup/Texture/pull/1204 - // ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); if (subnode == nil) { ASDisplayNodeFailAssert(@"Cannot insert a nil subnode"); @@ -2428,7 +2428,7 @@ - (void)_insertSubnode:(ASDisplayNode *)subnode atIndex:(NSInteger)idx { ASDisplayNodeAssertThreadAffinity(self); // TODO: Disabled due to PR: https://github.com/TextureGroup/Texture/pull/1204 - // ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); if (subnode == nil) { ASDisplayNodeFailAssert(@"Cannot insert a nil subnode"); @@ -2466,7 +2466,7 @@ - (void)_removeSubnode:(ASDisplayNode *)subnode { ASDisplayNodeAssertThreadAffinity(self); // TODO: Disabled due to PR: https://github.com/TextureGroup/Texture/pull/1204 - // ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); // Don't call self.supernode here because that will retain/autorelease the supernode. This method -_removeSupernode: is often called while tearing down a node hierarchy, and the supernode in question might be in the middle of its -dealloc. The supernode is never messaged, only compared by value, so this is safe. // The particular issue that triggers this edge case is when a node calls -removeFromSupernode on a subnode from within its own -dealloc method. @@ -2493,7 +2493,7 @@ - (void)_removeFromSupernode { ASDisplayNodeAssertThreadAffinity(self); // TODO: Disabled due to PR: https://github.com/TextureGroup/Texture/pull/1204 - // ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); __instanceLock__.lock(); __weak ASDisplayNode *supernode = _supernode; @@ -2508,7 +2508,7 @@ - (void)_removeFromSupernodeIfEqualTo:(ASDisplayNode *)supernode { ASDisplayNodeAssertThreadAffinity(self); // TODO: Disabled due to PR: https://github.com/TextureGroup/Texture/pull/1204 - // ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); __instanceLock__.lock(); @@ -2601,7 +2601,7 @@ - (void)__decrementVisibilityNotificationsDisabled - (void)_locked_layoutPlaceholderIfNecessary { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); if ([self _locked_shouldHavePlaceholderLayer]) { [self _locked_setupPlaceholderLayerIfNeeded]; } @@ -2611,14 +2611,14 @@ - (void)_locked_layoutPlaceholderIfNecessary - (BOOL)_locked_shouldHavePlaceholderLayer { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); return (_placeholderEnabled && [self _implementsDisplay]); } - (void)_locked_setupPlaceholderLayerIfNeeded { ASDisplayNodeAssertMainThread(); - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); if (!_placeholderLayer) { _placeholderLayer = [CALayer layer]; @@ -2666,7 +2666,7 @@ - (void)__enterHierarchy { ASDisplayNodeAssertMainThread(); ASDisplayNodeAssert(!_flags.isEnteringHierarchy, @"Should not cause recursive __enterHierarchy"); - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); ASDisplayNodeLogEvent(self, @"enterHierarchy"); // Profiling has shown that locking this method is beneficial, so each of the property accesses don't have to lock and unlock. @@ -2715,7 +2715,7 @@ - (void)__exitHierarchy { ASDisplayNodeAssertMainThread(); ASDisplayNodeAssert(!_flags.isExitingHierarchy, @"Should not cause recursive __exitHierarchy"); - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); ASDisplayNodeLogEvent(self, @"exitHierarchy"); // Profiling has shown that locking this method is beneficial, so each of the property accesses don't have to lock and unlock. @@ -2820,7 +2820,7 @@ - (void)willEnterHierarchy ASDisplayNodeAssertMainThread(); ASDisplayNodeAssert(_flags.isEnteringHierarchy, @"You should never call -willEnterHierarchy directly. Appearance is automatically managed by ASDisplayNode"); ASDisplayNodeAssert(!_flags.isExitingHierarchy, @"ASDisplayNode inconsistency. __enterHierarchy and __exitHierarchy are mutually exclusive"); - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); if (![self supportsRangeManagedInterfaceState]) { self.interfaceState = ASInterfaceStateInHierarchy; @@ -2841,7 +2841,7 @@ - (void)didEnterHierarchy { ASDisplayNodeAssert(!_flags.isEnteringHierarchy, @"You should never call -didEnterHierarchy directly. Appearance is automatically managed by ASDisplayNode"); ASDisplayNodeAssert(!_flags.isExitingHierarchy, @"ASDisplayNode inconsistency. __enterHierarchy and __exitHierarchy are mutually exclusive"); ASDisplayNodeAssert(_flags.isInHierarchy, @"ASDisplayNode inconsistency. __enterHierarchy and __exitHierarchy are mutually exclusive"); - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); } - (void)didExitHierarchy @@ -2849,7 +2849,7 @@ - (void)didExitHierarchy ASDisplayNodeAssertMainThread(); ASDisplayNodeAssert(_flags.isExitingHierarchy, @"You should never call -didExitHierarchy directly. Appearance is automatically managed by ASDisplayNode"); ASDisplayNodeAssert(!_flags.isEnteringHierarchy, @"ASDisplayNode inconsistency. __enterHierarchy and __exitHierarchy are mutually exclusive"); - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); // This case is important when tearing down hierarchies. We must deliver a visibileStateDidChange:NO callback, as part our API guarantee that this method can be used for // things like data analytics about user content viewing. We cannot call the method in the dealloc as any incidental retain operations in client code would fail. @@ -2973,7 +2973,7 @@ - (void)applyPendingInterfaceState:(ASInterfaceState)newPendingState ASDisplayNodeAssertMainThread(); // This method manages __instanceLock__ itself, to ensure the lock is not held while didEnter/Exit(.*)State methods are called, thus avoid potential deadlocks - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); ASInterfaceState oldState = ASInterfaceStateNone; ASInterfaceState newState = ASInterfaceStateNone; @@ -3104,8 +3104,7 @@ - (void)prepareForCATransactionCommit - (void)interfaceStateDidChange:(ASInterfaceState)newState fromState:(ASInterfaceState)oldState { - // Subclass hook - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); ASDisplayNodeAssertMainThread(); [self enumerateInterfaceStateDelegates:^(id del) { [del interfaceStateDidChange:newState fromState:oldState]; @@ -3161,7 +3160,7 @@ - (void)didEnterVisibleState } #endif - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); [self enumerateInterfaceStateDelegates:^(id del) { [del didEnterVisibleState]; }]; @@ -3175,7 +3174,7 @@ - (void)didExitVisibleState { // subclass override ASDisplayNodeAssertMainThread(); - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); [self enumerateInterfaceStateDelegates:^(id del) { [del didExitVisibleState]; }]; @@ -3191,7 +3190,7 @@ - (void)didEnterDisplayState { // subclass override ASDisplayNodeAssertMainThread(); - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); [self enumerateInterfaceStateDelegates:^(id del) { [del didEnterDisplayState]; }]; @@ -3201,7 +3200,7 @@ - (void)didExitDisplayState { // subclass override ASDisplayNodeAssertMainThread(); - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); [self enumerateInterfaceStateDelegates:^(id del) { [del didExitDisplayState]; }]; @@ -3241,7 +3240,7 @@ - (void)recursivelyClearPreloadedData - (void)didEnterPreloadState { ASDisplayNodeAssertMainThread(); - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); // If this node has ASM enabled and is not yet visible, force a layout pass to apply its applicable pending layout, if any, // so that its subnodes are inserted/deleted and start preloading right away. @@ -3263,7 +3262,7 @@ - (void)didEnterPreloadState - (void)didExitPreloadState { ASDisplayNodeAssertMainThread(); - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); [self enumerateInterfaceStateDelegates:^(id del) { [del didExitPreloadState]; }]; @@ -3272,7 +3271,7 @@ - (void)didExitPreloadState - (void)clearContents { ASDisplayNodeAssertMainThread(); - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); ASDN::MutexLocker l(__instanceLock__); if (_flags.canClearContentsOfLayer) { @@ -3295,7 +3294,7 @@ - (void)recursivelyClearContents - (void)enumerateInterfaceStateDelegates:(void (NS_NOESCAPE ^)(id))block { - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); id dels[AS_MAX_INTERFACE_STATE_DELEGATES]; int count = 0; @@ -3391,7 +3390,7 @@ - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event - (void)_locked_applyPendingStateToViewOrLayer { ASDisplayNodeAssertMainThread(); - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); ASDisplayNodeAssert(self.nodeLoaded, @"must have a view or layer"); TIME_SCOPED(_debugTimeToApplyPendingState); @@ -3411,7 +3410,7 @@ - (void)_locked_applyPendingStateToViewOrLayer - (void)applyPendingViewState { ASDisplayNodeAssertMainThread(); - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); ASDN::UniqueLock l(__instanceLock__); // FIXME: Ideally we'd call this as soon as the node receives -setNeedsLayout @@ -3430,7 +3429,7 @@ - (void)applyPendingViewState - (void)_locked_applyPendingViewState { ASDisplayNodeAssertMainThread(); - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); ASDisplayNodeAssert([self _locked_isNodeLoaded], @"Expected node to be loaded before applying pending state."); if (_flags.layerBacked) { diff --git a/Source/ASImageNode+AnimatedImage.mm b/Source/ASImageNode+AnimatedImage.mm index 99ecf82d5..df8be0830 100644 --- a/Source/ASImageNode+AnimatedImage.mm +++ b/Source/ASImageNode+AnimatedImage.mm @@ -42,7 +42,7 @@ - (void)setAnimatedImage:(id )animatedImage - (void)_locked_setAnimatedImage:(id )animatedImage { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); if (ASObjectIsEqual(_animatedImage, animatedImage) && (animatedImage == nil || animatedImage.playbackReady)) { return; @@ -95,7 +95,7 @@ - (void)_locked_setAnimatedImage:(id )animatedImage - (void)animatedImageSet:(id )newAnimatedImage previousAnimatedImage:(id )previousAnimatedImage { // Subclass hook should not be called with the lock held - ASAssertUnlocked(__instanceLock__); + DISABLED_ASAssertUnlocked(__instanceLock__); // Subclasses may override } @@ -131,7 +131,7 @@ - (void)setCoverImageCompleted:(UIImage *)coverImage - (void)_locked_setCoverImageCompleted:(UIImage *)coverImage { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); _displayLinkLock.lock(); BOOL setCoverImage = (_displayLink == nil) || _displayLink.paused; @@ -150,7 +150,7 @@ - (void)setCoverImage:(UIImage *)coverImage - (void)_locked_setCoverImage:(UIImage *)coverImage { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); //If we're a network image node, we want to set the default image so //that it will correctly be restored if it exits the range. @@ -193,7 +193,7 @@ - (void)setShouldAnimate:(BOOL)shouldAnimate - (void)_locked_setShouldAnimate:(BOOL)shouldAnimate { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); // This test is explicitly done and not ASPerformBlockOnMainThread as this would perform the block immediately // on main if called on main thread and we have to call methods locked or unlocked based on which thread we are on @@ -228,7 +228,7 @@ - (void)startAnimating - (void)_locked_startAnimating { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); // It should be safe to call self.interfaceState in this case as it will only grab the lock of the superclass if (!ASInterfaceStateIncludesVisible(self.interfaceState)) { @@ -273,7 +273,7 @@ - (void)stopAnimating - (void)_locked_stopAnimating { ASDisplayNodeAssertMainThread(); - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); #if ASAnimatedImageDebug NSLog(@"stopping animation: %p", self); diff --git a/Source/ASImageNode.mm b/Source/ASImageNode.mm index ce473e3e7..259d8b9b1 100644 --- a/Source/ASImageNode.mm +++ b/Source/ASImageNode.mm @@ -235,7 +235,7 @@ - (void)setImage:(UIImage *)image - (void)_locked_setImage:(UIImage *)image { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); if (ASObjectIsEqual(_image, image)) { return; } diff --git a/Source/ASMultiplexImageNode.mm b/Source/ASMultiplexImageNode.mm index 2adc646f9..3af8e5f0e 100644 --- a/Source/ASMultiplexImageNode.mm +++ b/Source/ASMultiplexImageNode.mm @@ -493,12 +493,10 @@ - (UIImage *)_bestImmediatelyAvailableImageFromDataSource:(id *)imageIdentifierO #pragma mark - -/** - @note: This should be called without _downloadIdentifierLock held. We will lock - super to read our interface state and it's best to avoid acquiring both locks. - */ - (void)_updateProgressImageBlockOnDownloaderIfNeeded { + DISABLED_ASAssertUnlocked(_downloadIdentifierLock); + BOOL shouldRenderProgressImages = self.shouldRenderProgressImages; // Read our interface state before locking so that we don't lock super while holding our lock. diff --git a/Source/ASNetworkImageNode.mm b/Source/ASNetworkImageNode.mm index 0a0245dbe..e7a134b1e 100644 --- a/Source/ASNetworkImageNode.mm +++ b/Source/ASNetworkImageNode.mm @@ -148,7 +148,7 @@ - (void)setImage:(UIImage *)image - (void)_locked_setImage:(UIImage *)image { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); BOOL imageWasSetExternally = (image != nil); BOOL shouldCancelAndClear = imageWasSetExternally && (imageWasSetExternally != _imageWasSetExternally); @@ -176,7 +176,7 @@ - (void)_setImage:(UIImage *)image - (void)_locked__setImage:(UIImage *)image { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); [super _locked_setImage:image]; } @@ -532,7 +532,7 @@ - (void)_cancelDownloadAndClearImageWithResumePossibility:(BOOL)storeResume - (void)_locked_cancelDownloadAndClearImageWithResumePossibility:(BOOL)storeResume { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); [self _locked_cancelImageDownloadWithResumePossibility:storeResume]; @@ -558,7 +558,7 @@ - (void)_cancelImageDownloadWithResumePossibility:(BOOL)storeResume - (void)_locked_cancelImageDownloadWithResumePossibility:(BOOL)storeResume { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); if (!_downloadIdentifier) { return; diff --git a/Source/ASTextNode.mm b/Source/ASTextNode.mm index 7ce9c8322..4602cceb5 100644 --- a/Source/ASTextNode.mm +++ b/Source/ASTextNode.mm @@ -346,20 +346,20 @@ - (ASTextKitRenderer *)_rendererWithBounds:(CGRect)bounds - (ASTextKitRenderer *)_locked_renderer { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); return [self _locked_rendererWithBounds:[self _locked_threadSafeBounds]]; } - (ASTextKitRenderer *)_locked_rendererWithBounds:(CGRect)bounds { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); bounds = UIEdgeInsetsInsetRect(bounds, _textContainerInset); return rendererForAttributes([self _locked_rendererAttributes], bounds.size); } - (ASTextKitAttributes)_locked_rendererAttributes { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); return { .attributedString = _attributedText, .truncationAttributedString = [self _locked_composedTruncationText], @@ -1302,7 +1302,7 @@ - (NSRange)_additionalTruncationMessageRangeWithVisibleRange:(NSRange)visibleRan */ - (NSAttributedString *)_locked_composedTruncationText { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); if (_composedTruncationText == nil) { if (_truncationAttributedText != nil && _additionalTruncationMessage != nil) { NSMutableAttributedString *newComposedTruncationString = [[NSMutableAttributedString alloc] initWithAttributedString:_truncationAttributedText]; @@ -1328,7 +1328,7 @@ - (NSAttributedString *)_locked_composedTruncationText */ - (NSAttributedString *)_locked_prepareTruncationStringForDrawing:(NSAttributedString *)truncationString { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); truncationString = ASCleanseAttributedStringOfCoreTextAttributes(truncationString); NSMutableAttributedString *truncationMutableString = [truncationString mutableCopy]; // Grab the attributes from the full string diff --git a/Source/ASTextNode2.mm b/Source/ASTextNode2.mm index eeaae995d..46c49e6e4 100644 --- a/Source/ASTextNode2.mm +++ b/Source/ASTextNode2.mm @@ -1231,7 +1231,7 @@ - (NSRange)_additionalTruncationMessageRangeWithVisibleRange:(NSRange)visibleRan */ - (NSAttributedString *)_locked_composedTruncationText { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); if (_composedTruncationText == nil) { if (_truncationAttributedText != nil && _additionalTruncationMessage != nil) { NSMutableAttributedString *newComposedTruncationString = [[NSMutableAttributedString alloc] initWithAttributedString:_truncationAttributedText]; @@ -1257,7 +1257,7 @@ - (NSAttributedString *)_locked_composedTruncationText */ - (NSAttributedString *)_locked_prepareTruncationStringForDrawing:(NSAttributedString *)truncationString { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); NSMutableAttributedString *truncationMutableString = [truncationString mutableCopy]; // Grab the attributes from the full string if (_attributedText.length > 0) { diff --git a/Source/ASVideoPlayerNode.mm b/Source/ASVideoPlayerNode.mm index 08d86770d..f8fdc06cf 100644 --- a/Source/ASVideoPlayerNode.mm +++ b/Source/ASVideoPlayerNode.mm @@ -339,7 +339,7 @@ - (void)_locked_cleanCachedControls - (void)_locked_createPlaybackButton { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); if (_playbackButtonNode == nil) { _playbackButtonNode = [[ASDefaultPlaybackButton alloc] init]; @@ -367,7 +367,7 @@ - (void)_locked_createPlaybackButton - (void)_locked_createFullScreenButton { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); if (_fullScreenButtonNode == nil) { _fullScreenButtonNode = [[ASButtonNode alloc] init]; @@ -389,7 +389,7 @@ - (void)_locked_createFullScreenButton - (void)_locked_createElapsedTextField { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); if (_elapsedTextNode == nil) { _elapsedTextNode = [[ASTextNode alloc] init]; @@ -407,7 +407,7 @@ - (void)_locked_createElapsedTextField - (void)_locked_createDurationTextField { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); if (_durationTextNode == nil) { _durationTextNode = [[ASTextNode alloc] init]; @@ -426,7 +426,7 @@ - (void)_locked_createDurationTextField - (void)_locked_createScrubber { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); if (_scrubberNode == nil) { __weak __typeof__(self) weakSelf = self; @@ -474,7 +474,7 @@ - (void)_locked_createScrubber - (void)_locked_createControlFlexGrowSpacer { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); if (_controlFlexGrowSpacerSpec == nil) { _controlFlexGrowSpacerSpec = [[ASStackLayoutSpec alloc] init]; diff --git a/Source/Details/ASThread.h b/Source/Details/ASThread.h index d5896fd13..7b54b2aad 100644 --- a/Source/Details/ASThread.h +++ b/Source/Details/ASThread.h @@ -98,8 +98,8 @@ ASDISPLAYNODE_INLINE void _ASUnlockScopeCleanup(id __strong *lockPtr) #include // These macros are here for legacy reasons. We may get rid of them later. -#define ASAssertLocked(m) m.AssertHeld() -#define ASAssertUnlocked(m) m.AssertNotHeld() +#define DISABLED_ASAssertLocked(m) +#define DISABLED_ASAssertUnlocked(m) namespace ASDN { diff --git a/Source/Private/ASDisplayNode+UIViewBridge.mm b/Source/Private/ASDisplayNode+UIViewBridge.mm index acb821801..5107410ca 100644 --- a/Source/Private/ASDisplayNode+UIViewBridge.mm +++ b/Source/Private/ASDisplayNode+UIViewBridge.mm @@ -973,7 +973,7 @@ - (void)setLayerCornerRadius:(CGFloat)newLayerCornerRadius - (BOOL)_locked_insetsLayoutMarginsFromSafeArea { - ASAssertLocked(__instanceLock__); + DISABLED_ASAssertLocked(__instanceLock__); if (AS_AVAILABLE_IOS(11.0)) { if (!_flags.layerBacked) { return _getFromViewOnly(insetsLayoutMarginsFromSafeArea);