Skip to content

Commit 2008354

Browse files
Nick Lefeverfacebook-github-bot
authored andcommitted
Add support for global view culling outset ratio setting
Summary: Adding a feature flag controlling the outset ratio set on the culling context frame. This feature flag value will add an outset on the width and height calculated by multiplying these with the provided ratio value. This will offset each side of the frame, maintaining the center of the frame at the same location. This outset ratio helps mitigate async scroll blanking and focus handling on host platforms. Changelog: [Internal] Differential Revision: D82684027
1 parent e97ef8f commit 2008354

21 files changed

+153
-22
lines changed

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

1010
/**
@@ -462,6 +462,12 @@ public object ReactNativeFeatureFlags {
462462
@JvmStatic
463463
public fun useTurboModules(): Boolean = accessor.useTurboModules()
464464

465+
/**
466+
* Outset the culling context frame with the provided ratio. The culling context frame size will be outset by width * ratio on the left and right, and height * ratio on the top and bottom.
467+
*/
468+
@JvmStatic
469+
public fun viewCullingOutsetRatio(): Double = accessor.viewCullingOutsetRatio()
470+
465471
/**
466472
* Sets a hysteresis window for transition between prerender and hidden modes.
467473
*/

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

1010
/**
@@ -92,6 +92,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
9292
private var useShadowNodeStateOnCloneCache: Boolean? = null
9393
private var useTurboModuleInteropCache: Boolean? = null
9494
private var useTurboModulesCache: Boolean? = null
95+
private var viewCullingOutsetRatioCache: Double? = null
9596
private var virtualViewHysteresisRatioCache: Double? = null
9697
private var virtualViewPrerenderRatioCache: Double? = null
9798

@@ -743,6 +744,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
743744
return cached
744745
}
745746

747+
override fun viewCullingOutsetRatio(): Double {
748+
var cached = viewCullingOutsetRatioCache
749+
if (cached == null) {
750+
cached = ReactNativeFeatureFlagsCxxInterop.viewCullingOutsetRatio()
751+
viewCullingOutsetRatioCache = cached
752+
}
753+
return cached
754+
}
755+
746756
override fun virtualViewHysteresisRatio(): Double {
747757
var cached = virtualViewHysteresisRatioCache
748758
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<<d73f5df2130479a4cd1000dc76b15d1b>>
7+
* @generated SignedSource<<51ec412a57101b8b7a9df10f36283742>>
88
*/
99

1010
/**
@@ -172,6 +172,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
172172

173173
@DoNotStrip @JvmStatic public external fun useTurboModules(): Boolean
174174

175+
@DoNotStrip @JvmStatic public external fun viewCullingOutsetRatio(): Double
176+
175177
@DoNotStrip @JvmStatic public external fun virtualViewHysteresisRatio(): Double
176178

177179
@DoNotStrip @JvmStatic public external fun virtualViewPrerenderRatio(): Double

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

1010
/**
@@ -167,6 +167,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
167167

168168
override fun useTurboModules(): Boolean = false
169169

170+
override fun viewCullingOutsetRatio(): Double = 0.0
171+
170172
override fun virtualViewHysteresisRatio(): Double = 0.0
171173

172174
override fun virtualViewPrerenderRatio(): Double = 5.0

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<<962c60d1761b0a1f4945b44767aa7b02>>
7+
* @generated SignedSource<<d836e598d64595a21f242170a53181b3>>
88
*/
99

1010
/**
@@ -96,6 +96,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
9696
private var useShadowNodeStateOnCloneCache: Boolean? = null
9797
private var useTurboModuleInteropCache: Boolean? = null
9898
private var useTurboModulesCache: Boolean? = null
99+
private var viewCullingOutsetRatioCache: Double? = null
99100
private var virtualViewHysteresisRatioCache: Double? = null
100101
private var virtualViewPrerenderRatioCache: Double? = null
101102

@@ -819,6 +820,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
819820
return cached
820821
}
821822

823+
override fun viewCullingOutsetRatio(): Double {
824+
var cached = viewCullingOutsetRatioCache
825+
if (cached == null) {
826+
cached = currentProvider.viewCullingOutsetRatio()
827+
accessedFeatureFlags.add("viewCullingOutsetRatio")
828+
viewCullingOutsetRatioCache = cached
829+
}
830+
return cached
831+
}
832+
822833
override fun virtualViewHysteresisRatio(): Double {
823834
var cached = virtualViewHysteresisRatioCache
824835
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<<f9f3dee3dde2f7f6f851ce4525a4ebec>>
7+
* @generated SignedSource<<db9622c511f6b3feaaf27af598ba5a9b>>
88
*/
99

