Skip to content

Commit 99604b0

Browse files
Nick Lefeverfacebook-github-bot
authored andcommitted
Add support for global view culling outset ratio setting (#53845)
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 5735bb5 commit 99604b0

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<<6b632ac7553ae149fa42a67efde5acfa>>
7+
* @generated SignedSource<<f707e26d09b6f7962ec97296a1a215b6>>
88
*/
99

1010
/**
@@ -468,6 +468,12 @@ public object ReactNativeFeatureFlags {
468468
@JvmStatic
469469
public fun useTurboModules(): Boolean = accessor.useTurboModules()
470470

471+
/**
472+
* 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.
473+
*/
474+
@JvmStatic
475+
public fun viewCullingOutsetRatio(): Double = accessor.viewCullingOutsetRatio()
476+
471477
/**
472478
* Sets a hysteresis window for transition between prerender and hidden modes.
473479
*/

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

1010
/**
@@ -93,6 +93,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
9393
private var useShadowNodeStateOnCloneCache: Boolean? = null
9494
private var useTurboModuleInteropCache: Boolean? = null
9595
private var useTurboModulesCache: Boolean? = null
96+
private var viewCullingOutsetRatioCache: Double? = null
9697
private var virtualViewHysteresisRatioCache: Double? = null
9798
private var virtualViewPrerenderRatioCache: Double? = null
9899

@@ -753,6 +754,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
753754
return cached
754755
}
755756

757+
override fun viewCullingOutsetRatio(): Double {
758+
var cached = viewCullingOutsetRatioCache
759+
if (cached == null) {
760+
cached = ReactNativeFeatureFlagsCxxInterop.viewCullingOutsetRatio()
761+
viewCullingOutsetRatioCache = cached
762+
}
763+
return cached
764+
}
765+
756766
override fun virtualViewHysteresisRatio(): Double {
757767
var cached = virtualViewHysteresisRatioCache
758768
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<<26dce1945df5641ab84cbca9eaf2b10f>>
7+
* @generated SignedSource<<3254fef626b10ef21d8d9ee1bdbb1880>>
88
*/
99

1010
/**
@@ -174,6 +174,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
174174

175175
@DoNotStrip @JvmStatic public external fun useTurboModules(): Boolean
176176

177+
@DoNotStrip @JvmStatic public external fun viewCullingOutsetRatio(): Double
178+
177179
@DoNotStrip @JvmStatic public external fun virtualViewHysteresisRatio(): Double
178180

179181
@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<<11051ece1b61fd4bf4ca003a3b7fc4f9>>
7+
* @generated SignedSource<<9f7eb1bb5e24fd8ee87accf60209cce3>>
88
*/
99

1010
/**
@@ -169,6 +169,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
169169

170170
override fun useTurboModules(): Boolean = false
171171

172+
override fun viewCullingOutsetRatio(): Double = 0.0
173+
172174
override fun virtualViewHysteresisRatio(): Double = 0.0
173175

174176
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<<66fa583c37021750123a483ab0ccb030>>
7+
* @generated SignedSource<<9e6e04ca37edd1ad9265b74e251ff4de>>
88
*/
99

1010
/**
@@ -97,6 +97,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
9797
private var useShadowNodeStateOnCloneCache: Boolean? = null
9898
private var useTurboModuleInteropCache: Boolean? = null
9999
private var useTurboModulesCache: Boolean? = null
100+
private var viewCullingOutsetRatioCache: Double? = null
100101
private var virtualViewHysteresisRatioCache: Double? = null
101102
private var virtualViewPrerenderRatioCache: Double? = null
102103

@@ -830,6 +831,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
830831
return cached
831832
}
832833

834+
override fun viewCullingOutsetRatio(): Double {
835+
var cached = viewCullingOutsetRatioCache
836+
if (cached == null) {
837+
cached = currentProvider.viewCullingOutsetRatio()
838+
accessedFeatureFlags.add("viewCullingOutsetRatio")
839+
viewCullingOutsetRatioCache = cached
840+
}
841+
return cached
842+
}
843+
833844
override fun virtualViewHysteresisRatio(): Double {
834845
var cached = virtualViewHysteresisRatioCache
835846
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<<f26998daf87c8b90c2ec822c8316b134>>
7+
* @generated SignedSource<<65e895433fc609bd7c2b5d7faa507f46>>
88
*/
99

1010
/**
@@ -169,6 +169,8 @@ public interface ReactNativeFeatureFlagsProvider {
169169

170170
@DoNotStrip public fun useTurboModules(): Boolean
171171

172+
@DoNotStrip public fun viewCullingOutsetRatio(): Double
173+
172174
@DoNotStrip public fun virtualViewHysteresisRatio(): Double
173175

174176
@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<<8e1821e9a153a4b725890cb4a7f262ee>>
7+
* @generated SignedSource<<7a0a26494846d6b4881bea01beabb9d6>>
88
*/
99

1010
/**
@@ -477,6 +477,12 @@ class ReactNativeFeatureFlagsJavaProvider
477477
return method(javaProvider_);
478478
}
479479

480+
double viewCullingOutsetRatio() override {
481+
static const auto method =
482+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jdouble()>("viewCullingOutsetRatio");
483+
return method(javaProvider_);
484+
}
485+
480486
double virtualViewHysteresisRatio() override {
481487
static const auto method =
482488
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jdouble()>("virtualViewHysteresisRatio");
@@ -858,6 +864,11 @@ bool JReactNativeFeatureFlagsCxxInterop::useTurboModules(
858864
return ReactNativeFeatureFlags::useTurboModules();
859865
}
860866

867+
double JReactNativeFeatureFlagsCxxInterop::viewCullingOutsetRatio(
868+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
869+
return ReactNativeFeatureFlags::viewCullingOutsetRatio();
870+
}
871+
861872
double JReactNativeFeatureFlagsCxxInterop::virtualViewHysteresisRatio(
862873
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
863874
return ReactNativeFeatureFlags::virtualViewHysteresisRatio();
@@ -1118,6 +1129,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
11181129
makeNativeMethod(
11191130
"useTurboModules",
11201131
JReactNativeFeatureFlagsCxxInterop::useTurboModules),
1132+
makeNativeMethod(
1133+
"viewCullingOutsetRatio",
1134+
JReactNativeFeatureFlagsCxxInterop::viewCullingOutsetRatio),
11211135
makeNativeMethod(
11221136
"virtualViewHysteresisRatio",
11231137
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<<5be2ec52bda638a1eac837c402149b9f>>
7+
* @generated SignedSource<<ad2e322ef177ced7eb07412552596a5b>>
88
*/
99

1010
/**
@@ -249,6 +249,9 @@ class JReactNativeFeatureFlagsCxxInterop
249249
static bool useTurboModules(
250250
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
251251

252+
static double viewCullingOutsetRatio(
253+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
254+
252255
static double virtualViewHysteresisRatio(
253256
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
254257

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

1010
/**
@@ -318,6 +318,10 @@ bool ReactNativeFeatureFlags::useTurboModules() {
318318
return getAccessor().useTurboModules();
319319
}
320320

321+
double ReactNativeFeatureFlags::viewCullingOutsetRatio() {
322+
return getAccessor().viewCullingOutsetRatio();
323+
}
324+
321325
double ReactNativeFeatureFlags::virtualViewHysteresisRatio() {
322326
return getAccessor().virtualViewHysteresisRatio();
323327
}

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<<bad2aadea64eba29430e9c93c169d621>>
7+
* @generated SignedSource<<559a8be87c24238e70fceded8ac962a0>>
88
*/
99

1010
/**
@@ -404,6 +404,11 @@ class ReactNativeFeatureFlags {
404404
*/
405405
RN_EXPORT static bool useTurboModules();
406406

407+
/**
408+
* 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.
409+
*/
410+
RN_EXPORT static double viewCullingOutsetRatio();
411+
407412
/**
408413
* Sets a hysteresis window for transition between prerender and hidden modes.
409414
*/

0 commit comments

Comments
 (0)