Skip to content

Commit 2f28eee

Browse files
zeyapmeta-codesync[bot]
authored andcommitted
Add animatedDeferStartOfTimingAnimations feature flag
Summary: Add the `animatedDeferStartOfTimingAnimations` common (native + JS) feature flag (default off). On its own this is a no-op; it gates deferring the start of native-driven timing animations to the first rendered frame, implemented in the following diffs. The flag is defined as a `common` flag (not JS-only) so the same value can be read from both the JS Animated layer and the native C++ animation code. This diff includes all the generated accessors, regenerated via `yarn featureflags --update`: Kotlin (`ReactNativeFeatureFlags*.kt`), C++ (`ReactNativeFeatureFlags*.h`/`.cpp` and the JNI interop), the JS `ReactNativeFeatureFlags.js`, and the native module spec. Changelog: [Internal] Differential Revision: D106825629
1 parent dc9043e commit 2f28eee

20 files changed

Lines changed: 223 additions & 106 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<<86c797c19cc585b74714ca3aa75bbd6d>>
7+
* @generated SignedSource<<5a3498ac81b47029c55d5ad60459b3a0>>
88
*/
99

1010
/**
@@ -36,6 +36,12 @@ public object ReactNativeFeatureFlags {
3636
@JvmStatic
3737
public fun commonTestFlag(): Boolean = accessor.commonTestFlag()
3838

39+
/**
40+
* When enabled, native timing animations defer their first frame and re-anchor timing to prevent skipping initial frames when the UI thread is busy with layout work.
41+
*/
42+
@JvmStatic
43+
public fun animatedDeferStartOfTimingAnimations(): Boolean = accessor.animatedDeferStartOfTimingAnimations()
44+
3945
/**
4046
* Enable emitting of InteractionEntry live metrics to the debugger. Requires `enableBridgelessArchitecture`.
4147
*/

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<<d71556cf1226fe6a41dd388568153d3a>>
7+
* @generated SignedSource<<3b5c4a312ce0ef80fea3cd3bb733924c>>
88
*/
99

1010
/**
@@ -21,6 +21,7 @@ package com.facebook.react.internal.featureflags
2121

2222
internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccessor {
2323
private var commonTestFlagCache: Boolean? = null
24+
private var animatedDeferStartOfTimingAnimationsCache: Boolean? = null
2425
private var cdpInteractionMetricsEnabledCache: Boolean? = null
2526
private var cxxNativeAnimatedEnabledCache: Boolean? = null
2627
private var defaultTextToOverflowHiddenCache: Boolean? = null
@@ -117,6 +118,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
117118
return cached
118119
}
119120

121+
override fun animatedDeferStartOfTimingAnimations(): Boolean {
122+
var cached = animatedDeferStartOfTimingAnimationsCache
123+
if (cached == null) {
124+
cached = ReactNativeFeatureFlagsCxxInterop.animatedDeferStartOfTimingAnimations()
125+
animatedDeferStartOfTimingAnimationsCache = cached
126+
}
127+
return cached
128+
}
129+
120130
override fun cdpInteractionMetricsEnabled(): Boolean {
121131
var cached = cdpInteractionMetricsEnabledCache
122132
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<<2ee82b1e1dcae3ea10dbd92549d65a6c>>
7+
* @generated SignedSource<<45cd25ae7e3e3d850e3c80fc0a433dd6>>
88
*/
99

1010
/**
@@ -30,6 +30,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
3030

3131
@DoNotStrip @JvmStatic public external fun commonTestFlag(): Boolean
3232

33+
@DoNotStrip @JvmStatic public external fun animatedDeferStartOfTimingAnimations(): Boolean
34+
3335
@DoNotStrip @JvmStatic public external fun cdpInteractionMetricsEnabled(): Boolean
3436

3537
@DoNotStrip @JvmStatic public external fun cxxNativeAnimatedEnabled(): 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<<738a114e73ddb940fb14efd0dff79d1b>>
7+
* @generated SignedSource<<53813a42017eb4b46774e6bb0c46185a>>
88
*/
99

1010
/**
@@ -25,6 +25,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
2525

2626
override fun commonTestFlag(): Boolean = false
2727

28+
override fun animatedDeferStartOfTimingAnimations(): Boolean = false
29+
2830
override fun cdpInteractionMetricsEnabled(): Boolean = false
2931

3032
override fun cxxNativeAnimatedEnabled(): 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<<d5b84c7e0c58f61d891e0dd63f61b4c0>>
7+
* @generated SignedSource<<4ce8eccad029b1b8b8296ca4e5664d2a>>
88
*/
99

