Skip to content

Commit a4b0d64

Browse files
NickGerlemanfacebook-github-bot
authored andcommitted
ReactNativeFeatureFlags.enableAndroidTextMeasurementOptimizations() (#52384)
Summary: Pull Request resolved: #52384 Adds the feature flag, controlling multiple optimizations up the stack. Changelog: [Internal] Reviewed By: lenaic Differential Revision: D77622983 fbshipit-source-id: 16500e8557d36db627c62faa511eeb4c73dc7484
1 parent 22b8b53 commit a4b0d64

20 files changed

Lines changed: 202 additions & 68 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<<8e198a0a6b815c6ff06766301b1c0e87>>
7+
* @generated SignedSource<<a4a7c66f4603fc6a56018aba12c942ee>>
88
*/
99

1010
/**
@@ -84,6 +84,12 @@ public object ReactNativeFeatureFlags {
8484
@JvmStatic
8585
public fun enableAccumulatedUpdatesInRawPropsAndroid(): Boolean = accessor.enableAccumulatedUpdatesInRawPropsAndroid()
8686

87+
/**
88+
* Enables various optimizations throughout the path of measuring text on Android.
89+
*/
90+
@JvmStatic
91+
public fun enableAndroidTextMeasurementOptimizations(): Boolean = accessor.enableAndroidTextMeasurementOptimizations()
92+
8793
/**
8894
* Feature flag to enable the new bridgeless architecture. Note: Enabling this will force enable the following flags: `useTurboModules` & `enableFabricRenderer`.
8995
*/

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<<8ede08c653b07258ad95f5893d16a6d6>>
7+
* @generated SignedSource<<9b6d83d6ea0acbc13bce19d869699079>>
88
*/
99

1010
/**
@@ -29,6 +29,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
2929
private var disableTextLayoutManagerCacheAndroidCache: Boolean? = null
3030
private var enableAccessibilityOrderCache: Boolean? = null
3131
private var enableAccumulatedUpdatesInRawPropsAndroidCache: Boolean? = null
32+
private var enableAndroidTextMeasurementOptimizationsCache: Boolean? = null
3233
private var enableBridgelessArchitectureCache: Boolean? = null
3334
private var enableCppPropsIteratorSetterCache: Boolean? = null
3435
private var enableCustomFocusSearchOnClippedElementsAndroidCache: Boolean? = null
@@ -159,6 +160,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
159160
return cached
160161
}
161162

163+
override fun enableAndroidTextMeasurementOptimizations(): Boolean {
164+
var cached = enableAndroidTextMeasurementOptimizationsCache
165+
if (cached == null) {
166+
cached = ReactNativeFeatureFlagsCxxInterop.enableAndroidTextMeasurementOptimizations()
167+
enableAndroidTextMeasurementOptimizationsCache = cached
168+
}
169+
return cached
170+
}
171+
162172
override fun enableBridgelessArchitecture(): Boolean {
163173
var cached = enableBridgelessArchitectureCache
164174
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<<e7f6a38d4aac049d010b77766962a0c0>>
7+
* @generated SignedSource<<75760457dea789ab0951d3a22be3341c>>
88
*/
99

1010
/**
@@ -46,6 +46,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
4646

4747
@DoNotStrip @JvmStatic public external fun enableAccumulatedUpdatesInRawPropsAndroid(): Boolean
4848

49+
@DoNotStrip @JvmStatic public external fun enableAndroidTextMeasurementOptimizations(): Boolean
50+
4951
@DoNotStrip @JvmStatic public external fun enableBridgelessArchitecture(): Boolean
5052

5153
@DoNotStrip @JvmStatic public external fun enableCppPropsIteratorSetter(): 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<<0c189c58b7c2bc0bc3360339c740ccc1>>
7+
* @generated SignedSource<<48fa8921cc2947a713974c9926e1d806>>
88
*/
99

1010
/**
@@ -41,6 +41,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
4141

4242
override fun enableAccumulatedUpdatesInRawPropsAndroid(): Boolean = false
4343

44+
override fun enableAndroidTextMeasurementOptimizations(): Boolean = false
45+
4446
override fun enableBridgelessArchitecture(): Boolean = false
4547

4648
override fun enableCppPropsIteratorSetter(): 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<<d8ee60bb432749b5f9f3999c550dd9bf>>
7+
* @generated SignedSource<<356261385b837def94ac5a4ca7ffd05d>>
88
*/
99

1010
/**
@@ -33,6 +33,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
3333
private var disableTextLayoutManagerCacheAndroidCache: Boolean? = null
3434
private var enableAccessibilityOrderCache: Boolean? = null
3535
private var enableAccumulatedUpdatesInRawPropsAndroidCache: Boolean? = null
36+
private var enableAndroidTextMeasurementOptimizationsCache: Boolean? = null
3637
private var enableBridgelessArchitectureCache: Boolean? = null
3738
private var enableCppPropsIteratorSetterCache: Boolean? = null
3839
private var enableCustomFocusSearchOnClippedElementsAndroidCache: Boolean? = null
@@ -172,6 +173,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
172173
return cached
173174
}
174175

176+
override fun enableAndroidTextMeasurementOptimizations(): Boolean {
177+
var cached = enableAndroidTextMeasurementOptimizationsCache
178+
if (cached == null) {
179+
cached = currentProvider.enableAndroidTextMeasurementOptimizations()
180+
accessedFeatureFlags.add("enableAndroidTextMeasurementOptimizations")
181+
enableAndroidTextMeasurementOptimizationsCache = cached
182+
}
183+
return cached
184+
}
185+
175186
override fun enableBridgelessArchitecture(): Boolean {
176187
var cached = enableBridgelessArchitectureCache
177188
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<<d01ababf59389626a95bdcc17df095d4>>
7+
* @generated SignedSource<<8abf9bfb81265ae0c840457eb6c199bd>>
88
*/
99

1010
/**
@@ -41,6 +41,8 @@ public interface ReactNativeFeatureFlagsProvider {
4141

4242
@DoNotStrip public fun enableAccumulatedUpdatesInRawPropsAndroid(): Boolean
4343

44+
@DoNotStrip public fun enableAndroidTextMeasurementOptimizations(): Boolean
45+
4446
@DoNotStrip public fun enableBridgelessArchitecture(): Boolean
4547

4648
@DoNotStrip public fun enableCppPropsIteratorSetter(): 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<<5374ad1a8a8e0be6f88982093a597591>>
7+
* @generated SignedSource<<5effd7d4ac8034424144ea68c82b61a7>>
88
*/
99

1010
/**
@@ -93,6 +93,12 @@ class ReactNativeFeatureFlagsJavaProvider
9393
return method(javaProvider_);
9494
}
9595

96+
bool enableAndroidTextMeasurementOptimizations() override {
97+
static const auto method =
98+
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableAndroidTextMeasurementOptimizations");
99+
return method(javaProvider_);
100+
}
101+
96102
bool enableBridgelessArchitecture() override {
97103
static const auto method =
98104
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableBridgelessArchitecture");
@@ -430,6 +436,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableAccumulatedUpdatesInRawPropsAndro
430436
return ReactNativeFeatureFlags::enableAccumulatedUpdatesInRawPropsAndroid();
431437
}
432438

439+
bool JReactNativeFeatureFlagsCxxInterop::enableAndroidTextMeasurementOptimizations(
440+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
441+
return ReactNativeFeatureFlags::enableAndroidTextMeasurementOptimizations();
442+
}
443+
433444
bool JReactNativeFeatureFlagsCxxInterop::enableBridgelessArchitecture(
434445
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
435446
return ReactNativeFeatureFlags::enableBridgelessArchitecture();
@@ -728,6 +739,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
728739
makeNativeMethod(
729740
"enableAccumulatedUpdatesInRawPropsAndroid",
730741
JReactNativeFeatureFlagsCxxInterop::enableAccumulatedUpdatesInRawPropsAndroid),
742+
makeNativeMethod(
743+
"enableAndroidTextMeasurementOptimizations",
744+
JReactNativeFeatureFlagsCxxInterop::enableAndroidTextMeasurementOptimizations),
731745
makeNativeMethod(
732746
"enableBridgelessArchitecture",
733747
JReactNativeFeatureFlagsCxxInterop::enableBridgelessArchitecture),

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

1010
/**
@@ -57,6 +57,9 @@ class JReactNativeFeatureFlagsCxxInterop
5757
static bool enableAccumulatedUpdatesInRawPropsAndroid(
5858
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
5959

60+
static bool enableAndroidTextMeasurementOptimizations(
61+
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
62+
6063
static bool enableBridgelessArchitecture(
6164
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
6265

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<<6d4c9a910861484f6fc5db643e729c05>>
7+
* @generated SignedSource<<20c25bf5541e37cd5c918684925726df>>
88
*/
99

1010
/**
@@ -62,6 +62,10 @@ bool ReactNativeFeatureFlags::enableAccumulatedUpdatesInRawPropsAndroid() {
6262
return getAccessor().enableAccumulatedUpdatesInRawPropsAndroid();
6363
}
6464

65+
bool ReactNativeFeatureFlags::enableAndroidTextMeasurementOptimizations() {
66+
return getAccessor().enableAndroidTextMeasurementOptimizations();
67+
}
68+
6569
bool ReactNativeFeatureFlags::enableBridgelessArchitecture() {
6670
return getAccessor().enableBridgelessArchitecture();
6771
}

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<<2faa0be111dc874380e977b74aa36254>>
7+
* @generated SignedSource<<20809734183aa7bfd7aad9b8d01ea080>>
88
*/
99

1010
/**
@@ -84,6 +84,11 @@ class ReactNativeFeatureFlags {
8484
*/
8585
RN_EXPORT static bool enableAccumulatedUpdatesInRawPropsAndroid();
8686

87+
/**
88+
* Enables various optimizations throughout the path of measuring text on Android.
89+
*/
90+
RN_EXPORT static bool enableAndroidTextMeasurementOptimizations();
91+
8792
/**
8893
* Feature flag to enable the new bridgeless architecture. Note: Enabling this will force enable the following flags: `useTurboModules` & `enableFabricRenderer`.
8994
*/

0 commit comments

Comments
 (0)