diff --git a/React/Fabric/RCTScheduler.mm b/React/Fabric/RCTScheduler.mm index 70eca70fa8a..ffdf94bb3af 100644 --- a/React/Fabric/RCTScheduler.mm +++ b/React/Fabric/RCTScheduler.mm @@ -124,6 +124,9 @@ class LayoutAnimationDelegateProxy : public LayoutAnimationStatusDelegate, publi _layoutAnimationDelegateProxy = std::make_shared((__bridge void *)self); _animationDriver = std::make_shared(toolbox.runtimeExecutor, _layoutAnimationDelegateProxy.get()); + if (reactNativeConfig->getBool("react_fabric:enabled_skip_invalidated_key_frames_ios")) { + _animationDriver->enableSkipInvalidatedKeyFrames(); + } _uiRunLoopObserver = toolbox.mainRunLoopObserverFactory(RunLoopObserver::Activity::BeforeWaiting, _layoutAnimationDelegateProxy); _uiRunLoopObserver->setDelegate(_layoutAnimationDelegateProxy.get()); diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index 67758c2ede3..ca16b6a9c93 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -1313,6 +1313,10 @@ void LayoutAnimationKeyFrameManager::setClockNow( now_ = now; } +void LayoutAnimationKeyFrameManager::enableSkipInvalidatedKeyFrames() { + skipInvalidatedKeyFrames_ = true; +} + #pragma mark - Protected bool LayoutAnimationKeyFrameManager::hasComponentDescriptorForShadowView( @@ -1471,6 +1475,9 @@ void LayoutAnimationKeyFrameManager::queueFinalMutationsForCompletedKeyFrame( ShadowViewMutation::List &mutationsList, bool interrupted, std::string logPrefix) const { + if (skipInvalidatedKeyFrames_ && keyframe.invalidated) { + return; + } if (keyframe.finalMutationsForKeyFrame.size() > 0) { // TODO: modularize this segment, it is repeated 2x in KeyFrameManager // as well. diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h index 603fd7482c4..37d4cd6c674 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h @@ -86,6 +86,8 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate, void setClockNow(std::function now); + void enableSkipInvalidatedKeyFrames(); + protected: SharedComponentDescriptorRegistry componentDescriptorRegistry_; mutable better::optional currentAnimation_{}; @@ -144,6 +146,7 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate, mutable LayoutAnimationStatusDelegate *layoutAnimationStatusDelegate_{}; mutable std::mutex surfaceIdsToStopMutex_; mutable better::set surfaceIdsToStop_{}; + bool skipInvalidatedKeyFrames_{false}; // Function that returns current time in milliseconds std::function now_;