1010
/**
@@ -25,6 +25,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
2525
private val accessedFeatureFlags = mutableSetOf<String>()
2626

2727
private var commonTestFlagCache: Boolean? = null
28+
private var animatedDeferStartOfTimingAnimationsCache: Boolean? = null
2829
private var cdpInteractionMetricsEnabledCache: Boolean? = null
2930
private var cxxNativeAnimatedEnabledCache: Boolean? = null
3031
private var defaultTextToOverflowHiddenCache: Boolean? = null
@@ -122,6 +123,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
122123
return cached
123124
}
124125

126+
override fun animatedDeferStartOfTimingAnimations(): Boolean {
127+
var cached = animatedDeferStartOfTimingAnimationsCache
128+
if (cached == null) {
129+
cached = currentProvider.animatedDeferStartOfTimingAnimations()
130+
accessedFeatureFlags.add("animatedDeferStartOfTimingAnimations")
131+
animatedDeferStartOfTimingAnimationsCache = cached
132+
}
133+
return cached
134+
}
135+
125136
override fun cdpInteractionMetricsEnabled(): Boolean {
126137
var cached = cdpInteractionMetricsEnabledCache
127138
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<<a3dbeb4eec6efecc4fc355b15a984e58>>
7+
* @generated SignedSource<<dccf6ee6d2603cac53e58d6c80640d3f>>
88
*/
99

1010
/**
@@ -25,6 +25,8 @@ import com.facebook.proguard.annotations.DoNotStrip
2525
public interface ReactNativeFeatureFlagsProvider {
2626
@DoNotStrip public fun commonTestFlag(): Boolean
2727

28+
@DoNotStrip public fun animatedDeferStartOfTimingAnimations(): Boolean
29+
2830
@DoNotStrip public fun cdpInteractionMetricsEnabled(): Boolean
2931

3032
@DoNotStrip public fun cxxNativeAnimatedEnabled(): 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<<99f843dd0784f9fe372f943767e2033c>>
7+
* @generated SignedSource<<e6b17f4548b88ccca9605165525c03b8>>
88
*/
99

1010
/**
@@ -45,6 +45,12 @@ class ReactNativeFeatureFlagsJavaProvider
4545
return method(javaProvider_);
4646
}
4747

48+
bool animatedDeferStartOfTimingAnimations() override {
49+
static const auto method =
50+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("animatedDeferStartOfTimingAnimations");
51+
return method(javaProvider_);
52+
}
53+
4854
bool cdpInteractionMetricsEnabled() override {
4955
static const auto method =
5056
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("cdpInteractionMetricsEnabled");
@@ -570,6 +576,11 @@ bool JReactNativeFeatureFlagsCxxInterop::commonTestFlag(
570576
return ReactNativeFeatureFlags::commonTestFlag();
571577
}
572578

579+
bool JReactNativeFeatureFlagsCxxInterop::animatedDeferStartOfTimingAnimations(
580+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
581+
return ReactNativeFeatureFlags::animatedDeferStartOfTimingAnimations();
582+
}
583+
573584
bool JReactNativeFeatureFlagsCxxInterop::cdpInteractionMetricsEnabled(
574585
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
575586
return ReactNativeFeatureFlags::cdpInteractionMetricsEnabled();
@@ -1034,6 +1045,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
10341045
makeNativeMethod(
10351046
"commonTestFlag",
10361047
JReactNativeFeatureFlagsCxxInterop::commonTestFlag),
1048+
makeNativeMethod(
1049+
"animatedDeferStartOfTimingAnimations",
1050+
JReactNativeFeatureFlagsCxxInterop::animatedDeferStartOfTimingAnimations),
10371051
makeNativeMethod(
10381052
"cdpInteractionMetricsEnabled",
10391053
JReactNativeFeatureFlagsCxxInterop::cdpInteractionMetricsEnabled),

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<<05716b6ab8139bc31b962f9158acd6b6>>
7+
* @generated SignedSource<<49ef70701e00d4f06c400157392405bd>>
88
*/
99

1010
/**
@@ -33,6 +33,9 @@ class JReactNativeFeatureFlagsCxxInterop
3333
static bool commonTestFlag(
3434
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
3535

36+
static bool animatedDeferStartOfTimingAnimations(
37+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
38+
3639
static bool cdpInteractionMetricsEnabled(
3740
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
3841

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

1010
/**
@@ -30,6 +30,10 @@ bool ReactNativeFeatureFlags::commonTestFlag() {
3030
return getAccessor().commonTestFlag();
3131
}
3232

33+
bool ReactNativeFeatureFlags::animatedDeferStartOfTimingAnimations() {
34+
return getAccessor().animatedDeferStartOfTimingAnimations();
35+
}
36+
3337
bool ReactNativeFeatureFlags::cdpInteractionMetricsEnabled() {
3438
return getAccessor().cdpInteractionMetricsEnabled();
3539
}

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<<dcb1e3ba662f28194124dc63879f4fde>>
7+
* @generated SignedSource<<4c8925cb81d67439feb8f3c1e9690d36>>
88
*/
99

1010
/**
@@ -44,6 +44,11 @@ class ReactNativeFeatureFlags {
4444
*/
4545
RN_EXPORT static bool commonTestFlag();
4646

47+
/**
48+
* When enabled, native timing animations defer their first frame and re-anchor timing to prevent skipping initial frames when the UI thread is busy with layout work.
49+
*/
50+
RN_EXPORT static bool animatedDeferStartOfTimingAnimations();
51+
4752
/**
4853
* Enable emitting of InteractionEntry live metrics to the debugger. Requires `enableBridgelessArchitecture`.
4954
*/

0 commit comments

Comments
 (0)