Measure text at the window's density on Android (#59087)

Summary:
Pull Request resolved: https://github.com/react/react-native/pull/59087

`DisplayMetricsHolder.initDisplayMetrics()` takes `density` and `densityDpi` from `Display.getRealMetrics()`, the physical display, but `scaledDensity` from the window's configuration. When a window renders at a different density than its display, text is measured at one density and laid out at the other, so it comes out clipped or oversized.

With the new `useWindowDensityForDisplayMetricsAndroid` feature flag on, the screen metrics keep the window's `density` and `densityDpi` and take only the screen size from the display. The flag is off by default, so nothing changes for apps that don't turn it on. `initDisplayMetrics` reads the flag only when the window's density differs from the display's, so in the usual case it doesn't touch feature flags, and apps can still set their flags after calling it.

**How to use:** return `true` from your app's feature flag overrides, before React Native starts:

```
override fun useWindowDensityForDisplayMetricsAndroid(): Boolean = true
```

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D123975873

fbshipit-source-id: 50b15ce70d993eba6e5ac8d065218ff9bcc6a12c
This commit is contained in:
Bruno Ramos authored and meta-codesync[bot] committed 2026-10-14 16:11:56 -07:00
1 parent e619ebd3a1
commit 43c9b88d5c
23 files changed
+208 -24