1010
/**
@@ -167,6 +167,8 @@ public interface ReactNativeFeatureFlagsProvider {
167167

168168
@DoNotStrip public fun useTurboModules(): Boolean
169169

170+
@DoNotStrip public fun viewCullingOutsetRatio(): Double
171+
170172
@DoNotStrip public fun virtualViewHysteresisRatio(): Double
171173

172174
@DoNotStrip public fun virtualViewPrerenderRatio(): Double

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<<de817bc06ae5ef584db08d6a094c9d03>>
7+
* @generated SignedSource<<34f7ed1d7261a13732b6bcdf111f7031>>
88
*/
99

1010
/**
@@ -471,6 +471,12 @@ class ReactNativeFeatureFlagsJavaProvider
471471
return method(javaProvider_);
472472
}
473473

474+
double viewCullingOutsetRatio() override {
475+
static const auto method =
476+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jdouble()>("viewCullingOutsetRatio");
477+
return method(javaProvider_);
478+
}
479+
474480
double virtualViewHysteresisRatio() override {
475481
static const auto method =
476482
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jdouble()>("virtualViewHysteresisRatio");
@@ -847,6 +853,11 @@ bool JReactNativeFeatureFlagsCxxInterop::useTurboModules(
847853
return ReactNativeFeatureFlags::useTurboModules();
848854
}
849855

856+
double JReactNativeFeatureFlagsCxxInterop::viewCullingOutsetRatio(
857+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
858+
return ReactNativeFeatureFlags::viewCullingOutsetRatio();
859+
}
860+
850861
double JReactNativeFeatureFlagsCxxInterop::virtualViewHysteresisRatio(
851862
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
852863
return ReactNativeFeatureFlags::virtualViewHysteresisRatio();
@@ -1104,6 +1115,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
11041115
makeNativeMethod(
11051116
"useTurboModules",
11061117
JReactNativeFeatureFlagsCxxInterop::useTurboModules),
1118+
makeNativeMethod(
1119+
"viewCullingOutsetRatio",
1120+
JReactNativeFeatureFlagsCxxInterop::viewCullingOutsetRatio),
11071121
makeNativeMethod(
11081122
"virtualViewHysteresisRatio",
11091123
JReactNativeFeatureFlagsCxxInterop::virtualViewHysteresisRatio),

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

1010
/**
@@ -246,6 +246,9 @@ class JReactNativeFeatureFlagsCxxInterop
246246
static bool useTurboModules(
247247
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
248248

249+
static double viewCullingOutsetRatio(
250+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
251+
249252
static double virtualViewHysteresisRatio(
250253
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
251254

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<<50f81f60d4c2d2e08fde98f4a2d841ea>>
7+
* @generated SignedSource<<74870f8b253c1d7e7ba1f05d031ae7d0>>
88
*/
99

1010
/**
@@ -314,6 +314,10 @@ bool ReactNativeFeatureFlags::useTurboModules() {
314314
return getAccessor().useTurboModules();
315315
}
316316

317+
double ReactNativeFeatureFlags::viewCullingOutsetRatio() {
318+
return getAccessor().viewCullingOutsetRatio();
319+
}
320+
317321
double ReactNativeFeatureFlags::virtualViewHysteresisRatio() {
318322
return getAccessor().virtualViewHysteresisRatio();
319323
}

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<<3446eebd26c1142fd78cd5413771569d>>
7+
* @generated SignedSource<<8f0bbf7e7e6f45b4790fffeeb22ee124>>
88
*/
99

1010
/**
@@ -399,6 +399,11 @@ class ReactNativeFeatureFlags {
399399
*/
400400
RN_EXPORT static bool useTurboModules();
401401

402+
/**
403+
* Outset the culling context frame with the provided ratio. The culling context frame size will be outset by width * ratio on the left and right, and height * ratio on the top and bottom.
404+
*/
405+
RN_EXPORT static double viewCullingOutsetRatio();
406+
402407
/**
403408
* Sets a hysteresis window for transition between prerender and hidden modes.
404409
*/

0 commit comments

Comments
 (0)