diff --git a/CHANGELOG.md b/CHANGELOG.md index 452f4dcc5..05b80eff0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ - Improve TextNode2 by skipping an unneeded copy during measurement. [Adlai Holler](https://github.com/Adlai-Holler) - Improve locking around clearContents [Michael Schneider](https://github.com/maicki) - Unlock before cleanup and calling out to subclass hooks for animated images. [Michael Schneider](https://github.com/maicki) [#1087](https://github.com/TextureGroup/Texture/pull/1087) +- [ASDisplayNode] Fix interface state update for layer backed nodes when layer thrashes (interface coaleascing case).[Max Wang](https://github.com/wsdwsd0829). [#1111](https://github.com/TextureGroup/Texture/pull/1111) ## 2.7 - Fix pager node for interface coalescing. [Max Wang](https://github.com/wsdwsd0829) [#877](https://github.com/TextureGroup/Texture/pull/877) diff --git a/Source/ASDisplayNode.mm b/Source/ASDisplayNode.mm index d84b5cbe0..12fca50fa 100644 --- a/Source/ASDisplayNode.mm +++ b/Source/ASDisplayNode.mm @@ -2947,6 +2947,15 @@ - (void)willEnterHierarchy if (![self supportsRangeManagedInterfaceState]) { self.interfaceState = ASInterfaceStateInHierarchy; + } else if (ASCATransactionQueue.sharedQueue.isEnabled) { + __instanceLock__.lock(); + ASInterfaceState state = _preExitingInterfaceState; + _preExitingInterfaceState = ASInterfaceStateNone; + __instanceLock__.unlock(); + // Layer thrash happened, revert to before exiting. + if (state != ASInterfaceStateNone) { + self.interfaceState = state; + } } } @@ -2985,6 +2994,8 @@ - (void)didExitHierarchy unsigned isStillInHierarchy = _flags.isInHierarchy; BOOL isVisible = ASInterfaceStateIncludesVisible(_pendingInterfaceState); ASInterfaceState newState = (_pendingInterfaceState & ~ASInterfaceStateVisible); + // layer may be thrashed, we need to remember the state so we can reset if it enters in same runloop later. + _preExitingInterfaceState = _pendingInterfaceState; __instanceLock__.unlock(); if (!isStillInHierarchy && isVisible) { #if ENABLE_NEW_EXIT_HIERARCHY_BEHAVIOR @@ -3102,6 +3113,7 @@ - (void)applyPendingInterfaceState:(ASInterfaceState)newPendingState return; } _interfaceState = newState; + _preExitingInterfaceState = ASInterfaceStateNone; } // It should never be possible for a node to be visible but not be allowed / expected to display. diff --git a/Source/Private/ASDisplayNodeInternal.h b/Source/Private/ASDisplayNodeInternal.h index 18eb03c5c..dc3dedf81 100644 --- a/Source/Private/ASDisplayNodeInternal.h +++ b/Source/Private/ASDisplayNodeInternal.h @@ -83,6 +83,8 @@ AS_EXTERN NSString * const ASRenderingEngineDidDisplayNodesScheduledBeforeTimest _ASPendingState *_pendingViewState; ASInterfaceState _pendingInterfaceState; + ASInterfaceState _preExitingInterfaceState; + UIView *_view; CALayer *_layer;