No files matched your search

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<eb0bafceba60cb439a4be3d68b890725>>
* @generated SignedSource<<cfa7aa53731059247d858fd8fb6e914b>>
*/
/**
@@ -564,6 +564,12 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun useTurboModuleInterop(): Boolean = accessor.useTurboModuleInterop()
/**
* Keeps the window density in the screen display metrics instead of the physical display density, so text is measured at the density the window renders at.
*/
@JvmStatic
public fun useWindowDensityForDisplayMetricsAndroid(): Boolean = accessor.useWindowDensityForDisplayMetricsAndroid()
/**
* 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.
*/
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<0107593110db613063b6f4ceb50d8e58>>
* @generated SignedSource<<71d0554dc45df7d5365f81b7ec8c3d5b>>
*/
/**
@@ -109,6 +109,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
private var useSharedAnimatedBackendCache: Boolean? = null
private var useTraitHiddenOnAndroidCache: Boolean? = null
private var useTurboModuleInteropCache: Boolean? = null
private var useWindowDensityForDisplayMetricsAndroidCache: Boolean? = null
private var viewCullingOutsetRatioCache: Double? = null
private var viewTransitionEnabledCache: Boolean? = null
private var viewTransitionUseHardwareBitmapAndroidCache: Boolean? = null
@@ -915,6 +916,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
return cached
}
override fun useWindowDensityForDisplayMetricsAndroid(): Boolean {
var cached = useWindowDensityForDisplayMetricsAndroidCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.useWindowDensityForDisplayMetricsAndroid()
useWindowDensityForDisplayMetricsAndroidCache = cached
}
return cached
}
override fun viewCullingOutsetRatio(): Double {
var cached = viewCullingOutsetRatioCache
if (cached == null) {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<fa0374808e3cbe7122ca993780c0b627>>
* @generated SignedSource<<312cec99bd429d22e25f4e82d7fc4ee7>>
*/
/**
@@ -206,6 +206,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
@DoNotStrip @JvmStatic public external fun useTurboModuleInterop(): Boolean
@DoNotStrip @JvmStatic public external fun useWindowDensityForDisplayMetricsAndroid(): Boolean
@DoNotStrip @JvmStatic public external fun viewCullingOutsetRatio(): Double
@DoNotStrip @JvmStatic public external fun viewTransitionEnabled(): Boolean
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<768077a22c110aa98ab02bc96eec695b>>
* @generated SignedSource<<669f16e131d4a5ddc026ffecc6893575>>
*/
/**
@@ -201,6 +201,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
override fun useTurboModuleInterop(): Boolean = false
override fun useWindowDensityForDisplayMetricsAndroid(): Boolean = false
override fun viewCullingOutsetRatio(): Double = 0.0
override fun viewTransitionEnabled(): Boolean = false
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<86ebc7307e7ebe2023e909a868ed3117>>
* @generated SignedSource<<ee4c0f9c1e7c6af3b0d15948ebc519b3>>
*/
/**
@@ -113,6 +113,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
private var useSharedAnimatedBackendCache: Boolean? = null
private var useTraitHiddenOnAndroidCache: Boolean? = null
private var useTurboModuleInteropCache: Boolean? = null
private var useWindowDensityForDisplayMetricsAndroidCache: Boolean? = null
private var viewCullingOutsetRatioCache: Double? = null
private var viewTransitionEnabledCache: Boolean? = null
private var viewTransitionUseHardwareBitmapAndroidCache: Boolean? = null
@@ -1008,6 +1009,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
return cached
}
override fun useWindowDensityForDisplayMetricsAndroid(): Boolean {
var cached = useWindowDensityForDisplayMetricsAndroidCache
if (cached == null) {
cached = currentProvider.useWindowDensityForDisplayMetricsAndroid()
accessedFeatureFlags.add("useWindowDensityForDisplayMetricsAndroid")
useWindowDensityForDisplayMetricsAndroidCache = cached
}
return cached
}
override fun viewCullingOutsetRatio(): Double {
var cached = viewCullingOutsetRatioCache
if (cached == null) {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<c83fba10dc6f7d596e3bcd9725c64e6e>>
* @generated SignedSource<<18267103ef4f3eb22f23a15b808528c2>>
*/
/**
@@ -201,6 +201,8 @@ public interface ReactNativeFeatureFlagsProvider {
@DoNotStrip public fun useTurboModuleInterop(): Boolean
@DoNotStrip public fun useWindowDensityForDisplayMetricsAndroid(): Boolean
@DoNotStrip public fun viewCullingOutsetRatio(): Double
@DoNotStrip public fun viewTransitionEnabled(): Boolean
@@ -14,6 +14,7 @@ import android.util.DisplayMetrics
import android.view.WindowManager
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
import com.facebook.react.uimanager.PixelUtil.pxToDp
/**
@@ -61,6 +62,13 @@ public object DisplayMetricsHolder {
// Non-visual contexts (e.g. Application) may throw on API 30+.
// Falls back to resource display metrics copied via setTo() above.
}
if (
displayMetrics.densityDpi != screenDisplayMetrics.densityDpi &&
ReactNativeFeatureFlags.useWindowDensityForDisplayMetricsAndroid()
) {
screenDisplayMetrics.density = displayMetrics.density
screenDisplayMetrics.densityDpi = displayMetrics.densityDpi
}
// Preserve fontScale from the configuration because getRealMetrics() returns
// physical display metrics without the system font scale setting.
// This is needed for proper text scaling when fontScale < 1.0
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<200266835197634d13de07182d80a2c1>>
* @generated SignedSource<<568d6e4175fb51e09bc3d4441ffa9741>>
*/
/**
@@ -573,6 +573,12 @@ class ReactNativeFeatureFlagsJavaProvider
return method(javaProvider_);
}
bool useWindowDensityForDisplayMetricsAndroid() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("useWindowDensityForDisplayMetricsAndroid");
return method(javaProvider_);
}
double viewCullingOutsetRatio() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jdouble()>("viewCullingOutsetRatio");
@@ -1046,6 +1052,11 @@ bool JReactNativeFeatureFlagsCxxInterop::useTurboModuleInterop(
return ReactNativeFeatureFlags::useTurboModuleInterop();
}
bool JReactNativeFeatureFlagsCxxInterop::useWindowDensityForDisplayMetricsAndroid(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::useWindowDensityForDisplayMetricsAndroid();
}
double JReactNativeFeatureFlagsCxxInterop::viewCullingOutsetRatio(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::viewCullingOutsetRatio();
@@ -1364,6 +1375,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"useTurboModuleInterop",
JReactNativeFeatureFlagsCxxInterop::useTurboModuleInterop),
makeNativeMethod(
"useWindowDensityForDisplayMetricsAndroid",
JReactNativeFeatureFlagsCxxInterop::useWindowDensityForDisplayMetricsAndroid),
makeNativeMethod(
"viewCullingOutsetRatio",
JReactNativeFeatureFlagsCxxInterop::viewCullingOutsetRatio),
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<13aa248dae556b06b31c25a28e448460>>
* @generated SignedSource<<2e0f936c003aafc456ab3f960ca4b2f3>>
*/
/**
@@ -297,6 +297,9 @@ class JReactNativeFeatureFlagsCxxInterop
static bool useTurboModuleInterop(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool useWindowDensityForDisplayMetricsAndroid(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static double viewCullingOutsetRatio(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
@@ -17,6 +17,9 @@ import android.view.View
import android.view.Window
import android.view.WindowInsets
import androidx.annotation.RequiresApi
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsDefaults
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsForTests
import com.facebook.testutils.shadows.ShadowNativeLoader
import com.facebook.testutils.shadows.ShadowNativeMap
import com.facebook.testutils.shadows.ShadowReadableNativeMap
@@ -52,6 +55,7 @@ class DisplayMetricsHolderTest {
@Before
fun setUp() {
ReactNativeFeatureFlagsForTests.setUp()
context = RuntimeEnvironment.getApplication()
displayMetrics = context.resources.displayMetrics
DisplayMetricsHolder.setScreenDisplayMetrics(null)
@@ -60,6 +64,7 @@ class DisplayMetricsHolderTest {
@After
fun tearDown() {
DisplayMetricsHolder.setScreenDisplayMetrics(null)
ReactNativeFeatureFlags.dangerouslyReset()
}
@Test(expected = IllegalStateException::class)
@@ -142,6 +147,41 @@ class DisplayMetricsHolderTest {
assertThat(screenMetrics.scaledDensity).isEqualTo(customScaledDensity)
}
@Test
fun initDisplayMetrics_withWindowDensityFlag_usesTheWindowDensity() {
overrideWindowDensityFlag(true)
setWindowDensityTo400Dpi()
DisplayMetricsHolder.initDisplayMetrics(context)
val screenMetrics = DisplayMetricsHolder.getScreenDisplayMetrics()
assertThat(screenMetrics.density).isEqualTo(2.5f)
assertThat(screenMetrics.densityDpi).isEqualTo(DisplayMetrics.DENSITY_400)
assertThat(PixelUtil.toDIPFromPixel(PixelUtil.toPixelFromSP(16f))).isEqualTo(16f)
}
@Test
fun initDisplayMetrics_withoutWindowDensityFlag_usesTheDisplayDensity() {
DisplayMetricsHolder.initDisplayMetrics(context)
val displayDensityDpi = DisplayMetricsHolder.getScreenDisplayMetrics().densityDpi
overrideWindowDensityFlag(false)
setWindowDensityTo400Dpi()
DisplayMetricsHolder.initDisplayMetrics(context)
assertThat(DisplayMetricsHolder.getScreenDisplayMetrics().densityDpi)
.isEqualTo(displayDensityDpi)
.isNotEqualTo(DisplayMetrics.DENSITY_400)
}
@Test
fun initDisplayMetrics_withMatchingDensities_doesNotReadFeatureFlags() {
DisplayMetricsHolder.initDisplayMetrics(context)
overrideWindowDensityFlag(true)
assertThat(ReactNativeFeatureFlags.useWindowDensityForDisplayMetricsAndroid()).isTrue()
}
@Test
fun initDisplayMetrics_doesNotCrashWithNonVisualContext() {
val mockContext: Context = mock()
@@ -164,4 +204,19 @@ class DisplayMetricsHolderTest {
// Metrics should still be set from resource display metrics
assertThat(DisplayMetricsHolder.getScreenDisplayMetrics()).isNotNull()
}
private fun overrideWindowDensityFlag(enabled: Boolean) {
ReactNativeFeatureFlags.override(
object : ReactNativeFeatureFlagsDefaults() {
override fun useWindowDensityForDisplayMetricsAndroid(): Boolean = enabled
},
)
}
private fun setWindowDensityTo400Dpi() {
val resourceMetrics = context.resources.displayMetrics
resourceMetrics.density = 2.5f
resourceMetrics.densityDpi = DisplayMetrics.DENSITY_400
resourceMetrics.scaledDensity = 2.5f
}
}
@@ -14,6 +14,8 @@ import android.content.Context
import android.content.res.Configuration
import android.content.res.Resources
import android.util.DisplayMetrics
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsForTests
import com.facebook.testutils.shadows.ShadowNativeLoader
import com.facebook.testutils.shadows.ShadowSoLoader
import kotlin.math.abs
@@ -36,6 +38,7 @@ class PixelUtilTest {
@Before
fun setUp() {
ReactNativeFeatureFlagsForTests.setUp()
context = RuntimeEnvironment.getApplication()
DisplayMetricsHolder.setScreenDisplayMetrics(null)
}
@@ -43,6 +46,7 @@ class PixelUtilTest {
@After
fun tearDown() {
DisplayMetricsHolder.setScreenDisplayMetrics(null)
ReactNativeFeatureFlags.dangerouslyReset()
}
@Test
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<fc4b67b43c846eac0085ed4a5528a170>>
* @generated SignedSource<<f90778065a9a5f48383dd9b4606bd862>>
*/
/**
@@ -382,6 +382,10 @@ bool ReactNativeFeatureFlags::useTurboModuleInterop() {
return getAccessor().useTurboModuleInterop();
}
bool ReactNativeFeatureFlags::useWindowDensityForDisplayMetricsAndroid() {
return getAccessor().useWindowDensityForDisplayMetricsAndroid();
}
double ReactNativeFeatureFlags::viewCullingOutsetRatio() {
return getAccessor().viewCullingOutsetRatio();
}
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<1a9a8a587b477b6aa0d3aa57e30272c2>>
* @generated SignedSource<<62dbb584d6aaf595314636a81346e3e5>>
*/
/**
@@ -486,6 +486,11 @@ class ReactNativeFeatureFlags {
*/
RN_EXPORT static bool useTurboModuleInterop();
/**
* Keeps the window density in the screen display metrics instead of the physical display density, so text is measured at the density the window renders at.
*/
RN_EXPORT static bool useWindowDensityForDisplayMetricsAndroid();
/**
* 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.
*/
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<fe7bc7ae7a968cb99713b7ba353328bc>>
* @generated SignedSource<<ba48094e66da5ce008c4d1b093549ef0>>
*/
/**
@@ -1631,6 +1631,24 @@ bool ReactNativeFeatureFlagsAccessor::useTurboModuleInterop() {
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::useWindowDensityForDisplayMetricsAndroid() {
auto flagValue = useWindowDensityForDisplayMetricsAndroid_.load();
if (!flagValue.has_value()) {
// This block is not exclusive but it is not necessary.
// If multiple threads try to initialize the feature flag, we would only
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(89, "useWindowDensityForDisplayMetricsAndroid");
flagValue = currentProvider_->useWindowDensityForDisplayMetricsAndroid();
useWindowDensityForDisplayMetricsAndroid_ = flagValue;
}
return flagValue.value();
}
double ReactNativeFeatureFlagsAccessor::viewCullingOutsetRatio() {
auto flagValue = viewCullingOutsetRatio_.load();
@@ -1640,7 +1658,7 @@ double ReactNativeFeatureFlagsAccessor::viewCullingOutsetRatio() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(89, "viewCullingOutsetRatio");
markFlagAsAccessed(90, "viewCullingOutsetRatio");
flagValue = currentProvider_->viewCullingOutsetRatio();
viewCullingOutsetRatio_ = flagValue;
@@ -1658,7 +1676,7 @@ bool ReactNativeFeatureFlagsAccessor::viewTransitionEnabled() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(90, "viewTransitionEnabled");
markFlagAsAccessed(91, "viewTransitionEnabled");
flagValue = currentProvider_->viewTransitionEnabled();
viewTransitionEnabled_ = flagValue;
@@ -1676,7 +1694,7 @@ bool ReactNativeFeatureFlagsAccessor::viewTransitionUseHardwareBitmapAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(91, "viewTransitionUseHardwareBitmapAndroid");
markFlagAsAccessed(92, "viewTransitionUseHardwareBitmapAndroid");
flagValue = currentProvider_->viewTransitionUseHardwareBitmapAndroid();
viewTransitionUseHardwareBitmapAndroid_ = flagValue;
@@ -1694,7 +1712,7 @@ double ReactNativeFeatureFlagsAccessor::virtualViewPrerenderRatio() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(92, "virtualViewPrerenderRatio");
markFlagAsAccessed(93, "virtualViewPrerenderRatio");
flagValue = currentProvider_->virtualViewPrerenderRatio();
virtualViewPrerenderRatio_ = flagValue;
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<486b4aac1c83d8bced6a3f5393a03756>>
* @generated SignedSource<<074e6ad1d773f289f93ce1d16656ec6e>>
*/
/**
@@ -123,6 +123,7 @@ class ReactNativeFeatureFlagsAccessor {
bool useSharedAnimatedBackend();
bool useTraitHiddenOnAndroid();
bool useTurboModuleInterop();
bool useWindowDensityForDisplayMetricsAndroid();
double viewCullingOutsetRatio();
bool viewTransitionEnabled();
bool viewTransitionUseHardwareBitmapAndroid();
@@ -138,7 +139,7 @@ class ReactNativeFeatureFlagsAccessor {
std::unique_ptr<ReactNativeFeatureFlagsProvider> currentProvider_;
bool wasOverridden_;
std::array<std::atomic<const char*>, 93> accessedFeatureFlags_;
std::array<std::atomic<const char*>, 94> accessedFeatureFlags_;
std::atomic<std::optional<bool>> commonTestFlag_;
std::atomic<std::optional<bool>> cdpInteractionMetricsEnabled_;
@@ -229,6 +230,7 @@ class ReactNativeFeatureFlagsAccessor {
std::atomic<std::optional<bool>> useSharedAnimatedBackend_;
std::atomic<std::optional<bool>> useTraitHiddenOnAndroid_;
std::atomic<std::optional<bool>> useTurboModuleInterop_;
std::atomic<std::optional<bool>> useWindowDensityForDisplayMetricsAndroid_;
std::atomic<std::optional<double>> viewCullingOutsetRatio_;
std::atomic<std::optional<bool>> viewTransitionEnabled_;
std::atomic<std::optional<bool>> viewTransitionUseHardwareBitmapAndroid_;
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<af191519eab7fb22b70d11fd73afba4f>>
* @generated SignedSource<<52db1adfed5fd99e4ca145b50dc413a0>>
*/
/**
@@ -385,6 +385,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
return false;
}
bool useWindowDensityForDisplayMetricsAndroid() override {
return false;
}
double viewCullingOutsetRatio() override {
return 0.0;
}
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<2a5ad585617d77035a43b255d3e30eb3>>
* @generated SignedSource<<8d27c5f3feb4c8000922012882701b7e>>
*/
/**
@@ -848,6 +848,15 @@ class ReactNativeFeatureFlagsDynamicProvider : public ReactNativeFeatureFlagsDef
return ReactNativeFeatureFlagsDefaults::useTurboModuleInterop();
}
bool useWindowDensityForDisplayMetricsAndroid() override {
auto value = values_["useWindowDensityForDisplayMetricsAndroid"];
if (!value.isNull()) {
return value.getBool();
}
return ReactNativeFeatureFlagsDefaults::useWindowDensityForDisplayMetricsAndroid();
}
double viewCullingOutsetRatio() override {
auto value = values_["viewCullingOutsetRatio"];
if (!value.isNull()) {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<8daa3cebd554caa27139d96604fcc368>>
* @generated SignedSource<<7e5839223cfce81a42708f876c4c77ee>>
*/
/**
@@ -116,6 +116,7 @@ class ReactNativeFeatureFlagsProvider {
virtual bool useSharedAnimatedBackend() = 0;
virtual bool useTraitHiddenOnAndroid() = 0;
virtual bool useTurboModuleInterop() = 0;
virtual bool useWindowDensityForDisplayMetricsAndroid() = 0;
virtual double viewCullingOutsetRatio() = 0;
virtual bool viewTransitionEnabled() = 0;
virtual bool viewTransitionUseHardwareBitmapAndroid() = 0;
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<00cccf7098052c51f5855949375ea0f9>>
* @generated SignedSource<<cd218b84f81cb128569351055afcceeb>>
*/
/**
@@ -489,6 +489,11 @@ bool NativeReactNativeFeatureFlags::useTurboModuleInterop(
return ReactNativeFeatureFlags::useTurboModuleInterop();
}
bool NativeReactNativeFeatureFlags::useWindowDensityForDisplayMetricsAndroid(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::useWindowDensityForDisplayMetricsAndroid();
}
double NativeReactNativeFeatureFlags::viewCullingOutsetRatio(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::viewCullingOutsetRatio();
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<fe6f53b8f98378abeae064b70681ed39>>
* @generated SignedSource<<84b944e162fc53799326c584a5edd17d>>
*/
/**
@@ -216,6 +216,8 @@ class NativeReactNativeFeatureFlags
bool useTurboModuleInterop(jsi::Runtime& runtime);
bool useWindowDensityForDisplayMetricsAndroid(jsi::Runtime& runtime);
double viewCullingOutsetRatio(jsi::Runtime& runtime);
bool viewTransitionEnabled(jsi::Runtime& runtime);
@@ -1005,6 +1005,17 @@ const definitions: FeatureFlagDefinitions = {
},
ossReleaseStage: 'canary',
},
useWindowDensityForDisplayMetricsAndroid: {
defaultValue: false,
metadata: {
dateAdded: '2026-10-11',
description:
'Keeps the window density in the screen display metrics instead of the physical display density, so text is measured at the density the window renders at.',
expectedReleaseValue: true,
purpose: 'experimentation',
},
ossReleaseStage: 'none',
},
viewCullingOutsetRatio: {
defaultValue: 0,
metadata: {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<c5edfa3b739746e892eb0d681c631016>>
* @generated SignedSource<<4eb26b4190d023d26a50f54b6e3ea5eb>>
* @flow strict
* @noformat
*/
@@ -139,6 +139,7 @@ export type ReactNativeFeatureFlags = Readonly<{
useSharedAnimatedBackend: Getter<boolean>,
useTraitHiddenOnAndroid: Getter<boolean>,
useTurboModuleInterop: Getter<boolean>,
useWindowDensityForDisplayMetricsAndroid: Getter<boolean>,
viewCullingOutsetRatio: Getter<number>,
viewTransitionEnabled: Getter<boolean>,
viewTransitionUseHardwareBitmapAndroid: Getter<boolean>,
@@ -580,6 +581,10 @@ export const useTraitHiddenOnAndroid: Getter<boolean> = createNativeFlagGetter('
* In Bridgeless mode, should legacy NativeModules use the TurboModule system?
*/
export const useTurboModuleInterop: Getter<boolean> = createNativeFlagGetter('useTurboModuleInterop', false);
/**
* Keeps the window density in the screen display metrics instead of the physical display density, so text is measured at the density the window renders at.
*/
export const useWindowDensityForDisplayMetricsAndroid: Getter<boolean> = createNativeFlagGetter('useWindowDensityForDisplayMetricsAndroid', false);
/**
* 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.
*/
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<3972c873d92371d3dc67eaa3a6217427>>
* @generated SignedSource<<40cc7b87d7658fb5aa3d33f468eff3fc>>
* @flow strict
* @noformat
*/
@@ -114,6 +114,7 @@ export interface Spec extends TurboModule {
readonly useSharedAnimatedBackend?: () => boolean;
readonly useTraitHiddenOnAndroid?: () => boolean;
readonly useTurboModuleInterop?: () => boolean;
readonly useWindowDensityForDisplayMetricsAndroid?: () => boolean;
readonly viewCullingOutsetRatio?: () => number;
readonly viewTransitionEnabled?: () => boolean;
readonly viewTransitionUseHardwareBitmapAndroid?: () => boolean;