Skip to content

Commit 0d13474

Browse files
sammy-SCfacebook-github-bot
authored andcommitted
provide option to fabric commits in C++ Animated (facebook#52834)
Summary: Pull Request resolved: facebook#52834 changelog: [internal] we have seen some problems with the fabric commit and believe there is a race condition in the implementation. Here, we introduce an option to disable it. Reviewed By: rozele Differential Revision: D78972655 fbshipit-source-id: 99005c77dbe4dde3816b9e6a692f170cf287f7cd
1 parent 54d5b74 commit 0d13474

21 files changed

+207
-85
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<92170b32c13dc405a81b4a5cf5677afb>>
7+
* @generated SignedSource<<b236df3f1d4b9e0a263f80018743557b>>
88
*/
99

1010
/**
@@ -48,6 +48,12 @@ public object ReactNativeFeatureFlags {
4848
@JvmStatic
4949
public fun cxxNativeAnimatedRemoveJsSync(): Boolean = accessor.cxxNativeAnimatedRemoveJsSync()
5050

51+
/**
52+
* Prevents use of Fabric commit in C++ Animated implementation
53+
*/
54+
@JvmStatic
55+
public fun disableFabricCommitInCXXAnimated(): Boolean = accessor.disableFabricCommitInCXXAnimated()
56+
5157
/**
5258
* Prevent FabricMountingManager from reordering mountItems, which may lead to invalid state on the UI thread
5359
*/

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<34c0a7def872e270cd542785d9bfde40>>
7+
* @generated SignedSource<<85d8fba6c2a5db872d20bbe89fa93f7f>>
88
*/
99

1010
/**
@@ -23,6 +23,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
2323
private var commonTestFlagCache: Boolean? = null
2424
private var cxxNativeAnimatedEnabledCache: Boolean? = null
2525
private var cxxNativeAnimatedRemoveJsSyncCache: Boolean? = null
26+
private var disableFabricCommitInCXXAnimatedCache: Boolean? = null
2627
private var disableMountItemReorderingAndroidCache: Boolean? = null
2728
private var disableOldAndroidAttachmentMetricsWorkaroundsCache: Boolean? = null
2829
private var disableTextLayoutManagerCacheAndroidCache: Boolean? = null
@@ -112,6 +113,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
112113
return cached
113114
}
114115

116+
override fun disableFabricCommitInCXXAnimated(): Boolean {
117+
var cached = disableFabricCommitInCXXAnimatedCache
118+
if (cached == null) {
119+
cached = ReactNativeFeatureFlagsCxxInterop.disableFabricCommitInCXXAnimated()
120+
disableFabricCommitInCXXAnimatedCache = cached
121+
}
122+
return cached
123+
}
124+
115125
override fun disableMountItemReorderingAndroid(): Boolean {
116126
var cached = disableMountItemReorderingAndroidCache
117127
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<3c9a5f37b4d141ffcf9a2ec152f70563>>
7+
* @generated SignedSource<<f98ae1736e9d822c68e173e1f90dc72f>>
88
*/
99

1010
/**
@@ -34,6 +34,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
3434

3535
@DoNotStrip @JvmStatic public external fun cxxNativeAnimatedRemoveJsSync(): Boolean
3636

37+
@DoNotStrip @JvmStatic public external fun disableFabricCommitInCXXAnimated(): Boolean
38+
3739
@DoNotStrip @JvmStatic public external fun disableMountItemReorderingAndroid(): Boolean
3840

3941
@DoNotStrip @JvmStatic public external fun disableOldAndroidAttachmentMetricsWorkarounds(): Boolean

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<728ae563ec31340ccc8c4c593d566c64>>
7+
* @generated SignedSource<<1221da6338bb06cd57e14b00a342b815>>
88
*/
99

1010
/**
@@ -29,6 +29,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
2929

3030
override fun cxxNativeAnimatedRemoveJsSync(): Boolean = false
3131

32+
override fun disableFabricCommitInCXXAnimated(): Boolean = false
33+
3234
override fun disableMountItemReorderingAndroid(): Boolean = false
3335

3436
override fun disableOldAndroidAttachmentMetricsWorkarounds(): Boolean = true

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<9a5b0bdc0bd9ab0889e548b25cfe5371>>
7+
* @generated SignedSource<<2c5eebdefa26052c1a20fcf55f68c931>>
88
*/
99

1010
/**
@@ -27,6 +27,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
2727
private var commonTestFlagCache: Boolean? = null
2828
private var cxxNativeAnimatedEnabledCache: Boolean? = null
2929
private var cxxNativeAnimatedRemoveJsSyncCache: Boolean? = null
30+
private var disableFabricCommitInCXXAnimatedCache: Boolean? = null
3031
private var disableMountItemReorderingAndroidCache: Boolean? = null
3132
private var disableOldAndroidAttachmentMetricsWorkaroundsCache: Boolean? = null
3233
private var disableTextLayoutManagerCacheAndroidCache: Boolean? = null
@@ -119,6 +120,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
119120
return cached
120121
}
121122

123+
override fun disableFabricCommitInCXXAnimated(): Boolean {
124+
var cached = disableFabricCommitInCXXAnimatedCache
125+
if (cached == null) {
126+
cached = currentProvider.disableFabricCommitInCXXAnimated()
127+
accessedFeatureFlags.add("disableFabricCommitInCXXAnimated")
128+
disableFabricCommitInCXXAnimatedCache = cached
129+
}
130+
return cached
131+
}
132+
122133
override fun disableMountItemReorderingAndroid(): Boolean {
123134
var cached = disableMountItemReorderingAndroidCache
124135
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<ee4525af457a5ad08f506cf8447a4156>>
7+
* @generated SignedSource<<bcd6d9b502d0dc374fc239fb860dd2b9>>
88
*/
99

1010
/**
@@ -29,6 +29,8 @@ public interface ReactNativeFeatureFlagsProvider {
2929

3030
@DoNotStrip public fun cxxNativeAnimatedRemoveJsSync(): Boolean
3131

32+
@DoNotStrip public fun disableFabricCommitInCXXAnimated(): Boolean
33+
3234
@DoNotStrip public fun disableMountItemReorderingAndroid(): Boolean
3335

3436
@DoNotStrip public fun disableOldAndroidAttachmentMetricsWorkarounds(): Boolean

packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<fa975c22ecec781f4621cad8b90ea290>>
7+
* @generated SignedSource<<ae065932c2095d9dbb802a1979624ab8>>
88
*/
99

1010
/**
@@ -57,6 +57,12 @@ class ReactNativeFeatureFlagsJavaProvider
5757
return method(javaProvider_);
5858
}
5959

60+
bool disableFabricCommitInCXXAnimated() override {
61+
static const auto method =
62+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("disableFabricCommitInCXXAnimated");
63+
return method(javaProvider_);
64+
}
65+
6066
bool disableMountItemReorderingAndroid() override {
6167
static const auto method =
6268
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("disableMountItemReorderingAndroid");
@@ -442,6 +448,11 @@ bool JReactNativeFeatureFlagsCxxInterop::cxxNativeAnimatedRemoveJsSync(
442448
return ReactNativeFeatureFlags::cxxNativeAnimatedRemoveJsSync();
443449
}
444450

451+
bool JReactNativeFeatureFlagsCxxInterop::disableFabricCommitInCXXAnimated(
452+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
453+
return ReactNativeFeatureFlags::disableFabricCommitInCXXAnimated();
454+
}
455+
445456
bool JReactNativeFeatureFlagsCxxInterop::disableMountItemReorderingAndroid(
446457
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
447458
return ReactNativeFeatureFlags::disableMountItemReorderingAndroid();
@@ -787,6 +798,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
787798
makeNativeMethod(
788799
"cxxNativeAnimatedRemoveJsSync",
789800
JReactNativeFeatureFlagsCxxInterop::cxxNativeAnimatedRemoveJsSync),
801+
makeNativeMethod(
802+
"disableFabricCommitInCXXAnimated",
803+
JReactNativeFeatureFlagsCxxInterop::disableFabricCommitInCXXAnimated),
790804
makeNativeMethod(
791805
"disableMountItemReorderingAndroid",
792806
JReactNativeFeatureFlagsCxxInterop::disableMountItemReorderingAndroid),

packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<3e83546899ed1194fe03f143865ba97a>>
7+
* @generated SignedSource<<9ed81573a882312bc8dad5c1ce3a544b>>
88
*/
99

1010
/**
@@ -39,6 +39,9 @@ class JReactNativeFeatureFlagsCxxInterop
3939
static bool cxxNativeAnimatedRemoveJsSync(
4040
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
4141

42+
static bool disableFabricCommitInCXXAnimated(
43+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
44+
4245
static bool disableMountItemReorderingAndroid(
4346
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
4447

packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<21d92927b8b282b29ed9ff5795c60f8a>>
7+
* @generated SignedSource<<aa946c3d4a6b602848e59f0eb0dbf957>>
88
*/
99

1010
/**
@@ -38,6 +38,10 @@ bool ReactNativeFeatureFlags::cxxNativeAnimatedRemoveJsSync() {
3838
return getAccessor().cxxNativeAnimatedRemoveJsSync();
3939
}
4040

41+
bool ReactNativeFeatureFlags::disableFabricCommitInCXXAnimated() {
42+
return getAccessor().disableFabricCommitInCXXAnimated();
43+
}
44+
4145
bool ReactNativeFeatureFlags::disableMountItemReorderingAndroid() {
4246
return getAccessor().disableMountItemReorderingAndroid();
4347
}

packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<4e6e5bfa892fcfc1ad67d625a6b58ce6>>
7+
* @generated SignedSource<<728daf2946d40a449a702cb0d9c19f66>>
88
*/
99

1010
/**
@@ -54,6 +54,11 @@ class ReactNativeFeatureFlags {
5454
*/
5555
RN_EXPORT static bool cxxNativeAnimatedRemoveJsSync();
5656

57+
/**
58+
* Prevents use of Fabric commit in C++ Animated implementation
59+
*/
60+
RN_EXPORT static bool disableFabricCommitInCXXAnimated();
61+
5762
/**
5863
* Prevent FabricMountingManager from reordering mountItems, which may lead to invalid state on the UI thread
5964
*/

0 commit comments

Comments
 (0)