Skip to content

Commit 9f77d42

Browse files
zeyapfacebook-github-bot
authored andcommitted
make sure to only disable js sync & animate layout when disableFabricCommitInCXXAnimated==false (#53230)
Summary: Pull Request resolved: #53230 ## Changelog: [Internal] [Changed] - make sure to only disable js sync & animate layout when disableFabricCommitInCXXAnimated==false Reviewed By: sammy-SC Differential Revision: D80002015 fbshipit-source-id: 5e6ee4b5908fe8d2ee52b77ca3b78164debc4d59
1 parent 1c7925a commit 9f77d42

3 files changed

Lines changed: 18 additions & 16 deletions

File tree

packages/react-native/Libraries/Animated/animations/Animation.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,11 @@ export default class Animation {
150150
if (value != null) {
151151
animatedValue.__onAnimatedValueUpdateReceived(value, offset);
152152

153-
if (
154-
!(
155-
ReactNativeFeatureFlags.cxxNativeAnimatedEnabled() &&
156-
ReactNativeFeatureFlags.cxxNativeAnimatedRemoveJsSync()
157-
)
158-
) {
153+
const isJsSyncRemoved =
154+
ReactNativeFeatureFlags.cxxNativeAnimatedEnabled() &&
155+
!ReactNativeFeatureFlags.disableFabricCommitInCXXAnimated() &&
156+
ReactNativeFeatureFlags.cxxNativeAnimatedRemoveJsSync();
157+
if (!isJsSyncRemoved) {
159158
if (this.__isLooping === true) {
160159
return;
161160
}

packages/react-native/ReactCxxPlatform/react/renderer/animated/NativeAnimatedNodesManager.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,10 @@ bool NativeAnimatedNodesManager::onAnimationFrame(double timestamp) {
699699

700700
if (driver->getIsComplete()) {
701701
hasFinishedAnimations = true;
702-
if (ReactNativeFeatureFlags::cxxNativeAnimatedRemoveJsSync()) {
702+
const auto shouldRemoveJsSync =
703+
ReactNativeFeatureFlags::cxxNativeAnimatedRemoveJsSync() &&
704+
!ReactNativeFeatureFlags::disableFabricCommitInCXXAnimated();
705+
if (shouldRemoveJsSync) {
703706
finishedAnimationValueNodes.insert(driver->getAnimatedValueTag());
704707
}
705708
}
@@ -810,15 +813,17 @@ void NativeAnimatedNodesManager::schedulePropsCommit(
810813
bool forceFabricCommit) noexcept {
811814
// When fabricCommitCallback_ & directManipulationCallback_ are both
812815
// available, we commit layout props via Fabric and the other using direct
813-
// manipulation; if only one is available, we commit all props using that
816+
// manipulation. If only fabricCommitCallback_ is available, we commit all
817+
// props using that; if only directManipulationCallback_ is available, we
818+
// commit all except for layout props.
814819
if (fabricCommitCallback_ != nullptr &&
815820
(layoutStyleUpdated || forceFabricCommit ||
816821
directManipulationCallback_ == nullptr)) {
817822
mergeObjects(updateViewProps_[viewTag], props);
818823

819824
// Must call direct manipulation to set final values on components.
820825
mergeObjects(updateViewPropsDirect_[viewTag], props);
821-
} else if (directManipulationCallback_ != nullptr) {
826+
} else if (!layoutStyleUpdated && directManipulationCallback_ != nullptr) {
822827
mergeObjects(updateViewPropsDirect_[viewTag], props);
823828
{
824829
std::lock_guard<std::mutex> lock(unsyncedDirectViewPropsMutex_);

packages/react-native/src/private/animated/createAnimatedPropsHook.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,11 @@ export default function createAnimatedPropsHook(
125125
if (node.__isNative) {
126126
// Check 2: this is an animation driven by native.
127127
// In native driven animations, this callback is only called once the animation completes.
128-
if (
129-
isFabricNode &&
130-
!(
131-
ReactNativeFeatureFlags.cxxNativeAnimatedEnabled() &&
132-
ReactNativeFeatureFlags.cxxNativeAnimatedRemoveJsSync()
133-
)
134-
) {
128+
const shouldRemoveJsSync =
129+
ReactNativeFeatureFlags.cxxNativeAnimatedEnabled() &&
130+
!ReactNativeFeatureFlags.disableFabricCommitInCXXAnimated() &&
131+
ReactNativeFeatureFlags.cxxNativeAnimatedRemoveJsSync();
132+
if (isFabricNode && !shouldRemoveJsSync) {
135133
// Call `scheduleUpdate` to synchronise Fiber and Shadow tree.
136134
// Must not be called in Paper.
137135
scheduleUpdate();

0 commit comments

Comments
 (0)