Skip to content

Commit 0a951c1

Browse files
yungstersfacebook-github-bot
authored andcommitted
RN: Create virtualViewPrerenderRatio Feature Flag (#51716)
Summary: Pull Request resolved: #51716 Adds a feature flag to experiment with different `prerenderRatio` values from the `VirtualView` native component. Notably, this is the first time that the a feature flag has a non-boolean type. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D75713594 fbshipit-source-id: ff3feb8d8bb3292fea6e04a4cfccd87e8249144e
1 parent 746376a commit 0a951c1

20 files changed

Lines changed: 136 additions & 20 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<<d92f20c3ec9183dd2539f41a7b45ad08>>
7+
* @generated SignedSource<<7484b716c0cb8d12d307e3b34767e559>>
88
*/
99

1010
/**
@@ -348,6 +348,12 @@ public object ReactNativeFeatureFlags {
348348
@JvmStatic
349349
public fun useTurboModules(): Boolean = accessor.useTurboModules()
350350

351+
/**
352+
* Initial prerender ratio for VirtualView.
353+
*/
354+
@JvmStatic
355+
public fun virtualViewPrerenderRatio(): Double = accessor.virtualViewPrerenderRatio()
356+
351357
/**
352358
* Overrides the feature flags with the ones provided by the given provider
353359
* (generally one that extends `ReactNativeFeatureFlagsDefaults`).

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<<1cd5b56933a6fc03ff2cc3b09fe0c2e8>>
7+
* @generated SignedSource<<daf78f5249ed27828d8e2fb83d5e5df3>>
88
*/
99

1010
/**
@@ -73,6 +73,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
7373
private var useShadowNodeStateOnCloneCache: Boolean? = null
7474
private var useTurboModuleInteropCache: Boolean? = null
7575
private var useTurboModulesCache: Boolean? = null
76+
private var virtualViewPrerenderRatioCache: Double? = null
7677

7778
override fun commonTestFlag(): Boolean {
7879
var cached = commonTestFlagCache
@@ -551,6 +552,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
551552
return cached
552553
}
553554

555+
override fun virtualViewPrerenderRatio(): Double {
556+
var cached = virtualViewPrerenderRatioCache
557+
if (cached == null) {
558+
cached = ReactNativeFeatureFlagsCxxInterop.virtualViewPrerenderRatio()
559+
virtualViewPrerenderRatioCache = cached
560+
}
561+
return cached
562+
}
563+
554564
override fun override(provider: ReactNativeFeatureFlagsProvider): Unit =
555565
ReactNativeFeatureFlagsCxxInterop.override(provider as Any)
556566

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<<3e0d774f5d727e98bce677e218238eb1>>
7+
* @generated SignedSource<<1261be706a0da435a217a88faed53015>>
88
*/
99

1010
/**
@@ -134,6 +134,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
134134

135135
@DoNotStrip @JvmStatic public external fun useTurboModules(): Boolean
136136

137+
@DoNotStrip @JvmStatic public external fun virtualViewPrerenderRatio(): Double
138+
137139
@DoNotStrip @JvmStatic public external fun override(provider: Any)
138140

139141
@DoNotStrip @JvmStatic public external fun dangerouslyReset()

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<<45f8f8047e5edb8b5c8fd32350246cf6>>
7+
* @generated SignedSource<<e3792f1be08a9175b71c3bef175fbb71>>
88
*/
99

1010
/**
@@ -128,4 +128,6 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
128128
override fun useTurboModuleInterop(): Boolean = false
129129

130130
override fun useTurboModules(): Boolean = false
131+
132+
override fun virtualViewPrerenderRatio(): Double = 5.0
131133
}

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<<2a7cd724a2ce1c9ea796f0b92120072b>>
7+
* @generated SignedSource<<aba6b250d4c48029ae96480724c16ed0>>
88
*/
99

1010
/**
@@ -77,6 +77,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
7777
private var useShadowNodeStateOnCloneCache: Boolean? = null
7878
private var useTurboModuleInteropCache: Boolean? = null
7979
private var useTurboModulesCache: Boolean? = null
80+
private var virtualViewPrerenderRatioCache: Double? = null
8081

8182
override fun commonTestFlag(): Boolean {
8283
var cached = commonTestFlagCache
@@ -608,6 +609,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
608609
return cached
609610
}
610611

612+
override fun virtualViewPrerenderRatio(): Double {
613+
var cached = virtualViewPrerenderRatioCache
614+
if (cached == null) {
615+
cached = currentProvider.virtualViewPrerenderRatio()
616+
accessedFeatureFlags.add("virtualViewPrerenderRatio")
617+
virtualViewPrerenderRatioCache = cached
618+
}
619+
return cached
620+
}
621+
611622
override fun override(provider: ReactNativeFeatureFlagsProvider) {
612623
if (accessedFeatureFlags.isNotEmpty()) {
613624
val accessedFeatureFlagsStr = accessedFeatureFlags.joinToString(separator = ", ") { it }

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

1010
/**
@@ -128,4 +128,6 @@ public interface ReactNativeFeatureFlagsProvider {
128128
@DoNotStrip public fun useTurboModuleInterop(): Boolean
129129

130130
@DoNotStrip public fun useTurboModules(): Boolean
131+
132+
@DoNotStrip public fun virtualViewPrerenderRatio(): Double
131133
}

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

1010
/**
@@ -357,6 +357,12 @@ class ReactNativeFeatureFlagsJavaProvider
357357
return method(javaProvider_);
358358
}
359359

360+
double virtualViewPrerenderRatio() override {
361+
static const auto method =
362+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jdouble()>("virtualViewPrerenderRatio");
363+
return method(javaProvider_);
364+
}
365+
360366
private:
361367
jni::global_ref<jobject> javaProvider_;
362368
};
@@ -626,6 +632,11 @@ bool JReactNativeFeatureFlagsCxxInterop::useTurboModules(
626632
return ReactNativeFeatureFlags::useTurboModules();
627633
}
628634

635+
double JReactNativeFeatureFlagsCxxInterop::virtualViewPrerenderRatio(
636+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
637+
return ReactNativeFeatureFlags::virtualViewPrerenderRatio();
638+
}
639+
629640
void JReactNativeFeatureFlagsCxxInterop::override(
630641
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/,
631642
jni::alias_ref<jobject> provider) {
@@ -816,6 +827,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
816827
makeNativeMethod(
817828
"useTurboModules",
818829
JReactNativeFeatureFlagsCxxInterop::useTurboModules),
830+
makeNativeMethod(
831+
"virtualViewPrerenderRatio",
832+
JReactNativeFeatureFlagsCxxInterop::virtualViewPrerenderRatio),
819833
});
820834
}
821835

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<<5916c20e72c045471b0182b229fa13c7>>
7+
* @generated SignedSource<<8ecffdc9571b0f9e89c90b5f53fd17d8>>
88
*/
99

1010
/**
@@ -189,6 +189,9 @@ class JReactNativeFeatureFlagsCxxInterop
189189
static bool useTurboModules(
190190
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
191191

192+
static double virtualViewPrerenderRatio(
193+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
194+
192195
static void override(
193196
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>,
194197
jni::alias_ref<jobject> provider);

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<<39a09787285319461afa9de7543d4365>>
7+
* @generated SignedSource<<b724dc9b1812a124f4964640b7fca8a1>>
88
*/
99

1010
/**
@@ -238,6 +238,10 @@ bool ReactNativeFeatureFlags::useTurboModules() {
238238
return getAccessor().useTurboModules();
239239
}
240240

241+
double ReactNativeFeatureFlags::virtualViewPrerenderRatio() {
242+
return getAccessor().virtualViewPrerenderRatio();
243+
}
244+
241245
void ReactNativeFeatureFlags::override(
242246
std::unique_ptr<ReactNativeFeatureFlagsProvider> provider) {
243247
getAccessor().override(std::move(provider));

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

1010
/**
@@ -304,6 +304,11 @@ class ReactNativeFeatureFlags {
304304
*/
305305
RN_EXPORT static bool useTurboModules();
306306

307+
/**
308+
* Initial prerender ratio for VirtualView.
309+
*/
310+
RN_EXPORT static double virtualViewPrerenderRatio();
311+
307312
/**
308313
* Overrides the feature flags with the ones provided by the given provider
309314
* (generally one that extends `ReactNativeFeatureFlagsDefaults`).

0 commit comments

Comments
 (0)