diff --git a/ReactCommon/fabric/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/fabric/animations/LayoutAnimationKeyFrameManager.cpp index 77b589a8696..91b73f5bdae 100644 --- a/ReactCommon/fabric/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/fabric/animations/LayoutAnimationKeyFrameManager.cpp @@ -311,6 +311,10 @@ void LayoutAnimationKeyFrameManager::adjustDelayedMutationIndicesForMutation( bool isInsertMutation = mutation.type == ShadowViewMutation::Type::Insert; assert(isRemoveMutation || isInsertMutation); + if (mutatedViewIsVirtual(mutation)) { + return; + } + for (auto &inflightAnimation : inflightAnimations_) { if (inflightAnimation.surfaceId != surfaceId) { continue; @@ -691,7 +695,8 @@ LayoutAnimationKeyFrameManager::pullTransaction( for (const auto &otherMutation : mutations) { if (otherMutation.type == ShadowViewMutation::Type::Insert && otherMutation.parentShadowView.tag == parentTag) { - if (otherMutation.index <= adjustedIndex) { + if (otherMutation.index <= adjustedIndex && + !mutatedViewIsVirtual(otherMutation)) { adjustedIndex++; } } @@ -861,6 +866,22 @@ LayoutAnimationKeyFrameManager::pullTransaction( surfaceId, transactionNumber, std::move(mutations), {}}; } +bool LayoutAnimationKeyFrameManager::mutatedViewIsVirtual( + ShadowViewMutation const &mutation) const { + bool viewIsVirtual = false; + + // TODO: extract this into an Android platform-specific class + // Explanation: for "Insert" mutations, oldChildShadowView is always empty. + // for "Remove" mutations, newChildShadowView is always empty. +#ifdef ANDROID + viewIsVirtual = + mutation.newChildShadowView.layoutMetrics == EmptyLayoutMetrics && + mutation.oldChildShadowView.layoutMetrics == EmptyLayoutMetrics; +#endif + + return viewIsVirtual; +} + ComponentDescriptor const & LayoutAnimationKeyFrameManager::getComponentDescriptorForShadowView( ShadowView const &shadowView) const { diff --git a/ReactCommon/fabric/animations/LayoutAnimationKeyFrameManager.h b/ReactCommon/fabric/animations/LayoutAnimationKeyFrameManager.h index 7f2bb952219..444e310c454 100644 --- a/ReactCommon/fabric/animations/LayoutAnimationKeyFrameManager.h +++ b/ReactCommon/fabric/animations/LayoutAnimationKeyFrameManager.h @@ -144,6 +144,8 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate, ShadowViewMutation const &mutation) const; protected: + bool mutatedViewIsVirtual(ShadowViewMutation const &mutation) const; + ComponentDescriptor const &getComponentDescriptorForShadowView( ShadowView const &shadowView) const; std::pair calculateAnimationProgress(