Skip to content

Commit 34ec31b

Browse files
Bartlomiej Bloniarzmeta-codesync[bot]
authored andcommitted
Add optimizedAnimatedPropUpdates feature flag
Summary: Add a new React Native feature flag, `optimizedAnimatedPropUpdates`, which gates an upcoming optimized code path for applying animated property updates from the C++ animation backend. The flag defaults to disabled and has no behavioural impact on its own. Changelog: [General][Added] - Add `optimizedAnimatedPropUpdates` feature flag Differential Revision: D101157450
1 parent 745b749 commit 34ec31b

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<<d4e81be344e15b275d015651b4fa824d>>
7+
* @generated SignedSource<<9fa8df8bd4c6ef4efeddff62e8518472>>
88
*/
99

1010
/**
@@ -414,6 +414,12 @@ public object ReactNativeFeatureFlags {
414414
@JvmStatic
415415
public fun hideOffscreenVirtualViewsOnIOS(): Boolean = accessor.hideOffscreenVirtualViewsOnIOS()
416416

417+
/**
418+
* 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.
419+
*/
420+
@JvmStatic
421+
public fun optimizedAnimatedPropUpdates(): Boolean = accessor.optimizedAnimatedPropUpdates()
422+
417423
/**
418424
* Override props at mounting with synchronously mounted (i.e. direct manipulation) props from Native Animated.
419425
*/

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<<189cc2dd3b42cd736191f13b442e7317>>
7+
* @generated SignedSource<<ef125427b8daa352919a846435008cad>>
88
*/
99

1010
/**
@@ -84,6 +84,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
8484
private var fuseboxNetworkInspectionEnabledCache: Boolean? = null
8585
private var fuseboxScreenshotCaptureEnabledCache: Boolean? = null
8686
private var hideOffscreenVirtualViewsOnIOSCache: Boolean? = null
87+
private var optimizedAnimatedPropUpdatesCache: Boolean? = null
8788
private var overrideBySynchronousMountPropsAtMountingAndroidCache: Boolean? = null
8889
private var perfIssuesEnabledCache: Boolean? = null
8990
private var perfMonitorV2EnabledCache: Boolean? = null
@@ -689,6 +690,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
689690
return cached
690691
}
691692

693+
override fun optimizedAnimatedPropUpdates(): Boolean {
694+
var cached = optimizedAnimatedPropUpdatesCache
695+
if (cached == null) {
696+
cached = ReactNativeFeatureFlagsCxxInterop.optimizedAnimatedPropUpdates()
697+
optimizedAnimatedPropUpdatesCache = cached
698+
}
699+
return cached
700+
}
701+
692702
override fun overrideBySynchronousMountPropsAtMountingAndroid(): Boolean {
693703
var cached = overrideBySynchronousMountPropsAtMountingAndroidCache
694704
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<<81c6672ae539af203fae7e0f9cf541a6>>
7+
* @generated SignedSource<<ebe28a896847fe54affddc0007733ee9>>
88
*/
99

1010
/**
@@ -156,6 +156,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
156156

157157
@DoNotStrip @JvmStatic public external fun hideOffscreenVirtualViewsOnIOS(): Boolean
158158

159+
@DoNotStrip @JvmStatic public external fun optimizedAnimatedPropUpdates(): Boolean
160+
159161
@DoNotStrip @JvmStatic public external fun overrideBySynchronousMountPropsAtMountingAndroid(): Boolean
160162

161163
@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<<053d67947ccd1a3556c8f6e1b6af5a14>>
7+
* @generated SignedSource<<008cbcccd695935f1d4ca17e69bce718>>
88
*/
99

1010
/**
@@ -151,6 +151,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
151151

152152
override fun hideOffscreenVirtualViewsOnIOS(): Boolean = false
153153

154+
override fun optimizedAnimatedPropUpdates(): Boolean = false
155+
154156
override fun overrideBySynchronousMountPropsAtMountingAndroid(): Boolean = true
155157

156158
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<<24972f077ba738a8191a2956be61b491>>
7+
* @generated SignedSource<<0d50d159540c35fa0ae015093a483442>>
88
*/
99

1010
/**
@@ -88,6 +88,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
8888
private var fuseboxNetworkInspectionEnabledCache: Boolean? = null
8989
private var fuseboxScreenshotCaptureEnabledCache: Boolean? = null
9090
private var hideOffscreenVirtualViewsOnIOSCache: Boolean? = null
91+
private var optimizedAnimatedPropUpdatesCache: Boolean? = null
9192
private var overrideBySynchronousMountPropsAtMountingAndroidCache: Boolean? = null
9293
private var perfIssuesEnabledCache: Boolean? = null
9394
private var perfMonitorV2EnabledCache: Boolean? = null
@@ -757,6 +758,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
757758
return cached
758759
}
759760

761+
override fun optimizedAnimatedPropUpdates(): Boolean {
762+
var cached = optimizedAnimatedPropUpdatesCache
763+
if (cached == null) {
764+
cached = currentProvider.optimizedAnimatedPropUpdates()
765+
accessedFeatureFlags.add("optimizedAnimatedPropUpdates")
766+
optimizedAnimatedPropUpdatesCache = cached
767+
}
768+
return cached
769+
}
770+
760771
override fun overrideBySynchronousMountPropsAtMountingAndroid(): Boolean {
761772
var cached = overrideBySynchronousMountPropsAtMountingAndroidCache
762773
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<<a7c69ce7e10faeb5328412c5e29552cf>>
7+
* @generated SignedSource<<0c9e61dd9a6102da81fa394d8a6401e2>>
88
*/
99

