Skip to content

Commit 2c2e21c

Browse files
Bartlomiej Bloniarzmeta-codesync[bot]
authored andcommitted
Add optimizedAnimatedPropUpdates feature flag (#56466)
Summary: Pull Request resolved: #56466 Add a new feature flag to gate the optimized animated prop updates code path. Differential Revision: D101157450
1 parent 52d87f9 commit 2c2e21c

20 files changed

Lines changed: 165 additions & 48 deletions

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<<c9be40b9d016463d1531057598a6aa88>>
7+
* @generated SignedSource<<bb2f6e382818453ab0290579f34670fd>>
88
*/
99

1010
/**
@@ -408,6 +408,12 @@ public object ReactNativeFeatureFlags {
408408
@JvmStatic
409409
public fun hideOffscreenVirtualViewsOnIOS(): Boolean = accessor.hideOffscreenVirtualViewsOnIOS()
410410

411+
/**
412+
* When enabled, uses optimized platform-specific paths to apply animated props synchronously. On Android, this uses a batched int/double buffer protocol with a single JNI call. On iOS, this passes AnimatedProps directly through the delegate chain and applies them via cloneProps, avoiding the folly::dynamic round-trip.
413+
*/
414+
@JvmStatic
415+
public fun optimizedAnimatedPropUpdates(): Boolean = accessor.optimizedAnimatedPropUpdates()
416+
411417
/**
412418
* Override props at mounting with synchronously mounted (i.e. direct manipulation) props from Native Animated.
413419
*/

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<<d07f1b96cf6e0a1798f86fc9f61caf73>>
7+
* @generated SignedSource<<1648fa680c10f771918390ccb73fe841>>
88
*/
99

1010
/**
@@ -83,6 +83,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
8383
private var fuseboxNetworkInspectionEnabledCache: Boolean? = null
8484
private var fuseboxScreenshotCaptureEnabledCache: Boolean? = null
8585
private var hideOffscreenVirtualViewsOnIOSCache: Boolean? = null
86+
private var optimizedAnimatedPropUpdatesCache: Boolean? = null
8687
private var overrideBySynchronousMountPropsAtMountingAndroidCache: Boolean? = null
8788
private var perfIssuesEnabledCache: Boolean? = null
8889
private var perfMonitorV2EnabledCache: Boolean? = null
@@ -679,6 +680,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
679680
return cached
680681
}
681682

683+
override fun optimizedAnimatedPropUpdates(): Boolean {
684+
var cached = optimizedAnimatedPropUpdatesCache
685+
if (cached == null) {
686+
cached = ReactNativeFeatureFlagsCxxInterop.optimizedAnimatedPropUpdates()
687+
optimizedAnimatedPropUpdatesCache = cached
688+
}
689+
return cached
690+
}
691+
682692
override fun overrideBySynchronousMountPropsAtMountingAndroid(): Boolean {
683693
var cached = overrideBySynchronousMountPropsAtMountingAndroidCache
684694
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<<d9aa2a16720aa9fd4378c0c14e4f8ffa>>
7+
* @generated SignedSource<<29dd19bc368ca4b60a7531f246813105>>
88
*/
99

1010
/**
@@ -154,6 +154,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
154154

155155
@DoNotStrip @JvmStatic public external fun hideOffscreenVirtualViewsOnIOS(): Boolean
156156

157+
@DoNotStrip @JvmStatic public external fun optimizedAnimatedPropUpdates(): Boolean
158+
157159
@DoNotStrip @JvmStatic public external fun overrideBySynchronousMountPropsAtMountingAndroid(): Boolean
158160

159161
@DoNotStrip @JvmStatic public external fun perfIssuesEnabled(): 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<<54a4f6d01a052e5ab19b15652d5ab1a5>>
7+
* @generated SignedSource<<2126ce39c026f84bae555060c29f7ffe>>
88
*/
99

1010
/**
@@ -149,6 +149,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
149149

150150
override fun hideOffscreenVirtualViewsOnIOS(): Boolean = false
151151

152+
override fun optimizedAnimatedPropUpdates(): Boolean = false
153+
152154
override fun overrideBySynchronousMountPropsAtMountingAndroid(): Boolean = true
153155

154156
override fun perfIssuesEnabled(): Boolean = false

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<<4d09d820304f454bc3850da89087caec>>
7+
* @generated SignedSource<<8be9380698b7ee8c44a022c261c50f8e>>
88
*/
99

1010
/**
@@ -87,6 +87,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
8787
private var fuseboxNetworkInspectionEnabledCache: Boolean? = null
8888
private var fuseboxScreenshotCaptureEnabledCache: Boolean? = null
8989
private var hideOffscreenVirtualViewsOnIOSCache: Boolean? = null
90+
private var optimizedAnimatedPropUpdatesCache: Boolean? = null
9091
private var overrideBySynchronousMountPropsAtMountingAndroidCache: Boolean? = null
9192
private var perfIssuesEnabledCache: Boolean? = null
9293
private var perfMonitorV2EnabledCache: Boolean? = null
@@ -746,6 +747,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
746747
return cached
747748
}
748749

750+
override fun optimizedAnimatedPropUpdates(): Boolean {
751+
var cached = optimizedAnimatedPropUpdatesCache
752+
if (cached == null) {
753+
cached = currentProvider.optimizedAnimatedPropUpdates()
754+
accessedFeatureFlags.add("optimizedAnimatedPropUpdates")
755+
optimizedAnimatedPropUpdatesCache = cached
756+
}
757+
return cached
758+
}
759+
749760
override fun overrideBySynchronousMountPropsAtMountingAndroid(): Boolean {
750761
var cached = overrideBySynchronousMountPropsAtMountingAndroidCache
751762
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<<592acf445c4b4e56651cd6afb57e46fa>>
7+
* @generated SignedSource<<b6ddbc0b2dab94f9996a30c407346e52>>
88
*/
99

1010
/**
@@ -149,6 +149,8 @@ public interface ReactNativeFeatureFlagsProvider {
149149

150150
@DoNotStrip public fun hideOffscreenVirtualViewsOnIOS(): Boolean
151151

152+
@DoNotStrip public fun optimizedAnimatedPropUpdates(): Boolean
153+
152154
@DoNotStrip public fun overrideBySynchronousMountPropsAtMountingAndroid(): Boolean
153155

154156
@DoNotStrip public fun perfIssuesEnabled(): 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<<55e4d6d6dc930b4ccf3e20cb77f7a042>>
7+
* @generated SignedSource<<906b76deb455d068ab12e3d1a21f4c12>>
88
*/
99

1010
/**
@@ -417,6 +417,12 @@ class ReactNativeFeatureFlagsJavaProvider
417417
return method(javaProvider_);
418418
}
419419

420+
bool optimizedAnimatedPropUpdates() override {
421+
static const auto method =
422+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("optimizedAnimatedPropUpdates");
423+
return method(javaProvider_);
424+
}
425+
420426
bool overrideBySynchronousMountPropsAtMountingAndroid() override {
421427
static const auto method =
422428
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("overrideBySynchronousMountPropsAtMountingAndroid");
@@ -904,6 +910,11 @@ bool JReactNativeFeatureFlagsCxxInterop::hideOffscreenVirtualViewsOnIOS(
904910
return ReactNativeFeatureFlags::hideOffscreenVirtualViewsOnIOS();
905911
}
906912

913+
bool JReactNativeFeatureFlagsCxxInterop::optimizedAnimatedPropUpdates(
914+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
915+
return ReactNativeFeatureFlags::optimizedAnimatedPropUpdates();
916+
}
917+
907918
bool JReactNativeFeatureFlagsCxxInterop::overrideBySynchronousMountPropsAtMountingAndroid(
908919
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
909920
return ReactNativeFeatureFlags::overrideBySynchronousMountPropsAtMountingAndroid();
@@ -1264,6 +1275,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
12641275
makeNativeMethod(
12651276
"hideOffscreenVirtualViewsOnIOS",
12661277
JReactNativeFeatureFlagsCxxInterop::hideOffscreenVirtualViewsOnIOS),
1278+
makeNativeMethod(
1279+
"optimizedAnimatedPropUpdates",
1280+
JReactNativeFeatureFlagsCxxInterop::optimizedAnimatedPropUpdates),
12671281
makeNativeMethod(
12681282
"overrideBySynchronousMountPropsAtMountingAndroid",
12691283
JReactNativeFeatureFlagsCxxInterop::overrideBySynchronousMountPropsAtMountingAndroid),

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<<f1db4e44d0b5d3daa11aec0e6a83e09f>>
7+
* @generated SignedSource<<be1c62b8fa507a337f7b100bc8f3de14>>
88
*/
99

1010
/**
@@ -219,6 +219,9 @@ class JReactNativeFeatureFlagsCxxInterop
219219
static bool hideOffscreenVirtualViewsOnIOS(
220220
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
221221

222+
static bool optimizedAnimatedPropUpdates(
223+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
224+
222225
static bool overrideBySynchronousMountPropsAtMountingAndroid(
223226
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
224227

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<<16024bed6914b4b74d4a50de142e872a>>
7+
* @generated SignedSource<<c442eb4ec51e996443b7204a4cad3e5e>>
88
*/
99

1010
/**
@@ -278,6 +278,10 @@ bool ReactNativeFeatureFlags::hideOffscreenVirtualViewsOnIOS() {
278278
return getAccessor().hideOffscreenVirtualViewsOnIOS();
279279
}
280280

281+
bool ReactNativeFeatureFlags::optimizedAnimatedPropUpdates() {
282+
return getAccessor().optimizedAnimatedPropUpdates();
283+
}
284+
281285
bool ReactNativeFeatureFlags::overrideBySynchronousMountPropsAtMountingAndroid() {
282286
return getAccessor().overrideBySynchronousMountPropsAtMountingAndroid();
283287
}

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<<33ffe2572bbaeba64d2167dbac4bb0ab>>
7+
* @generated SignedSource<<80c7b73bcd12d8257128d24f9606efbe>>
88
*/
99

1010
/**
@@ -354,6 +354,11 @@ class ReactNativeFeatureFlags {
354354
*/
355355
RN_EXPORT static bool hideOffscreenVirtualViewsOnIOS();
356356

357+
/**
358+
* When enabled, uses optimized platform-specific paths to apply animated props synchronously. On Android, this uses a batched int/double buffer protocol with a single JNI call. On iOS, this passes AnimatedProps directly through the delegate chain and applies them via cloneProps, avoiding the folly::dynamic round-trip.
359+
*/
360+
RN_EXPORT static bool optimizedAnimatedPropUpdates();
361+
357362
/**
358363
* Override props at mounting with synchronously mounted (i.e. direct manipulation) props from Native Animated.
359364
*/

0 commit comments

Comments
 (0)