mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add option to skip invalidated key frames
Summary: changelog: [internal] Maybe invalid keyframe animation shouldn't be queued. This adds a fix behind feature flag to verify if it fixes iOS crashes. Reviewed By: RSNara Differential Revision: D30730005 fbshipit-source-id: 8a2bb54c449449a95d14d51a1a78bfaccad61877
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f22e6033d9
commit
ae4068d63c
@@ -124,6 +124,9 @@ class LayoutAnimationDelegateProxy : public LayoutAnimationStatusDelegate, publi
|
||||
_layoutAnimationDelegateProxy = std::make_shared<LayoutAnimationDelegateProxy>((__bridge void *)self);
|
||||
_animationDriver =
|
||||
std::make_shared<LayoutAnimationDriver>(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());
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -86,6 +86,8 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate,
|
||||
|
||||
void setClockNow(std::function<uint64_t()> now);
|
||||
|
||||
void enableSkipInvalidatedKeyFrames();
|
||||
|
||||
protected:
|
||||
SharedComponentDescriptorRegistry componentDescriptorRegistry_;
|
||||
mutable better::optional<LayoutAnimation> currentAnimation_{};
|
||||
@@ -144,6 +146,7 @@ class LayoutAnimationKeyFrameManager : public UIManagerAnimationDelegate,
|
||||
mutable LayoutAnimationStatusDelegate *layoutAnimationStatusDelegate_{};
|
||||
mutable std::mutex surfaceIdsToStopMutex_;
|
||||
mutable better::set<SurfaceId> surfaceIdsToStop_{};
|
||||
bool skipInvalidatedKeyFrames_{false};
|
||||
|
||||
// Function that returns current time in milliseconds
|
||||
std::function<uint64_t()> now_;
|
||||
|
||||
Reference in New Issue
Block a user