1010
/**
@@ -151,6 +151,8 @@ public interface ReactNativeFeatureFlagsProvider {
151151

152152
@DoNotStrip public fun hideOffscreenVirtualViewsOnIOS(): Boolean
153153

154+
@DoNotStrip public fun optimizedAnimatedPropUpdates(): Boolean
155+
154156
@DoNotStrip public fun overrideBySynchronousMountPropsAtMountingAndroid(): Boolean
155157

156158
@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<<74f0602ce337a86730efe638ab8e966d>>
7+
* @generated SignedSource<<1f63c355480af133d9245dad20da704c>>
88
*/
99

1010
/**
@@ -423,6 +423,12 @@ class ReactNativeFeatureFlagsJavaProvider
423423
return method(javaProvider_);
424424
}
425425

426+
bool optimizedAnimatedPropUpdates() override {
427+
static const auto method =
428+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("optimizedAnimatedPropUpdates");
429+
return method(javaProvider_);
430+
}
431+
426432
bool overrideBySynchronousMountPropsAtMountingAndroid() override {
427433
static const auto method =
428434
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("overrideBySynchronousMountPropsAtMountingAndroid");
@@ -915,6 +921,11 @@ bool JReactNativeFeatureFlagsCxxInterop::hideOffscreenVirtualViewsOnIOS(
915921
return ReactNativeFeatureFlags::hideOffscreenVirtualViewsOnIOS();
916922
}
917923

924+
bool JReactNativeFeatureFlagsCxxInterop::optimizedAnimatedPropUpdates(
925+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
926+
return ReactNativeFeatureFlags::optimizedAnimatedPropUpdates();
927+
}
928+
918929
bool JReactNativeFeatureFlagsCxxInterop::overrideBySynchronousMountPropsAtMountingAndroid(
919930
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
920931
return ReactNativeFeatureFlags::overrideBySynchronousMountPropsAtMountingAndroid();
@@ -1278,6 +1289,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
12781289
makeNativeMethod(
12791290
"hideOffscreenVirtualViewsOnIOS",
12801291
JReactNativeFeatureFlagsCxxInterop::hideOffscreenVirtualViewsOnIOS),
1292+
makeNativeMethod(
1293+
"optimizedAnimatedPropUpdates",
1294+
JReactNativeFeatureFlagsCxxInterop::optimizedAnimatedPropUpdates),
12811295
makeNativeMethod(
12821296
"overrideBySynchronousMountPropsAtMountingAndroid",
12831297
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<<2e867941f693c14c0c52475d790cfed4>>
7+
* @generated SignedSource<<fbc1ffa6b9806e600b1e956f949eec3d>>
88
*/
99

1010
/**
@@ -222,6 +222,9 @@ class JReactNativeFeatureFlagsCxxInterop
222222
static bool hideOffscreenVirtualViewsOnIOS(
223223
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
224224

225+
static bool optimizedAnimatedPropUpdates(
226+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
227+
225228
static bool overrideBySynchronousMountPropsAtMountingAndroid(
226229
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
227230

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<<9c49f2931ab219997bc29969de95805d>>
7+
* @generated SignedSource<<b6d127d91bedd52101dae5761a9322b0>>
88
*/
99

1010
/**
@@ -282,6 +282,10 @@ bool ReactNativeFeatureFlags::hideOffscreenVirtualViewsOnIOS() {
282282
return getAccessor().hideOffscreenVirtualViewsOnIOS();
283283
}
284284

285+
bool ReactNativeFeatureFlags::optimizedAnimatedPropUpdates() {
286+
return getAccessor().optimizedAnimatedPropUpdates();
287+
}
288+
285289
bool ReactNativeFeatureFlags::overrideBySynchronousMountPropsAtMountingAndroid() {
286290
return getAccessor().overrideBySynchronousMountPropsAtMountingAndroid();
287291
}

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<<d15e79bbfac17a32fd7981538afc3683>>
7+
* @generated SignedSource<<58cb57cd6fc7d708db8f496744608f53>>
88
*/
99

1010
/**
@@ -359,6 +359,11 @@ class ReactNativeFeatureFlags {
359359
*/
360360
RN_EXPORT static bool hideOffscreenVirtualViewsOnIOS();
361361

362+
/**
363+
* 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.
364+
*/
365+
RN_EXPORT static bool optimizedAnimatedPropUpdates();
366+
362367
/**
363368
* Override props at mounting with synchronously mounted (i.e. direct manipulation) props from Native Animated.
364369
*/

0 commit comments

Comments
 (0)