Skip to content

Commit e5a2ae0

Browse files
Bartlomiej Bloniarzmeta-codesync[bot]
authored andcommitted
Add optimizedAnimatedPropUpdates feature flag
Summary: Add a new feature flag to gate the optimized animated prop updates code path. Differential Revision: D101157450
1 parent a6f2697 commit e5a2ae0

20 files changed

Lines changed: 162 additions & 45 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<<99a7d3e814f4b037ed4496b6eee4f264>>
7+
* @generated SignedSource<<ec90d5adafcfcc96eaf00148f0ba1991>>
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<<c2f867597d97dc97c8ded5fbd258c13c>>
7+
* @generated SignedSource<<9f7ea26f2a79cb69ec00b8ec763b605e>>
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
@@ -686,6 +687,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
686687
return cached
687688
}
688689

690+
override fun optimizedAnimatedPropUpdates(): Boolean {
691+
var cached = optimizedAnimatedPropUpdatesCache
692+
if (cached == null) {
693+
cached = ReactNativeFeatureFlagsCxxInterop.optimizedAnimatedPropUpdates()
694+
optimizedAnimatedPropUpdatesCache = cached
695+
}
696+
return cached
697+
}
698+
689699
override fun overrideBySynchronousMountPropsAtMountingAndroid(): Boolean {
690700
var cached = overrideBySynchronousMountPropsAtMountingAndroidCache
691701
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<<8667d7237cea82bb5978cb19582d59c0>>
7+
* @generated SignedSource<<615682a04f2be0b548235ca172faa244>>
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<<17abc72a4045c5695818f254be1783b5>>
7+
* @generated SignedSource<<7b05d0055367981a6c6eb6cd79ef93a6>>
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 = false
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<<77ba6c5db120016e6e1f8af195ab3690>>
7+
* @generated SignedSource<<9b1e9427538a12e34afe0f045f9adc94>>
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
@@ -754,6 +755,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
754755
return cached
755756
}
756757

758+
override fun optimizedAnimatedPropUpdates(): Boolean {
759+
var cached = optimizedAnimatedPropUpdatesCache
760+
if (cached == null) {
761+
cached = currentProvider.optimizedAnimatedPropUpdates()
762+
accessedFeatureFlags.add("optimizedAnimatedPropUpdates")
763+
optimizedAnimatedPropUpdatesCache = cached
764+
}
765+
return cached
766+
}
767+
757768
override fun overrideBySynchronousMountPropsAtMountingAndroid(): Boolean {
758769
var cached = overrideBySynchronousMountPropsAtMountingAndroidCache
759770
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<<8496c138ce5493df84149940df0de944>>
7+
* @generated SignedSource<<6aacf1c52ec159d7084dc106da017856>>
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<<5bac13bb6faeffdd3c5eca800f25b96a>>
7+
* @generated SignedSource<<5cafc732183ce679bfc8ebeacccdffb5>>
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");
@@ -897,6 +903,11 @@ bool JReactNativeFeatureFlagsCxxInterop::hideOffscreenVirtualViewsOnIOS(
897903
return ReactNativeFeatureFlags::hideOffscreenVirtualViewsOnIOS();
898904
}
899905

906+
bool JReactNativeFeatureFlagsCxxInterop::optimizedAnimatedPropUpdates(
907+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
908+
return ReactNativeFeatureFlags::optimizedAnimatedPropUpdates();
909+
}
910+
900911
bool JReactNativeFeatureFlagsCxxInterop::overrideBySynchronousMountPropsAtMountingAndroid(
901912
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
902913
return ReactNativeFeatureFlags::overrideBySynchronousMountPropsAtMountingAndroid();
@@ -1245,6 +1256,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
12451256
makeNativeMethod(
12461257
"hideOffscreenVirtualViewsOnIOS",
12471258
JReactNativeFeatureFlagsCxxInterop::hideOffscreenVirtualViewsOnIOS),
1259+
makeNativeMethod(
1260+
"optimizedAnimatedPropUpdates",
1261+
JReactNativeFeatureFlagsCxxInterop::optimizedAnimatedPropUpdates),
12481262
makeNativeMethod(
12491263
"overrideBySynchronousMountPropsAtMountingAndroid",
12501264
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<<ad45dce1fafd3bd29078bd54e4206d9f>>
7+
* @generated SignedSource<<400ee06a74c3147f8f682257fbf49f82>>
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<<b229243317998e64843f285f86af161c>>
7+
* @generated SignedSource<<3bb0009fd52637e16a1760bb407dfbcb>>
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<<86b3267ffa68e0f68280957aa54d5041>>
7+
* @generated SignedSource<<95796a46468fa86faadac188ebb7e98a>>
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)