diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index db61fe34fd02..b9968b4d54e9 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -94,6 +94,7 @@ import com.facebook.react.uimanager.events.RCTEventEmitter; import com.facebook.react.uimanager.events.SynchronousEventReceiver; import com.facebook.react.views.text.PreparedLayout; +import com.facebook.react.views.text.PreparedLayoutCache; import com.facebook.react.views.text.ReactTextViewManager; import com.facebook.react.views.text.ReactTextViewManagerCallback; import com.facebook.react.views.text.ReactTypefaceUtils; @@ -186,6 +187,7 @@ public class FabricUIManager private final ViewManagerRegistry mViewManagerRegistry; private final TextEffectRegistry mTextEffectRegistry = new TextEffectRegistry(); + private volatile @Nullable PreparedLayoutCache mPreparedLayoutCache; private final BatchEventDispatchedListener mBatchEventDispatchedListener; @@ -504,6 +506,10 @@ public void invalidate() { mDestroyed = true; // Before the teardown hooks below, which can throw and would otherwise leak the context. TextLayoutManager.destroySpannableCache(mReactApplicationContext); + PreparedLayoutCache preparedLayoutCache = mPreparedLayoutCache; + if (preparedLayoutCache != null) { + preparedLayoutCache.clear(); + } mEventDispatcher.removeBatchEventDispatchedListener(mBatchEventDispatchedListener); mEventDispatcher.invalidate(); @@ -748,6 +754,77 @@ public float[] measurePreparedLayout( getYogaMeasureMode(minHeight, maxHeight)); } + private PreparedLayoutCache getOrCreatePreparedLayoutCache() { + PreparedLayoutCache cache = mPreparedLayoutCache; + if (cache == null) { + synchronized (this) { + cache = mPreparedLayoutCache; + if (cache == null) { + cache = + new PreparedLayoutCache( + Math.max(0, (int) ReactNativeFeatureFlags.preparedTextCacheSize())); + mPreparedLayoutCache = cache; + } + } + } + return cache; + } + + @AnyThread + @ThreadConfined(ANY) + private PreparedLayout prepareTextLayoutAndCache( + long cacheId, + ReadableMapBuffer attributedString, + ReadableMapBuffer paragraphAttributes, + float minWidth, + float maxWidth, + float minHeight, + float maxHeight, + @Nullable int[] reactTags) { + PreparedLayout preparedLayout = + prepareTextLayout( + attributedString, paragraphAttributes, minWidth, maxWidth, minHeight, maxHeight); + getOrCreatePreparedLayoutCache().put(cacheId, preparedLayout); + return reactTags != null ? preparedLayout.withReactTags(reactTags) : preparedLayout; + } + + @AnyThread + @ThreadConfined(ANY) + private float[] prepareAndMeasureTextLayoutToCache( + long cacheId, + ReadableMapBuffer attributedString, + ReadableMapBuffer paragraphAttributes, + float minWidth, + float maxWidth, + float minHeight, + float maxHeight) { + PreparedLayout preparedLayout = + prepareTextLayout( + attributedString, paragraphAttributes, minWidth, maxWidth, minHeight, maxHeight); + getOrCreatePreparedLayoutCache().put(cacheId, preparedLayout); + return measurePreparedLayout(preparedLayout, minWidth, maxWidth, minHeight, maxHeight); + } + + @AnyThread + @ThreadConfined(ANY) + private @Nullable float[] measurePreparedLayoutById( + long cacheId, float minWidth, float maxWidth, float minHeight, float maxHeight) { + PreparedLayoutCache cache = mPreparedLayoutCache; + PreparedLayout preparedLayout = cache != null ? cache.get(cacheId) : null; + if (preparedLayout == null) { + return null; + } + return measurePreparedLayout(preparedLayout, minWidth, maxWidth, minHeight, maxHeight); + } + + @AnyThread + @ThreadConfined(ANY) + private @Nullable PreparedLayout getPreparedLayoutFromCache( + long cacheId, @Nullable int[] reactTags) { + PreparedLayoutCache cache = mPreparedLayoutCache; + return cache != null ? cache.getWithReactTags(cacheId, reactTags) : null; + } + @UnstableReactNativeAPI public TextEffectRegistry getTextEffectRegistry() { return mTextEffectRegistry; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt index e7e5c56cae6a..98d5900df522 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt @@ -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<<3c2494d2482efe3dded741dd746d4309>> + * @generated SignedSource<> */ /** @@ -48,6 +48,12 @@ public object ReactNativeFeatureFlags { @JvmStatic public fun cxxNativeAnimatedEnabled(): Boolean = accessor.cxxNativeAnimatedEnabled() + /** + * When enabled, cached PreparedLayout objects are shared across ParagraphShadowNodes without creating new JNI global references for differing React tags; new React tags are attached via a local JNI reference on mount. + */ + @JvmStatic + public fun deferPreparedLayoutReactTagsToMountAndroid(): Boolean = accessor.deferPreparedLayoutReactTagsToMountAndroid() + /** * When enabled, iOS TextInput applies edits that JS transforms (e.g. maxLength truncation) incrementally after the UIKit text change delegate call returns, avoiding synchronous text and selection rewrites that can deadlock UIKeyboardTaskQueue. */ @@ -582,6 +588,12 @@ public object ReactNativeFeatureFlags { @JvmStatic public fun useFabricInterop(): Boolean = accessor.useFabricInterop() + /** + * When enabled, PreparedLayout instances are cached in a bounded Java-side LRU cache keyed by opaque ID rather than held via JNI global references from C++. + */ + @JvmStatic + public fun useJavaPreparedLayoutCacheAndroid(): Boolean = accessor.useJavaPreparedLayoutCacheAndroid() + /** * When enabled, the native view configs are used in bridgeless mode. */ diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt index 8e2279ee89db..c307a9b2c969 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt @@ -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<<14682373d73e29327ec3c39882e59af5>> + * @generated SignedSource<> */ /** @@ -23,6 +23,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces private var commonTestFlagCache: Boolean? = null private var cdpInteractionMetricsEnabledCache: Boolean? = null private var cxxNativeAnimatedEnabledCache: Boolean? = null + private var deferPreparedLayoutReactTagsToMountAndroidCache: Boolean? = null private var deferTextInputTruncationIOSCache: Boolean? = null private var disableEarlyViewCommandExecutionCache: Boolean? = null private var disableIdleEventDispatchFrameCallbackRearmAndroidCache: Boolean? = null @@ -112,6 +113,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces private var updateRuntimeShadowNodeReferencesOnCommitThreadCache: Boolean? = null private var useAlwaysAvailableJSErrorHandlingCache: Boolean? = null private var useFabricInteropCache: Boolean? = null + private var useJavaPreparedLayoutCacheAndroidCache: Boolean? = null private var useNativeViewConfigsInBridgelessModeCache: Boolean? = null private var useNestedScrollViewAndroidCache: Boolean? = null private var useSharedAnimatedBackendCache: Boolean? = null @@ -150,6 +152,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces return cached } + override fun deferPreparedLayoutReactTagsToMountAndroid(): Boolean { + var cached = deferPreparedLayoutReactTagsToMountAndroidCache + if (cached == null) { + cached = ReactNativeFeatureFlagsCxxInterop.deferPreparedLayoutReactTagsToMountAndroid() + deferPreparedLayoutReactTagsToMountAndroidCache = cached + } + return cached + } + override fun deferTextInputTruncationIOS(): Boolean { var cached = deferTextInputTruncationIOSCache if (cached == null) { @@ -951,6 +962,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces return cached } + override fun useJavaPreparedLayoutCacheAndroid(): Boolean { + var cached = useJavaPreparedLayoutCacheAndroidCache + if (cached == null) { + cached = ReactNativeFeatureFlagsCxxInterop.useJavaPreparedLayoutCacheAndroid() + useJavaPreparedLayoutCacheAndroidCache = cached + } + return cached + } + override fun useNativeViewConfigsInBridgelessMode(): Boolean { var cached = useNativeViewConfigsInBridgelessModeCache if (cached == null) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt index e0845de7ca7f..a36264510c57 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt @@ -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<> + * @generated SignedSource<> */ /** @@ -34,6 +34,8 @@ public object ReactNativeFeatureFlagsCxxInterop { @DoNotStrip @JvmStatic public external fun cxxNativeAnimatedEnabled(): Boolean + @DoNotStrip @JvmStatic public external fun deferPreparedLayoutReactTagsToMountAndroid(): Boolean + @DoNotStrip @JvmStatic public external fun deferTextInputTruncationIOS(): Boolean @DoNotStrip @JvmStatic public external fun disableEarlyViewCommandExecution(): Boolean @@ -212,6 +214,8 @@ public object ReactNativeFeatureFlagsCxxInterop { @DoNotStrip @JvmStatic public external fun useFabricInterop(): Boolean + @DoNotStrip @JvmStatic public external fun useJavaPreparedLayoutCacheAndroid(): Boolean + @DoNotStrip @JvmStatic public external fun useNativeViewConfigsInBridgelessMode(): Boolean @DoNotStrip @JvmStatic public external fun useNestedScrollViewAndroid(): Boolean diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt index 0a9a0d6c6c38..3ea91f61c78f 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt @@ -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<> + * @generated SignedSource<> */ /** @@ -29,6 +29,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi override fun cxxNativeAnimatedEnabled(): Boolean = true + override fun deferPreparedLayoutReactTagsToMountAndroid(): Boolean = false + override fun deferTextInputTruncationIOS(): Boolean = false override fun disableEarlyViewCommandExecution(): Boolean = false @@ -207,6 +209,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi override fun useFabricInterop(): Boolean = true + override fun useJavaPreparedLayoutCacheAndroid(): Boolean = false + override fun useNativeViewConfigsInBridgelessMode(): Boolean = false override fun useNestedScrollViewAndroid(): Boolean = false diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt index ac0ca1339195..b8387191a1fa 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt @@ -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<> + * @generated SignedSource<<74fa4b118323e2c7bc3906229e1036a8>> */ /** @@ -27,6 +27,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc private var commonTestFlagCache: Boolean? = null private var cdpInteractionMetricsEnabledCache: Boolean? = null private var cxxNativeAnimatedEnabledCache: Boolean? = null + private var deferPreparedLayoutReactTagsToMountAndroidCache: Boolean? = null private var deferTextInputTruncationIOSCache: Boolean? = null private var disableEarlyViewCommandExecutionCache: Boolean? = null private var disableIdleEventDispatchFrameCallbackRearmAndroidCache: Boolean? = null @@ -116,6 +117,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc private var updateRuntimeShadowNodeReferencesOnCommitThreadCache: Boolean? = null private var useAlwaysAvailableJSErrorHandlingCache: Boolean? = null private var useFabricInteropCache: Boolean? = null + private var useJavaPreparedLayoutCacheAndroidCache: Boolean? = null private var useNativeViewConfigsInBridgelessModeCache: Boolean? = null private var useNestedScrollViewAndroidCache: Boolean? = null private var useSharedAnimatedBackendCache: Boolean? = null @@ -157,6 +159,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc return cached } + override fun deferPreparedLayoutReactTagsToMountAndroid(): Boolean { + var cached = deferPreparedLayoutReactTagsToMountAndroidCache + if (cached == null) { + cached = currentProvider.deferPreparedLayoutReactTagsToMountAndroid() + accessedFeatureFlags.add("deferPreparedLayoutReactTagsToMountAndroid") + deferPreparedLayoutReactTagsToMountAndroidCache = cached + } + return cached + } + override fun deferTextInputTruncationIOS(): Boolean { var cached = deferTextInputTruncationIOSCache if (cached == null) { @@ -1047,6 +1059,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc return cached } + override fun useJavaPreparedLayoutCacheAndroid(): Boolean { + var cached = useJavaPreparedLayoutCacheAndroidCache + if (cached == null) { + cached = currentProvider.useJavaPreparedLayoutCacheAndroid() + accessedFeatureFlags.add("useJavaPreparedLayoutCacheAndroid") + useJavaPreparedLayoutCacheAndroidCache = cached + } + return cached + } + override fun useNativeViewConfigsInBridgelessMode(): Boolean { var cached = useNativeViewConfigsInBridgelessModeCache if (cached == null) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt index daad224eaa7a..28744971b997 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt @@ -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<> + * @generated SignedSource<> */ /** @@ -29,6 +29,8 @@ public interface ReactNativeFeatureFlagsProvider { @DoNotStrip public fun cxxNativeAnimatedEnabled(): Boolean + @DoNotStrip public fun deferPreparedLayoutReactTagsToMountAndroid(): Boolean + @DoNotStrip public fun deferTextInputTruncationIOS(): Boolean @DoNotStrip public fun disableEarlyViewCommandExecution(): Boolean @@ -207,6 +209,8 @@ public interface ReactNativeFeatureFlagsProvider { @DoNotStrip public fun useFabricInterop(): Boolean + @DoNotStrip public fun useJavaPreparedLayoutCacheAndroid(): Boolean + @DoNotStrip public fun useNativeViewConfigsInBridgelessMode(): Boolean @DoNotStrip public fun useNestedScrollViewAndroid(): Boolean diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/PreparedLayout.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/PreparedLayout.kt index 7c7eea253254..8feebd1e27b9 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/PreparedLayout.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/PreparedLayout.kt @@ -28,4 +28,21 @@ internal class PreparedLayout( // (truncated) text; every caller must consciously supply the complete string so accessibility // and view-hierarchy consumers never fall back to the truncated text. val sourceText: CharSequence, -) +) { + @DoNotStrip + fun withReactTags(reactTags: IntArray): PreparedLayout { + if (this.reactTags.contentEquals(reactTags)) { + return this + } + return PreparedLayout( + layout, + maximumNumberOfLines, + verticalOffset, + reactTags, + textBreakStrategy, + justificationMode, + baseTextAttributes, + sourceText, + ) + } +} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/PreparedLayoutCache.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/PreparedLayoutCache.kt new file mode 100644 index 000000000000..8b7aae9df2cf --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/PreparedLayoutCache.kt @@ -0,0 +1,29 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.react.views.text + +import android.util.LruCache + +internal class PreparedLayoutCache(maxSize: Int) { + private val cache: LruCache? = if (maxSize > 0) LruCache(maxSize) else null + + fun put(cacheId: Long, layout: PreparedLayout) { + cache?.put(cacheId, layout) + } + + fun get(cacheId: Long): PreparedLayout? = cache?.get(cacheId) + + fun getWithReactTags(cacheId: Long, reactTags: IntArray?): PreparedLayout? { + val preparedLayout = get(cacheId) ?: return null + return if (reactTags != null) preparedLayout.withReactTags(reactTags) else preparedLayout + } + + fun clear() { + cache?.evictAll() + } +} diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp index 5a3ad88020ac..4659335aa4e8 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp @@ -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<> + * @generated SignedSource<<672cd6287a41bdc76e2404ae61defd55>> */ /** @@ -57,6 +57,12 @@ class ReactNativeFeatureFlagsJavaProvider return method(javaProvider_); } + bool deferPreparedLayoutReactTagsToMountAndroid() override { + static const auto method = + getReactNativeFeatureFlagsProviderJavaClass()->getMethod("deferPreparedLayoutReactTagsToMountAndroid"); + return method(javaProvider_); + } + bool deferTextInputTruncationIOS() override { static const auto method = getReactNativeFeatureFlagsProviderJavaClass()->getMethod("deferTextInputTruncationIOS"); @@ -591,6 +597,12 @@ class ReactNativeFeatureFlagsJavaProvider return method(javaProvider_); } + bool useJavaPreparedLayoutCacheAndroid() override { + static const auto method = + getReactNativeFeatureFlagsProviderJavaClass()->getMethod("useJavaPreparedLayoutCacheAndroid"); + return method(javaProvider_); + } + bool useNativeViewConfigsInBridgelessMode() override { static const auto method = getReactNativeFeatureFlagsProviderJavaClass()->getMethod("useNativeViewConfigsInBridgelessMode"); @@ -670,6 +682,11 @@ bool JReactNativeFeatureFlagsCxxInterop::cxxNativeAnimatedEnabled( return ReactNativeFeatureFlags::cxxNativeAnimatedEnabled(); } +bool JReactNativeFeatureFlagsCxxInterop::deferPreparedLayoutReactTagsToMountAndroid( + facebook::jni::alias_ref /*unused*/) { + return ReactNativeFeatureFlags::deferPreparedLayoutReactTagsToMountAndroid(); +} + bool JReactNativeFeatureFlagsCxxInterop::deferTextInputTruncationIOS( facebook::jni::alias_ref /*unused*/) { return ReactNativeFeatureFlags::deferTextInputTruncationIOS(); @@ -1115,6 +1132,11 @@ bool JReactNativeFeatureFlagsCxxInterop::useFabricInterop( return ReactNativeFeatureFlags::useFabricInterop(); } +bool JReactNativeFeatureFlagsCxxInterop::useJavaPreparedLayoutCacheAndroid( + facebook::jni::alias_ref /*unused*/) { + return ReactNativeFeatureFlags::useJavaPreparedLayoutCacheAndroid(); +} + bool JReactNativeFeatureFlagsCxxInterop::useNativeViewConfigsInBridgelessMode( facebook::jni::alias_ref /*unused*/) { return ReactNativeFeatureFlags::useNativeViewConfigsInBridgelessMode(); @@ -1205,6 +1227,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() { makeNativeMethod( "cxxNativeAnimatedEnabled", JReactNativeFeatureFlagsCxxInterop::cxxNativeAnimatedEnabled), + makeNativeMethod( + "deferPreparedLayoutReactTagsToMountAndroid", + JReactNativeFeatureFlagsCxxInterop::deferPreparedLayoutReactTagsToMountAndroid), makeNativeMethod( "deferTextInputTruncationIOS", JReactNativeFeatureFlagsCxxInterop::deferTextInputTruncationIOS), @@ -1472,6 +1497,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() { makeNativeMethod( "useFabricInterop", JReactNativeFeatureFlagsCxxInterop::useFabricInterop), + makeNativeMethod( + "useJavaPreparedLayoutCacheAndroid", + JReactNativeFeatureFlagsCxxInterop::useJavaPreparedLayoutCacheAndroid), makeNativeMethod( "useNativeViewConfigsInBridgelessMode", JReactNativeFeatureFlagsCxxInterop::useNativeViewConfigsInBridgelessMode), diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h index 9fb787e56443..19f967d62f48 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h +++ b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h @@ -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<<61b3685bb0e41ac62de7cef4927b577c>> + * @generated SignedSource<> */ /** @@ -39,6 +39,9 @@ class JReactNativeFeatureFlagsCxxInterop static bool cxxNativeAnimatedEnabled( facebook::jni::alias_ref); + static bool deferPreparedLayoutReactTagsToMountAndroid( + facebook::jni::alias_ref); + static bool deferTextInputTruncationIOS( facebook::jni::alias_ref); @@ -306,6 +309,9 @@ class JReactNativeFeatureFlagsCxxInterop static bool useFabricInterop( facebook::jni::alias_ref); + static bool useJavaPreparedLayoutCacheAndroid( + facebook::jni::alias_ref); + static bool useNativeViewConfigsInBridgelessMode( facebook::jni::alias_ref); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/PreparedLayoutCacheTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/PreparedLayoutCacheTest.kt new file mode 100644 index 000000000000..f7ea30693872 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/PreparedLayoutCacheTest.kt @@ -0,0 +1,108 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.react.views.text + +import android.annotation.SuppressLint +import android.graphics.text.LineBreakConfig +import android.text.Layout +import android.text.SpannableString +import android.text.TextPaint +import com.facebook.react.common.annotations.UnstableReactNativeAPI +import com.facebook.react.common.mapbuffer.WritableMapBuffer +import com.facebook.yoga.YogaMeasureMode +import org.assertj.core.api.Assertions.assertThat +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.annotation.Config +import org.robolectric.annotation.GraphicsMode + +@OptIn(UnstableReactNativeAPI::class) +@RunWith(RobolectricTestRunner::class) +@SuppressLint("NewApi") +@Config(sdk = [34]) +@GraphicsMode(GraphicsMode.Mode.NATIVE) +class PreparedLayoutCacheTest { + + private fun createPreparedLayout(text: String, reactTags: IntArray): PreparedLayout { + val spannable = SpannableString(text) + val layout = + TextLayoutManager.createLayout( + spannable, + null, + 200f, + YogaMeasureMode.AT_MOST, + true, + Layout.BREAK_STRATEGY_SIMPLE, + Layout.HYPHENATION_FREQUENCY_NONE, + LineBreakConfig.LINE_BREAK_STYLE_NONE, + LineBreakConfig.LINE_BREAK_WORD_STYLE_NONE, + Layout.Alignment.ALIGN_NORMAL, + Layout.JUSTIFICATION_MODE_NONE, + null, + -1, + TextPaint().apply { textSize = 14f }, + ) + return PreparedLayout( + layout = layout, + maximumNumberOfLines = -1, + verticalOffset = 0f, + reactTags = reactTags, + textBreakStrategy = Layout.BREAK_STRATEGY_SIMPLE, + justificationMode = Layout.JUSTIFICATION_MODE_NONE, + baseTextAttributes = TextAttributeProps.fromMapBuffer(WritableMapBuffer()), + sourceText = spannable, + ) + } + + @Test + fun putAndGet_evictsLeastRecentlyUsedEntries() { + val cache = PreparedLayoutCache(maxSize = 2) + val first = createPreparedLayout("first", intArrayOf(1)) + val second = createPreparedLayout("second", intArrayOf(2)) + val third = createPreparedLayout("third", intArrayOf(3)) + + cache.put(1L, first) + cache.put(2L, second) + assertThat(cache.get(1L)).isSameAs(first) + + cache.put(3L, third) + assertThat(cache.get(1L)).isSameAs(first) + assertThat(cache.get(2L)).isNull() + assertThat(cache.get(3L)).isSameAs(third) + } + + @Test + fun maxSizeZero_disablesCachingWithoutThrowing() { + val cache = PreparedLayoutCache(maxSize = 0) + val first = createPreparedLayout("first", intArrayOf(1)) + + cache.put(1L, first) + assertThat(cache.get(1L)).isNull() + assertThat(cache.getWithReactTags(1L, intArrayOf(1))).isNull() + } + + @Test + fun getWithReactTags_reusesOrClonesWrapperAndHandlesEviction() { + val cache = PreparedLayoutCache(maxSize = 2) + val original = createPreparedLayout("hello", intArrayOf(10, 20)) + cache.put(1L, original) + + assertThat(cache.getWithReactTags(1L, null)).isSameAs(original) + assertThat(cache.getWithReactTags(1L, intArrayOf(10, 20))).isSameAs(original) + + val rebound = cache.getWithReactTags(1L, intArrayOf(30, 40)) + assertThat(rebound).isNotNull() + assertThat(rebound).isNotSameAs(original) + assertThat(rebound!!.layout).isSameAs(original.layout) + assertThat(rebound.reactTags).containsExactly(30, 40) + + cache.clear() + assertThat(cache.getWithReactTags(1L, intArrayOf(30, 40))).isNull() + } +} diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/PreparedLayoutTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/PreparedLayoutTest.kt new file mode 100644 index 000000000000..ff9fca4b2033 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/views/text/PreparedLayoutTest.kt @@ -0,0 +1,89 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.react.views.text + +import android.annotation.SuppressLint +import android.graphics.text.LineBreakConfig +import android.text.Layout +import android.text.SpannableString +import android.text.TextPaint +import com.facebook.react.common.annotations.UnstableReactNativeAPI +import com.facebook.react.common.mapbuffer.WritableMapBuffer +import com.facebook.yoga.YogaMeasureMode +import org.assertj.core.api.Assertions.assertThat +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.annotation.Config +import org.robolectric.annotation.GraphicsMode + +@OptIn(UnstableReactNativeAPI::class) +@RunWith(RobolectricTestRunner::class) +@SuppressLint("NewApi") +@Config(sdk = [34]) +@GraphicsMode(GraphicsMode.Mode.NATIVE) +class PreparedLayoutTest { + + private fun createPreparedLayout(reactTags: IntArray): PreparedLayout { + val text = SpannableString("Hello world") + val layout = + TextLayoutManager.createLayout( + text, + null, + 200f, + YogaMeasureMode.AT_MOST, + true, + Layout.BREAK_STRATEGY_SIMPLE, + Layout.HYPHENATION_FREQUENCY_NONE, + LineBreakConfig.LINE_BREAK_STYLE_NONE, + LineBreakConfig.LINE_BREAK_WORD_STYLE_NONE, + Layout.Alignment.ALIGN_NORMAL, + Layout.JUSTIFICATION_MODE_NONE, + null, + -1, + TextPaint().apply { textSize = 14f }, + ) + return PreparedLayout( + layout = layout, + maximumNumberOfLines = 2, + verticalOffset = 1.5f, + reactTags = reactTags, + textBreakStrategy = Layout.BREAK_STRATEGY_SIMPLE, + justificationMode = Layout.JUSTIFICATION_MODE_NONE, + baseTextAttributes = TextAttributeProps.fromMapBuffer(WritableMapBuffer()), + sourceText = text, + ) + } + + @Test + fun `withReactTags returns same instance when tags match`() { + val original = createPreparedLayout(intArrayOf(10, 20)) + + val reused = original.withReactTags(intArrayOf(10, 20)) + + assertThat(reused).isSameAs(original) + } + + @Test + fun `withReactTags clones wrapper sharing layout when tags differ`() { + val original = createPreparedLayout(intArrayOf(10, 20)) + + val reused = original.withReactTags(intArrayOf(30, 40)) + + assertThat(reused).isNotSameAs(original) + assertThat(reused.layout).isSameAs(original.layout) + assertThat(reused.sourceText).isSameAs(original.sourceText) + assertThat(reused.baseTextAttributes).isSameAs(original.baseTextAttributes) + assertThat(reused.maximumNumberOfLines).isEqualTo(original.maximumNumberOfLines) + assertThat(reused.verticalOffset).isEqualTo(original.verticalOffset) + assertThat(reused.textBreakStrategy).isEqualTo(original.textBreakStrategy) + assertThat(reused.justificationMode).isEqualTo(original.justificationMode) + assertThat(reused.reactTags).containsExactly(30, 40) + assertThat(original.reactTags).containsExactly(10, 20) + } +} diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp index b947a4aa1770..9fd736857f52 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp @@ -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<<81cd9f64e05f8e5d59eb79c0ecfeda86>> + * @generated SignedSource<> */ /** @@ -38,6 +38,10 @@ bool ReactNativeFeatureFlags::cxxNativeAnimatedEnabled() { return getAccessor().cxxNativeAnimatedEnabled(); } +bool ReactNativeFeatureFlags::deferPreparedLayoutReactTagsToMountAndroid() { + return getAccessor().deferPreparedLayoutReactTagsToMountAndroid(); +} + bool ReactNativeFeatureFlags::deferTextInputTruncationIOS() { return getAccessor().deferTextInputTruncationIOS(); } @@ -394,6 +398,10 @@ bool ReactNativeFeatureFlags::useFabricInterop() { return getAccessor().useFabricInterop(); } +bool ReactNativeFeatureFlags::useJavaPreparedLayoutCacheAndroid() { + return getAccessor().useJavaPreparedLayoutCacheAndroid(); +} + bool ReactNativeFeatureFlags::useNativeViewConfigsInBridgelessMode() { return getAccessor().useNativeViewConfigsInBridgelessMode(); } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h index 0e2f3f6949c2..885ee8361df1 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h @@ -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<<8dca25c44632b8b14c5cdac75a3f36f8>> + * @generated SignedSource<<1215f223cfa673af6d65893d5921c5c1>> */ /** @@ -56,6 +56,11 @@ class ReactNativeFeatureFlags { */ RN_EXPORT static bool cxxNativeAnimatedEnabled(); + /** + * When enabled, cached PreparedLayout objects are shared across ParagraphShadowNodes without creating new JNI global references for differing React tags; new React tags are attached via a local JNI reference on mount. + */ + RN_EXPORT static bool deferPreparedLayoutReactTagsToMountAndroid(); + /** * When enabled, iOS TextInput applies edits that JS transforms (e.g. maxLength truncation) incrementally after the UIKit text change delegate call returns, avoiding synchronous text and selection rewrites that can deadlock UIKeyboardTaskQueue. */ @@ -501,6 +506,11 @@ class ReactNativeFeatureFlags { */ RN_EXPORT static bool useFabricInterop(); + /** + * When enabled, PreparedLayout instances are cached in a bounded Java-side LRU cache keyed by opaque ID rather than held via JNI global references from C++. + */ + RN_EXPORT static bool useJavaPreparedLayoutCacheAndroid(); + /** * When enabled, the native view configs are used in bridgeless mode. */ diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp index 7e23ac64cfbc..7b86cc9339df 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp @@ -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<<37e16ca8358e1b9639551d31ecea5372>> + * @generated SignedSource<<7cba79b4253191d1deaf97b3547305f4>> */ /** @@ -83,6 +83,24 @@ bool ReactNativeFeatureFlagsAccessor::cxxNativeAnimatedEnabled() { return flagValue.value(); } +bool ReactNativeFeatureFlagsAccessor::deferPreparedLayoutReactTagsToMountAndroid() { + auto flagValue = deferPreparedLayoutReactTagsToMountAndroid_.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(3, "deferPreparedLayoutReactTagsToMountAndroid"); + + flagValue = currentProvider_->deferPreparedLayoutReactTagsToMountAndroid(); + deferPreparedLayoutReactTagsToMountAndroid_ = flagValue; + } + + return flagValue.value(); +} + bool ReactNativeFeatureFlagsAccessor::deferTextInputTruncationIOS() { auto flagValue = deferTextInputTruncationIOS_.load(); @@ -92,7 +110,7 @@ bool ReactNativeFeatureFlagsAccessor::deferTextInputTruncationIOS() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(3, "deferTextInputTruncationIOS"); + markFlagAsAccessed(4, "deferTextInputTruncationIOS"); flagValue = currentProvider_->deferTextInputTruncationIOS(); deferTextInputTruncationIOS_ = flagValue; @@ -110,7 +128,7 @@ bool ReactNativeFeatureFlagsAccessor::disableEarlyViewCommandExecution() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(4, "disableEarlyViewCommandExecution"); + markFlagAsAccessed(5, "disableEarlyViewCommandExecution"); flagValue = currentProvider_->disableEarlyViewCommandExecution(); disableEarlyViewCommandExecution_ = flagValue; @@ -128,7 +146,7 @@ bool ReactNativeFeatureFlagsAccessor::disableIdleEventDispatchFrameCallbackRearm // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(5, "disableIdleEventDispatchFrameCallbackRearmAndroid"); + markFlagAsAccessed(6, "disableIdleEventDispatchFrameCallbackRearmAndroid"); flagValue = currentProvider_->disableIdleEventDispatchFrameCallbackRearmAndroid(); disableIdleEventDispatchFrameCallbackRearmAndroid_ = flagValue; @@ -146,7 +164,7 @@ bool ReactNativeFeatureFlagsAccessor::disableIdleMountItemFrameCallbackRearmAndr // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(6, "disableIdleMountItemFrameCallbackRearmAndroid"); + markFlagAsAccessed(7, "disableIdleMountItemFrameCallbackRearmAndroid"); flagValue = currentProvider_->disableIdleMountItemFrameCallbackRearmAndroid(); disableIdleMountItemFrameCallbackRearmAndroid_ = flagValue; @@ -164,7 +182,7 @@ bool ReactNativeFeatureFlagsAccessor::disableMountItemReorderingAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(7, "disableMountItemReorderingAndroid"); + markFlagAsAccessed(8, "disableMountItemReorderingAndroid"); flagValue = currentProvider_->disableMountItemReorderingAndroid(); disableMountItemReorderingAndroid_ = flagValue; @@ -182,7 +200,7 @@ bool ReactNativeFeatureFlagsAccessor::disableTextLayoutManagerCacheAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(8, "disableTextLayoutManagerCacheAndroid"); + markFlagAsAccessed(9, "disableTextLayoutManagerCacheAndroid"); flagValue = currentProvider_->disableTextLayoutManagerCacheAndroid(); disableTextLayoutManagerCacheAndroid_ = flagValue; @@ -200,7 +218,7 @@ bool ReactNativeFeatureFlagsAccessor::disableViewPreallocationAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(9, "disableViewPreallocationAndroid"); + markFlagAsAccessed(10, "disableViewPreallocationAndroid"); flagValue = currentProvider_->disableViewPreallocationAndroid(); disableViewPreallocationAndroid_ = flagValue; @@ -218,7 +236,7 @@ bool ReactNativeFeatureFlagsAccessor::enableAccessibilityOrder() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(10, "enableAccessibilityOrder"); + markFlagAsAccessed(11, "enableAccessibilityOrder"); flagValue = currentProvider_->enableAccessibilityOrder(); enableAccessibilityOrder_ = flagValue; @@ -236,7 +254,7 @@ bool ReactNativeFeatureFlagsAccessor::enableAccumulatedUpdatesInRawPropsAndroid( // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(11, "enableAccumulatedUpdatesInRawPropsAndroid"); + markFlagAsAccessed(12, "enableAccumulatedUpdatesInRawPropsAndroid"); flagValue = currentProvider_->enableAccumulatedUpdatesInRawPropsAndroid(); enableAccumulatedUpdatesInRawPropsAndroid_ = flagValue; @@ -254,7 +272,7 @@ bool ReactNativeFeatureFlagsAccessor::enableAliasedTextRoleInheritance() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(12, "enableAliasedTextRoleInheritance"); + markFlagAsAccessed(13, "enableAliasedTextRoleInheritance"); flagValue = currentProvider_->enableAliasedTextRoleInheritance(); enableAliasedTextRoleInheritance_ = flagValue; @@ -272,7 +290,7 @@ bool ReactNativeFeatureFlagsAccessor::enableAndroidTextMeasurementOptimizations( // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(13, "enableAndroidTextMeasurementOptimizations"); + markFlagAsAccessed(14, "enableAndroidTextMeasurementOptimizations"); flagValue = currentProvider_->enableAndroidTextMeasurementOptimizations(); enableAndroidTextMeasurementOptimizations_ = flagValue; @@ -290,7 +308,7 @@ bool ReactNativeFeatureFlagsAccessor::enableAsyncDiskCacheCheckInMultiSourceImag // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(14, "enableAsyncDiskCacheCheckInMultiSourceImageAndroid"); + markFlagAsAccessed(15, "enableAsyncDiskCacheCheckInMultiSourceImageAndroid"); flagValue = currentProvider_->enableAsyncDiskCacheCheckInMultiSourceImageAndroid(); enableAsyncDiskCacheCheckInMultiSourceImageAndroid_ = flagValue; @@ -308,7 +326,7 @@ bool ReactNativeFeatureFlagsAccessor::enableBridgelessArchitecture() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(15, "enableBridgelessArchitecture"); + markFlagAsAccessed(16, "enableBridgelessArchitecture"); flagValue = currentProvider_->enableBridgelessArchitecture(); enableBridgelessArchitecture_ = flagValue; @@ -326,7 +344,7 @@ bool ReactNativeFeatureFlagsAccessor::enableCppPropsIteratorSetter() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(16, "enableCppPropsIteratorSetter"); + markFlagAsAccessed(17, "enableCppPropsIteratorSetter"); flagValue = currentProvider_->enableCppPropsIteratorSetter(); enableCppPropsIteratorSetter_ = flagValue; @@ -344,7 +362,7 @@ bool ReactNativeFeatureFlagsAccessor::enableCustomFocusSearchOnClippedElementsAn // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(17, "enableCustomFocusSearchOnClippedElementsAndroid"); + markFlagAsAccessed(18, "enableCustomFocusSearchOnClippedElementsAndroid"); flagValue = currentProvider_->enableCustomFocusSearchOnClippedElementsAndroid(); enableCustomFocusSearchOnClippedElementsAndroid_ = flagValue; @@ -362,7 +380,7 @@ bool ReactNativeFeatureFlagsAccessor::enableDestroyShadowTreeRevisionAsync() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(18, "enableDestroyShadowTreeRevisionAsync"); + markFlagAsAccessed(19, "enableDestroyShadowTreeRevisionAsync"); flagValue = currentProvider_->enableDestroyShadowTreeRevisionAsync(); enableDestroyShadowTreeRevisionAsync_ = flagValue; @@ -380,7 +398,7 @@ bool ReactNativeFeatureFlagsAccessor::enableDoubleMeasurementFixAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(19, "enableDoubleMeasurementFixAndroid"); + markFlagAsAccessed(20, "enableDoubleMeasurementFixAndroid"); flagValue = currentProvider_->enableDoubleMeasurementFixAndroid(); enableDoubleMeasurementFixAndroid_ = flagValue; @@ -398,7 +416,7 @@ bool ReactNativeFeatureFlagsAccessor::enableEagerRootViewAttachment() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(20, "enableEagerRootViewAttachment"); + markFlagAsAccessed(21, "enableEagerRootViewAttachment"); flagValue = currentProvider_->enableEagerRootViewAttachment(); enableEagerRootViewAttachment_ = flagValue; @@ -416,7 +434,7 @@ bool ReactNativeFeatureFlagsAccessor::enableExclusivePropsUpdateAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(21, "enableExclusivePropsUpdateAndroid"); + markFlagAsAccessed(22, "enableExclusivePropsUpdateAndroid"); flagValue = currentProvider_->enableExclusivePropsUpdateAndroid(); enableExclusivePropsUpdateAndroid_ = flagValue; @@ -434,7 +452,7 @@ bool ReactNativeFeatureFlagsAccessor::enableFabricCommitBranching() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(22, "enableFabricCommitBranching"); + markFlagAsAccessed(23, "enableFabricCommitBranching"); flagValue = currentProvider_->enableFabricCommitBranching(); enableFabricCommitBranching_ = flagValue; @@ -452,7 +470,7 @@ bool ReactNativeFeatureFlagsAccessor::enableFabricCommitBranchingMergeOnMainThre // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(23, "enableFabricCommitBranchingMergeOnMainThread"); + markFlagAsAccessed(24, "enableFabricCommitBranchingMergeOnMainThread"); flagValue = currentProvider_->enableFabricCommitBranchingMergeOnMainThread(); enableFabricCommitBranchingMergeOnMainThread_ = flagValue; @@ -470,7 +488,7 @@ bool ReactNativeFeatureFlagsAccessor::enableFabricLogs() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(24, "enableFabricLogs"); + markFlagAsAccessed(25, "enableFabricLogs"); flagValue = currentProvider_->enableFabricLogs(); enableFabricLogs_ = flagValue; @@ -488,7 +506,7 @@ bool ReactNativeFeatureFlagsAccessor::enableFlexboxAutoMinSizeInStrictMode() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(25, "enableFlexboxAutoMinSizeInStrictMode"); + markFlagAsAccessed(26, "enableFlexboxAutoMinSizeInStrictMode"); flagValue = currentProvider_->enableFlexboxAutoMinSizeInStrictMode(); enableFlexboxAutoMinSizeInStrictMode_ = flagValue; @@ -506,7 +524,7 @@ bool ReactNativeFeatureFlagsAccessor::enableFlushSync() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(26, "enableFlushSync"); + markFlagAsAccessed(27, "enableFlushSync"); flagValue = currentProvider_->enableFlushSync(); enableFlushSync_ = flagValue; @@ -524,7 +542,7 @@ bool ReactNativeFeatureFlagsAccessor::enableFollowUpMountItemDispatchAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(27, "enableFollowUpMountItemDispatchAndroid"); + markFlagAsAccessed(28, "enableFollowUpMountItemDispatchAndroid"); flagValue = currentProvider_->enableFollowUpMountItemDispatchAndroid(); enableFollowUpMountItemDispatchAndroid_ = flagValue; @@ -542,7 +560,7 @@ bool ReactNativeFeatureFlagsAccessor::enableIOSCompressedTextFrameAdjustment() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(28, "enableIOSCompressedTextFrameAdjustment"); + markFlagAsAccessed(29, "enableIOSCompressedTextFrameAdjustment"); flagValue = currentProvider_->enableIOSCompressedTextFrameAdjustment(); enableIOSCompressedTextFrameAdjustment_ = flagValue; @@ -560,7 +578,7 @@ bool ReactNativeFeatureFlagsAccessor::enableIOSTextBaselineOffsetPerLine() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(29, "enableIOSTextBaselineOffsetPerLine"); + markFlagAsAccessed(30, "enableIOSTextBaselineOffsetPerLine"); flagValue = currentProvider_->enableIOSTextBaselineOffsetPerLine(); enableIOSTextBaselineOffsetPerLine_ = flagValue; @@ -578,7 +596,7 @@ bool ReactNativeFeatureFlagsAccessor::enableIOSViewClipToPaddingBox() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(30, "enableIOSViewClipToPaddingBox"); + markFlagAsAccessed(31, "enableIOSViewClipToPaddingBox"); flagValue = currentProvider_->enableIOSViewClipToPaddingBox(); enableIOSViewClipToPaddingBox_ = flagValue; @@ -596,7 +614,7 @@ bool ReactNativeFeatureFlagsAccessor::enableImagePrefetchingAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(31, "enableImagePrefetchingAndroid"); + markFlagAsAccessed(32, "enableImagePrefetchingAndroid"); flagValue = currentProvider_->enableImagePrefetchingAndroid(); enableImagePrefetchingAndroid_ = flagValue; @@ -614,7 +632,7 @@ bool ReactNativeFeatureFlagsAccessor::enableImageTransparentTintColor() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(32, "enableImageTransparentTintColor"); + markFlagAsAccessed(33, "enableImageTransparentTintColor"); flagValue = currentProvider_->enableImageTransparentTintColor(); enableImageTransparentTintColor_ = flagValue; @@ -632,7 +650,7 @@ bool ReactNativeFeatureFlagsAccessor::enableImmediateUpdateModeForContentOffsetC // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(33, "enableImmediateUpdateModeForContentOffsetChanges"); + markFlagAsAccessed(34, "enableImmediateUpdateModeForContentOffsetChanges"); flagValue = currentProvider_->enableImmediateUpdateModeForContentOffsetChanges(); enableImmediateUpdateModeForContentOffsetChanges_ = flagValue; @@ -650,7 +668,7 @@ bool ReactNativeFeatureFlagsAccessor::enableImmediateUpdateModeForScrollContentV // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(34, "enableImmediateUpdateModeForScrollContentView"); + markFlagAsAccessed(35, "enableImmediateUpdateModeForScrollContentView"); flagValue = currentProvider_->enableImmediateUpdateModeForScrollContentView(); enableImmediateUpdateModeForScrollContentView_ = flagValue; @@ -668,7 +686,7 @@ bool ReactNativeFeatureFlagsAccessor::enableImperativeEvents() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(35, "enableImperativeEvents"); + markFlagAsAccessed(36, "enableImperativeEvents"); flagValue = currentProvider_->enableImperativeEvents(); enableImperativeEvents_ = flagValue; @@ -686,7 +704,7 @@ bool ReactNativeFeatureFlagsAccessor::enableImperativeFocus() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(36, "enableImperativeFocus"); + markFlagAsAccessed(37, "enableImperativeFocus"); flagValue = currentProvider_->enableImperativeFocus(); enableImperativeFocus_ = flagValue; @@ -704,7 +722,7 @@ bool ReactNativeFeatureFlagsAccessor::enableInteractableResponderViews() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(37, "enableInteractableResponderViews"); + markFlagAsAccessed(38, "enableInteractableResponderViews"); flagValue = currentProvider_->enableInteractableResponderViews(); enableInteractableResponderViews_ = flagValue; @@ -722,7 +740,7 @@ bool ReactNativeFeatureFlagsAccessor::enableInteractiveInlineButtons() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(38, "enableInteractiveInlineButtons"); + markFlagAsAccessed(39, "enableInteractiveInlineButtons"); flagValue = currentProvider_->enableInteractiveInlineButtons(); enableInteractiveInlineButtons_ = flagValue; @@ -740,7 +758,7 @@ bool ReactNativeFeatureFlagsAccessor::enableInteropViewManagerClassLookUpOptimiz // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(39, "enableInteropViewManagerClassLookUpOptimizationIOS"); + markFlagAsAccessed(40, "enableInteropViewManagerClassLookUpOptimizationIOS"); flagValue = currentProvider_->enableInteropViewManagerClassLookUpOptimizationIOS(); enableInteropViewManagerClassLookUpOptimizationIOS_ = flagValue; @@ -758,7 +776,7 @@ bool ReactNativeFeatureFlagsAccessor::enableIntersectionObserverByDefault() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(40, "enableIntersectionObserverByDefault"); + markFlagAsAccessed(41, "enableIntersectionObserverByDefault"); flagValue = currentProvider_->enableIntersectionObserverByDefault(); enableIntersectionObserverByDefault_ = flagValue; @@ -776,7 +794,7 @@ bool ReactNativeFeatureFlagsAccessor::enableKeyEvents() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(41, "enableKeyEvents"); + markFlagAsAccessed(42, "enableKeyEvents"); flagValue = currentProvider_->enableKeyEvents(); enableKeyEvents_ = flagValue; @@ -794,7 +812,7 @@ bool ReactNativeFeatureFlagsAccessor::enableLayoutAnimationsOnAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(42, "enableLayoutAnimationsOnAndroid"); + markFlagAsAccessed(43, "enableLayoutAnimationsOnAndroid"); flagValue = currentProvider_->enableLayoutAnimationsOnAndroid(); enableLayoutAnimationsOnAndroid_ = flagValue; @@ -812,7 +830,7 @@ bool ReactNativeFeatureFlagsAccessor::enableLayoutAnimationsOnIOS() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(43, "enableLayoutAnimationsOnIOS"); + markFlagAsAccessed(44, "enableLayoutAnimationsOnIOS"); flagValue = currentProvider_->enableLayoutAnimationsOnIOS(); enableLayoutAnimationsOnIOS_ = flagValue; @@ -830,7 +848,7 @@ bool ReactNativeFeatureFlagsAccessor::enableModuleArgumentNSNullConversionIOS() // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(44, "enableModuleArgumentNSNullConversionIOS"); + markFlagAsAccessed(45, "enableModuleArgumentNSNullConversionIOS"); flagValue = currentProvider_->enableModuleArgumentNSNullConversionIOS(); enableModuleArgumentNSNullConversionIOS_ = flagValue; @@ -848,7 +866,7 @@ bool ReactNativeFeatureFlagsAccessor::enableMountingCoordinatorPullModelAndroid( // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(45, "enableMountingCoordinatorPullModelAndroid"); + markFlagAsAccessed(46, "enableMountingCoordinatorPullModelAndroid"); flagValue = currentProvider_->enableMountingCoordinatorPullModelAndroid(); enableMountingCoordinatorPullModelAndroid_ = flagValue; @@ -866,7 +884,7 @@ bool ReactNativeFeatureFlagsAccessor::enableMutationObserverByDefault() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(46, "enableMutationObserverByDefault"); + markFlagAsAccessed(47, "enableMutationObserverByDefault"); flagValue = currentProvider_->enableMutationObserverByDefault(); enableMutationObserverByDefault_ = flagValue; @@ -884,7 +902,7 @@ bool ReactNativeFeatureFlagsAccessor::enableNativeCSSParsing() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(47, "enableNativeCSSParsing"); + markFlagAsAccessed(48, "enableNativeCSSParsing"); flagValue = currentProvider_->enableNativeCSSParsing(); enableNativeCSSParsing_ = flagValue; @@ -902,7 +920,7 @@ bool ReactNativeFeatureFlagsAccessor::enablePreallocatedPropsDiffOnInsertAndroid // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(48, "enablePreallocatedPropsDiffOnInsertAndroid"); + markFlagAsAccessed(49, "enablePreallocatedPropsDiffOnInsertAndroid"); flagValue = currentProvider_->enablePreallocatedPropsDiffOnInsertAndroid(); enablePreallocatedPropsDiffOnInsertAndroid_ = flagValue; @@ -920,7 +938,7 @@ bool ReactNativeFeatureFlagsAccessor::enablePreparedTextLayout() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(49, "enablePreparedTextLayout"); + markFlagAsAccessed(50, "enablePreparedTextLayout"); flagValue = currentProvider_->enablePreparedTextLayout(); enablePreparedTextLayout_ = flagValue; @@ -938,7 +956,7 @@ bool ReactNativeFeatureFlagsAccessor::enablePropsUpdateReconciliationAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(50, "enablePropsUpdateReconciliationAndroid"); + markFlagAsAccessed(51, "enablePropsUpdateReconciliationAndroid"); flagValue = currentProvider_->enablePropsUpdateReconciliationAndroid(); enablePropsUpdateReconciliationAndroid_ = flagValue; @@ -956,7 +974,7 @@ bool ReactNativeFeatureFlagsAccessor::enableResizeObserverByDefault() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(51, "enableResizeObserverByDefault"); + markFlagAsAccessed(52, "enableResizeObserverByDefault"); flagValue = currentProvider_->enableResizeObserverByDefault(); enableResizeObserverByDefault_ = flagValue; @@ -974,7 +992,7 @@ bool ReactNativeFeatureFlagsAccessor::enableSwiftUIBasedFilters() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(52, "enableSwiftUIBasedFilters"); + markFlagAsAccessed(53, "enableSwiftUIBasedFilters"); flagValue = currentProvider_->enableSwiftUIBasedFilters(); enableSwiftUIBasedFilters_ = flagValue; @@ -992,7 +1010,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewCulling() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(53, "enableViewCulling"); + markFlagAsAccessed(54, "enableViewCulling"); flagValue = currentProvider_->enableViewCulling(); enableViewCulling_ = flagValue; @@ -1010,7 +1028,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecycling() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(54, "enableViewRecycling"); + markFlagAsAccessed(55, "enableViewRecycling"); flagValue = currentProvider_->enableViewRecycling(); enableViewRecycling_ = flagValue; @@ -1028,7 +1046,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForImage() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(55, "enableViewRecyclingForImage"); + markFlagAsAccessed(56, "enableViewRecyclingForImage"); flagValue = currentProvider_->enableViewRecyclingForImage(); enableViewRecyclingForImage_ = flagValue; @@ -1046,7 +1064,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForScrollView() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(56, "enableViewRecyclingForScrollView"); + markFlagAsAccessed(57, "enableViewRecyclingForScrollView"); flagValue = currentProvider_->enableViewRecyclingForScrollView(); enableViewRecyclingForScrollView_ = flagValue; @@ -1064,7 +1082,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForText() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(57, "enableViewRecyclingForText"); + markFlagAsAccessed(58, "enableViewRecyclingForText"); flagValue = currentProvider_->enableViewRecyclingForText(); enableViewRecyclingForText_ = flagValue; @@ -1082,7 +1100,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForView() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(58, "enableViewRecyclingForView"); + markFlagAsAccessed(59, "enableViewRecyclingForView"); flagValue = currentProvider_->enableViewRecyclingForView(); enableViewRecyclingForView_ = flagValue; @@ -1100,7 +1118,7 @@ bool ReactNativeFeatureFlagsAccessor::enableVirtualViewContainerStateExperimenta // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(59, "enableVirtualViewContainerStateExperimental"); + markFlagAsAccessed(60, "enableVirtualViewContainerStateExperimental"); flagValue = currentProvider_->enableVirtualViewContainerStateExperimental(); enableVirtualViewContainerStateExperimental_ = flagValue; @@ -1118,7 +1136,7 @@ bool ReactNativeFeatureFlagsAccessor::fixBorderlessRippleAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(60, "fixBorderlessRippleAndroid"); + markFlagAsAccessed(61, "fixBorderlessRippleAndroid"); flagValue = currentProvider_->fixBorderlessRippleAndroid(); fixBorderlessRippleAndroid_ = flagValue; @@ -1136,7 +1154,7 @@ bool ReactNativeFeatureFlagsAccessor::fixMappingOfEventPrioritiesBetweenFabricAn // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(61, "fixMappingOfEventPrioritiesBetweenFabricAndReact"); + markFlagAsAccessed(62, "fixMappingOfEventPrioritiesBetweenFabricAndReact"); flagValue = currentProvider_->fixMappingOfEventPrioritiesBetweenFabricAndReact(); fixMappingOfEventPrioritiesBetweenFabricAndReact_ = flagValue; @@ -1154,7 +1172,7 @@ bool ReactNativeFeatureFlagsAccessor::fixMultilineContentJumpAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(62, "fixMultilineContentJumpAndroid"); + markFlagAsAccessed(63, "fixMultilineContentJumpAndroid"); flagValue = currentProvider_->fixMultilineContentJumpAndroid(); fixMultilineContentJumpAndroid_ = flagValue; @@ -1172,7 +1190,7 @@ bool ReactNativeFeatureFlagsAccessor::fixProgrammaticScrollMomentumEventsIOS() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(63, "fixProgrammaticScrollMomentumEventsIOS"); + markFlagAsAccessed(64, "fixProgrammaticScrollMomentumEventsIOS"); flagValue = currentProvider_->fixProgrammaticScrollMomentumEventsIOS(); fixProgrammaticScrollMomentumEventsIOS_ = flagValue; @@ -1190,7 +1208,7 @@ bool ReactNativeFeatureFlagsAccessor::fixTextInlineViewLineHeight() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(64, "fixTextInlineViewLineHeight"); + markFlagAsAccessed(65, "fixTextInlineViewLineHeight"); flagValue = currentProvider_->fixTextInlineViewLineHeight(); fixTextInlineViewLineHeight_ = flagValue; @@ -1208,7 +1226,7 @@ bool ReactNativeFeatureFlagsAccessor::fixTextLayoutOnPixelDensityChange() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(65, "fixTextLayoutOnPixelDensityChange"); + markFlagAsAccessed(66, "fixTextLayoutOnPixelDensityChange"); flagValue = currentProvider_->fixTextLayoutOnPixelDensityChange(); fixTextLayoutOnPixelDensityChange_ = flagValue; @@ -1226,7 +1244,7 @@ bool ReactNativeFeatureFlagsAccessor::fixYogaFlexBasisFitContentInMainAxis() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(66, "fixYogaFlexBasisFitContentInMainAxis"); + markFlagAsAccessed(67, "fixYogaFlexBasisFitContentInMainAxis"); flagValue = currentProvider_->fixYogaFlexBasisFitContentInMainAxis(); fixYogaFlexBasisFitContentInMainAxis_ = flagValue; @@ -1244,7 +1262,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxAssertSingleHostState() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(67, "fuseboxAssertSingleHostState"); + markFlagAsAccessed(68, "fuseboxAssertSingleHostState"); flagValue = currentProvider_->fuseboxAssertSingleHostState(); fuseboxAssertSingleHostState_ = flagValue; @@ -1262,7 +1280,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxEnabledRelease() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(68, "fuseboxEnabledRelease"); + markFlagAsAccessed(69, "fuseboxEnabledRelease"); flagValue = currentProvider_->fuseboxEnabledRelease(); fuseboxEnabledRelease_ = flagValue; @@ -1280,7 +1298,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxFrameRecordingEnabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(69, "fuseboxFrameRecordingEnabled"); + markFlagAsAccessed(70, "fuseboxFrameRecordingEnabled"); flagValue = currentProvider_->fuseboxFrameRecordingEnabled(); fuseboxFrameRecordingEnabled_ = flagValue; @@ -1298,7 +1316,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxScreenshotCaptureEnabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(70, "fuseboxScreenshotCaptureEnabled"); + markFlagAsAccessed(71, "fuseboxScreenshotCaptureEnabled"); flagValue = currentProvider_->fuseboxScreenshotCaptureEnabled(); fuseboxScreenshotCaptureEnabled_ = flagValue; @@ -1316,7 +1334,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxWebSocketEventsEnabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(71, "fuseboxWebSocketEventsEnabled"); + markFlagAsAccessed(72, "fuseboxWebSocketEventsEnabled"); flagValue = currentProvider_->fuseboxWebSocketEventsEnabled(); fuseboxWebSocketEventsEnabled_ = flagValue; @@ -1334,7 +1352,7 @@ bool ReactNativeFeatureFlagsAccessor::keepTimersRunningWhileHostPausedAndroid() // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(72, "keepTimersRunningWhileHostPausedAndroid"); + markFlagAsAccessed(73, "keepTimersRunningWhileHostPausedAndroid"); flagValue = currentProvider_->keepTimersRunningWhileHostPausedAndroid(); keepTimersRunningWhileHostPausedAndroid_ = flagValue; @@ -1352,7 +1370,7 @@ bool ReactNativeFeatureFlagsAccessor::optimizedAnimatedPropUpdates() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(73, "optimizedAnimatedPropUpdates"); + markFlagAsAccessed(74, "optimizedAnimatedPropUpdates"); flagValue = currentProvider_->optimizedAnimatedPropUpdates(); optimizedAnimatedPropUpdates_ = flagValue; @@ -1370,7 +1388,7 @@ bool ReactNativeFeatureFlagsAccessor::overrideBySynchronousMountPropsAtMountingA // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(74, "overrideBySynchronousMountPropsAtMountingAndroid"); + markFlagAsAccessed(75, "overrideBySynchronousMountPropsAtMountingAndroid"); flagValue = currentProvider_->overrideBySynchronousMountPropsAtMountingAndroid(); overrideBySynchronousMountPropsAtMountingAndroid_ = flagValue; @@ -1388,7 +1406,7 @@ bool ReactNativeFeatureFlagsAccessor::perfIssuesEnabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(75, "perfIssuesEnabled"); + markFlagAsAccessed(76, "perfIssuesEnabled"); flagValue = currentProvider_->perfIssuesEnabled(); perfIssuesEnabled_ = flagValue; @@ -1406,7 +1424,7 @@ bool ReactNativeFeatureFlagsAccessor::perfMonitorV2Enabled() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(76, "perfMonitorV2Enabled"); + markFlagAsAccessed(77, "perfMonitorV2Enabled"); flagValue = currentProvider_->perfMonitorV2Enabled(); perfMonitorV2Enabled_ = flagValue; @@ -1424,7 +1442,7 @@ double ReactNativeFeatureFlagsAccessor::preparedTextCacheSize() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(77, "preparedTextCacheSize"); + markFlagAsAccessed(78, "preparedTextCacheSize"); flagValue = currentProvider_->preparedTextCacheSize(); preparedTextCacheSize_ = flagValue; @@ -1442,7 +1460,7 @@ bool ReactNativeFeatureFlagsAccessor::preventShadowTreeCommitExhaustion() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(78, "preventShadowTreeCommitExhaustion"); + markFlagAsAccessed(79, "preventShadowTreeCommitExhaustion"); flagValue = currentProvider_->preventShadowTreeCommitExhaustion(); preventShadowTreeCommitExhaustion_ = flagValue; @@ -1460,7 +1478,7 @@ bool ReactNativeFeatureFlagsAccessor::redBoxV2Android() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(79, "redBoxV2Android"); + markFlagAsAccessed(80, "redBoxV2Android"); flagValue = currentProvider_->redBoxV2Android(); redBoxV2Android_ = flagValue; @@ -1478,7 +1496,7 @@ bool ReactNativeFeatureFlagsAccessor::redBoxV2IOS() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(80, "redBoxV2IOS"); + markFlagAsAccessed(81, "redBoxV2IOS"); flagValue = currentProvider_->redBoxV2IOS(); redBoxV2IOS_ = flagValue; @@ -1496,7 +1514,7 @@ bool ReactNativeFeatureFlagsAccessor::shouldPressibilityUseW3CPointerEventsForHo // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(81, "shouldPressibilityUseW3CPointerEventsForHover"); + markFlagAsAccessed(82, "shouldPressibilityUseW3CPointerEventsForHover"); flagValue = currentProvider_->shouldPressibilityUseW3CPointerEventsForHover(); shouldPressibilityUseW3CPointerEventsForHover_ = flagValue; @@ -1514,7 +1532,7 @@ bool ReactNativeFeatureFlagsAccessor::shouldTriggerResponderTransferOnScrollAndr // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(82, "shouldTriggerResponderTransferOnScrollAndroid"); + markFlagAsAccessed(83, "shouldTriggerResponderTransferOnScrollAndroid"); flagValue = currentProvider_->shouldTriggerResponderTransferOnScrollAndroid(); shouldTriggerResponderTransferOnScrollAndroid_ = flagValue; @@ -1532,7 +1550,7 @@ bool ReactNativeFeatureFlagsAccessor::skipActivityIdentityAssertionOnHostPause() // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(83, "skipActivityIdentityAssertionOnHostPause"); + markFlagAsAccessed(84, "skipActivityIdentityAssertionOnHostPause"); flagValue = currentProvider_->skipActivityIdentityAssertionOnHostPause(); skipActivityIdentityAssertionOnHostPause_ = flagValue; @@ -1550,7 +1568,7 @@ bool ReactNativeFeatureFlagsAccessor::skipNativePropsForViewManagerWithDelegateA // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(84, "skipNativePropsForViewManagerWithDelegateAndroid"); + markFlagAsAccessed(85, "skipNativePropsForViewManagerWithDelegateAndroid"); flagValue = currentProvider_->skipNativePropsForViewManagerWithDelegateAndroid(); skipNativePropsForViewManagerWithDelegateAndroid_ = flagValue; @@ -1568,7 +1586,7 @@ bool ReactNativeFeatureFlagsAccessor::skipUnchangedChildrenInDifferentiator() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(85, "skipUnchangedChildrenInDifferentiator"); + markFlagAsAccessed(86, "skipUnchangedChildrenInDifferentiator"); flagValue = currentProvider_->skipUnchangedChildrenInDifferentiator(); skipUnchangedChildrenInDifferentiator_ = flagValue; @@ -1586,7 +1604,7 @@ bool ReactNativeFeatureFlagsAccessor::syncAndroidClipBoundsWithOverflow() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(86, "syncAndroidClipBoundsWithOverflow"); + markFlagAsAccessed(87, "syncAndroidClipBoundsWithOverflow"); flagValue = currentProvider_->syncAndroidClipBoundsWithOverflow(); syncAndroidClipBoundsWithOverflow_ = flagValue; @@ -1604,7 +1622,7 @@ bool ReactNativeFeatureFlagsAccessor::traceTurboModulePromiseRejectionsOnAndroid // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(87, "traceTurboModulePromiseRejectionsOnAndroid"); + markFlagAsAccessed(88, "traceTurboModulePromiseRejectionsOnAndroid"); flagValue = currentProvider_->traceTurboModulePromiseRejectionsOnAndroid(); traceTurboModulePromiseRejectionsOnAndroid_ = flagValue; @@ -1622,7 +1640,7 @@ bool ReactNativeFeatureFlagsAccessor::updateRuntimeShadowNodeReferencesOnCommit( // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(88, "updateRuntimeShadowNodeReferencesOnCommit"); + markFlagAsAccessed(89, "updateRuntimeShadowNodeReferencesOnCommit"); flagValue = currentProvider_->updateRuntimeShadowNodeReferencesOnCommit(); updateRuntimeShadowNodeReferencesOnCommit_ = flagValue; @@ -1640,7 +1658,7 @@ bool ReactNativeFeatureFlagsAccessor::updateRuntimeShadowNodeReferencesOnCommitT // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(89, "updateRuntimeShadowNodeReferencesOnCommitThread"); + markFlagAsAccessed(90, "updateRuntimeShadowNodeReferencesOnCommitThread"); flagValue = currentProvider_->updateRuntimeShadowNodeReferencesOnCommitThread(); updateRuntimeShadowNodeReferencesOnCommitThread_ = flagValue; @@ -1658,7 +1676,7 @@ bool ReactNativeFeatureFlagsAccessor::useAlwaysAvailableJSErrorHandling() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(90, "useAlwaysAvailableJSErrorHandling"); + markFlagAsAccessed(91, "useAlwaysAvailableJSErrorHandling"); flagValue = currentProvider_->useAlwaysAvailableJSErrorHandling(); useAlwaysAvailableJSErrorHandling_ = flagValue; @@ -1676,7 +1694,7 @@ bool ReactNativeFeatureFlagsAccessor::useFabricInterop() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(91, "useFabricInterop"); + markFlagAsAccessed(92, "useFabricInterop"); flagValue = currentProvider_->useFabricInterop(); useFabricInterop_ = flagValue; @@ -1685,6 +1703,24 @@ bool ReactNativeFeatureFlagsAccessor::useFabricInterop() { return flagValue.value(); } +bool ReactNativeFeatureFlagsAccessor::useJavaPreparedLayoutCacheAndroid() { + auto flagValue = useJavaPreparedLayoutCacheAndroid_.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(93, "useJavaPreparedLayoutCacheAndroid"); + + flagValue = currentProvider_->useJavaPreparedLayoutCacheAndroid(); + useJavaPreparedLayoutCacheAndroid_ = flagValue; + } + + return flagValue.value(); +} + bool ReactNativeFeatureFlagsAccessor::useNativeViewConfigsInBridgelessMode() { auto flagValue = useNativeViewConfigsInBridgelessMode_.load(); @@ -1694,7 +1730,7 @@ bool ReactNativeFeatureFlagsAccessor::useNativeViewConfigsInBridgelessMode() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(92, "useNativeViewConfigsInBridgelessMode"); + markFlagAsAccessed(94, "useNativeViewConfigsInBridgelessMode"); flagValue = currentProvider_->useNativeViewConfigsInBridgelessMode(); useNativeViewConfigsInBridgelessMode_ = flagValue; @@ -1712,7 +1748,7 @@ bool ReactNativeFeatureFlagsAccessor::useNestedScrollViewAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(93, "useNestedScrollViewAndroid"); + markFlagAsAccessed(95, "useNestedScrollViewAndroid"); flagValue = currentProvider_->useNestedScrollViewAndroid(); useNestedScrollViewAndroid_ = flagValue; @@ -1730,7 +1766,7 @@ bool ReactNativeFeatureFlagsAccessor::useSharedAnimatedBackend() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(94, "useSharedAnimatedBackend"); + markFlagAsAccessed(96, "useSharedAnimatedBackend"); flagValue = currentProvider_->useSharedAnimatedBackend(); useSharedAnimatedBackend_ = flagValue; @@ -1748,7 +1784,7 @@ bool ReactNativeFeatureFlagsAccessor::useTraitHiddenOnAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(95, "useTraitHiddenOnAndroid"); + markFlagAsAccessed(97, "useTraitHiddenOnAndroid"); flagValue = currentProvider_->useTraitHiddenOnAndroid(); useTraitHiddenOnAndroid_ = flagValue; @@ -1766,7 +1802,7 @@ bool ReactNativeFeatureFlagsAccessor::useTurboModuleInterop() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(96, "useTurboModuleInterop"); + markFlagAsAccessed(98, "useTurboModuleInterop"); flagValue = currentProvider_->useTurboModuleInterop(); useTurboModuleInterop_ = flagValue; @@ -1784,7 +1820,7 @@ bool ReactNativeFeatureFlagsAccessor::useWindowDensityForDisplayMetricsAndroid() // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(97, "useWindowDensityForDisplayMetricsAndroid"); + markFlagAsAccessed(99, "useWindowDensityForDisplayMetricsAndroid"); flagValue = currentProvider_->useWindowDensityForDisplayMetricsAndroid(); useWindowDensityForDisplayMetricsAndroid_ = flagValue; @@ -1802,7 +1838,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(98, "viewCullingOutsetRatio"); + markFlagAsAccessed(100, "viewCullingOutsetRatio"); flagValue = currentProvider_->viewCullingOutsetRatio(); viewCullingOutsetRatio_ = flagValue; @@ -1820,7 +1856,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(99, "viewTransitionEnabled"); + markFlagAsAccessed(101, "viewTransitionEnabled"); flagValue = currentProvider_->viewTransitionEnabled(); viewTransitionEnabled_ = flagValue; @@ -1838,7 +1874,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(100, "viewTransitionUseHardwareBitmapAndroid"); + markFlagAsAccessed(102, "viewTransitionUseHardwareBitmapAndroid"); flagValue = currentProvider_->viewTransitionUseHardwareBitmapAndroid(); viewTransitionUseHardwareBitmapAndroid_ = flagValue; @@ -1856,7 +1892,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(101, "virtualViewPrerenderRatio"); + markFlagAsAccessed(103, "virtualViewPrerenderRatio"); flagValue = currentProvider_->virtualViewPrerenderRatio(); virtualViewPrerenderRatio_ = flagValue; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h index 477dc1439e67..acfc98a500ad 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h @@ -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<> + * @generated SignedSource<> */ /** @@ -37,6 +37,7 @@ class ReactNativeFeatureFlagsAccessor { bool commonTestFlag(); bool cdpInteractionMetricsEnabled(); bool cxxNativeAnimatedEnabled(); + bool deferPreparedLayoutReactTagsToMountAndroid(); bool deferTextInputTruncationIOS(); bool disableEarlyViewCommandExecution(); bool disableIdleEventDispatchFrameCallbackRearmAndroid(); @@ -126,6 +127,7 @@ class ReactNativeFeatureFlagsAccessor { bool updateRuntimeShadowNodeReferencesOnCommitThread(); bool useAlwaysAvailableJSErrorHandling(); bool useFabricInterop(); + bool useJavaPreparedLayoutCacheAndroid(); bool useNativeViewConfigsInBridgelessMode(); bool useNestedScrollViewAndroid(); bool useSharedAnimatedBackend(); @@ -147,11 +149,12 @@ class ReactNativeFeatureFlagsAccessor { std::unique_ptr currentProvider_; bool wasOverridden_; - std::array, 102> accessedFeatureFlags_; + std::array, 104> accessedFeatureFlags_; std::atomic> commonTestFlag_; std::atomic> cdpInteractionMetricsEnabled_; std::atomic> cxxNativeAnimatedEnabled_; + std::atomic> deferPreparedLayoutReactTagsToMountAndroid_; std::atomic> deferTextInputTruncationIOS_; std::atomic> disableEarlyViewCommandExecution_; std::atomic> disableIdleEventDispatchFrameCallbackRearmAndroid_; @@ -241,6 +244,7 @@ class ReactNativeFeatureFlagsAccessor { std::atomic> updateRuntimeShadowNodeReferencesOnCommitThread_; std::atomic> useAlwaysAvailableJSErrorHandling_; std::atomic> useFabricInterop_; + std::atomic> useJavaPreparedLayoutCacheAndroid_; std::atomic> useNativeViewConfigsInBridgelessMode_; std::atomic> useNestedScrollViewAndroid_; std::atomic> useSharedAnimatedBackend_; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h index 51adc60a0256..e9f3348e3d7d 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h @@ -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<> + * @generated SignedSource<<0a041a9f18ac87683a4d7d207f6a51d2>> */ /** @@ -41,6 +41,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider { return true; } + bool deferPreparedLayoutReactTagsToMountAndroid() override { + return false; + } + bool deferTextInputTruncationIOS() override { return false; } @@ -397,6 +401,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider { return true; } + bool useJavaPreparedLayoutCacheAndroid() override { + return false; + } + bool useNativeViewConfigsInBridgelessMode() override { return false; } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h index 0e0fa1f4d133..d9a12455d0ae 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h @@ -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<> + * @generated SignedSource<<22cd2320e19ac21450b95d12f42967d9>> */ /** @@ -74,6 +74,15 @@ class ReactNativeFeatureFlagsDynamicProvider : public ReactNativeFeatureFlagsDef return ReactNativeFeatureFlagsDefaults::cxxNativeAnimatedEnabled(); } + bool deferPreparedLayoutReactTagsToMountAndroid() override { + auto value = values_["deferPreparedLayoutReactTagsToMountAndroid"]; + if (!value.isNull()) { + return value.getBool(); + } + + return ReactNativeFeatureFlagsDefaults::deferPreparedLayoutReactTagsToMountAndroid(); + } + bool deferTextInputTruncationIOS() override { auto value = values_["deferTextInputTruncationIOS"]; if (!value.isNull()) { @@ -875,6 +884,15 @@ class ReactNativeFeatureFlagsDynamicProvider : public ReactNativeFeatureFlagsDef return ReactNativeFeatureFlagsDefaults::useFabricInterop(); } + bool useJavaPreparedLayoutCacheAndroid() override { + auto value = values_["useJavaPreparedLayoutCacheAndroid"]; + if (!value.isNull()) { + return value.getBool(); + } + + return ReactNativeFeatureFlagsDefaults::useJavaPreparedLayoutCacheAndroid(); + } + bool useNativeViewConfigsInBridgelessMode() override { auto value = values_["useNativeViewConfigsInBridgelessMode"]; if (!value.isNull()) { diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h index 60b1c4d852bd..6a5f53f60ebf 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h @@ -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<<9548bb9a9945a7cf7f336a19775d7de9>> + * @generated SignedSource<<1b4afe8143f1eaab17f4e061188e77a8>> */ /** @@ -30,6 +30,7 @@ class ReactNativeFeatureFlagsProvider { virtual bool commonTestFlag() = 0; virtual bool cdpInteractionMetricsEnabled() = 0; virtual bool cxxNativeAnimatedEnabled() = 0; + virtual bool deferPreparedLayoutReactTagsToMountAndroid() = 0; virtual bool deferTextInputTruncationIOS() = 0; virtual bool disableEarlyViewCommandExecution() = 0; virtual bool disableIdleEventDispatchFrameCallbackRearmAndroid() = 0; @@ -119,6 +120,7 @@ class ReactNativeFeatureFlagsProvider { virtual bool updateRuntimeShadowNodeReferencesOnCommitThread() = 0; virtual bool useAlwaysAvailableJSErrorHandling() = 0; virtual bool useFabricInterop() = 0; + virtual bool useJavaPreparedLayoutCacheAndroid() = 0; virtual bool useNativeViewConfigsInBridgelessMode() = 0; virtual bool useNestedScrollViewAndroid() = 0; virtual bool useSharedAnimatedBackend() = 0; diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp index c8fd7a17ee6e..c8f4adcdf0d4 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp +++ b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp @@ -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<<27553445e099bb9288920bd3bd233c25>> + * @generated SignedSource<<66c71bc23c9ccbf349988b1d66ab59d6>> */ /** @@ -59,6 +59,11 @@ bool NativeReactNativeFeatureFlags::cxxNativeAnimatedEnabled( return ReactNativeFeatureFlags::cxxNativeAnimatedEnabled(); } +bool NativeReactNativeFeatureFlags::deferPreparedLayoutReactTagsToMountAndroid( + jsi::Runtime& /*runtime*/) { + return ReactNativeFeatureFlags::deferPreparedLayoutReactTagsToMountAndroid(); +} + bool NativeReactNativeFeatureFlags::deferTextInputTruncationIOS( jsi::Runtime& /*runtime*/) { return ReactNativeFeatureFlags::deferTextInputTruncationIOS(); @@ -504,6 +509,11 @@ bool NativeReactNativeFeatureFlags::useFabricInterop( return ReactNativeFeatureFlags::useFabricInterop(); } +bool NativeReactNativeFeatureFlags::useJavaPreparedLayoutCacheAndroid( + jsi::Runtime& /*runtime*/) { + return ReactNativeFeatureFlags::useJavaPreparedLayoutCacheAndroid(); +} + bool NativeReactNativeFeatureFlags::useNativeViewConfigsInBridgelessMode( jsi::Runtime& /*runtime*/) { return ReactNativeFeatureFlags::useNativeViewConfigsInBridgelessMode(); diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h index b9e4a1dce631..5d8921fd6304 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h +++ b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h @@ -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<<58aaefb40589a425061f191cc5c6c9c0>> + * @generated SignedSource<<942369ff7a63d511e471c64d852697d3>> */ /** @@ -44,6 +44,8 @@ class NativeReactNativeFeatureFlags bool cxxNativeAnimatedEnabled(jsi::Runtime& runtime); + bool deferPreparedLayoutReactTagsToMountAndroid(jsi::Runtime& runtime); + bool deferTextInputTruncationIOS(jsi::Runtime& runtime); bool disableEarlyViewCommandExecution(jsi::Runtime& runtime); @@ -222,6 +224,8 @@ class NativeReactNativeFeatureFlags bool useFabricInterop(jsi::Runtime& runtime); + bool useJavaPreparedLayoutCacheAndroid(jsi::Runtime& runtime); + bool useNativeViewConfigsInBridgelessMode(jsi::Runtime& runtime); bool useNestedScrollViewAndroid(jsi::Runtime& runtime); diff --git a/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/ParagraphState.cpp b/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/ParagraphState.cpp index bfa9c94d84c9..9acda283055b 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/ParagraphState.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/text/platform/android/react/renderer/components/text/ParagraphState.cpp @@ -7,9 +7,15 @@ #include "ParagraphState.h" +#include +#include +#include +#include + #include #include #include +#include namespace facebook::react { @@ -25,7 +31,46 @@ MapBuffer ParagraphState::getMapBuffer() const { } jni::local_ref ParagraphState::getJNIReference() const { - return jni::make_local(measuredLayout.preparedTextLayout.get()); + if (measuredLayout.preparedTextLayout.isCachedInJava()) { + auto manager = layoutManager.lock(); + if (manager == nullptr) { + return nullptr; + } + return manager->resolvePreparedLayoutForMount( + measuredLayout.preparedTextLayout, + attributedString, + paragraphAttributes, + measuredLayout.layoutConstraints); + } + + auto preparedLayout = measuredLayout.preparedTextLayout.get(); + if (preparedLayout == nullptr || + !measuredLayout.preparedTextLayout.hasDivergentReactTags()) { + return jni::make_local(preparedLayout); + } + + const auto& fragments = attributedString.getFragments(); + constexpr size_t kInlineTagCapacity = 8; + std::array inlineTags{}; + std::vector heapTags; + std::span tagSpan{inlineTags}; + if (fragments.size() > kInlineTagCapacity) { + heapTags.resize(fragments.size()); + tagSpan = heapTags; + } + for (size_t i = 0; i < fragments.size(); i++) { + tagSpan[i] = fragments[i].parentShadowView.tag; + } + + auto javaReactTags = jni::JArrayInt::newArray(fragments.size()); + javaReactTags->setRegion( + 0, static_cast(fragments.size()), tagSpan.data()); + + static auto withReactTags = + JPreparedLayout::javaClassStatic() + ->getMethod("withReactTags"); + + return withReactTags(preparedLayout, javaReactTags.get()); } } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp index bb58da7ef8f5..61876addedf3 100644 --- a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp +++ b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp @@ -5,6 +5,8 @@ * LICENSE file in the root directory of this source tree. */ +#include +#include #include #include @@ -27,6 +29,65 @@ static_assert(TextLayoutManagerExtended::supportsPreparedTextLayout()); namespace { +jni::local_ref makeReactTagsArray( + const AttributedString& attributedString) { + const auto& fragments = attributedString.getFragments(); + constexpr size_t kInlineTagCapacity = 8; + std::array inlineTags{}; + std::vector heapTags; + std::span tagSpan{inlineTags}; + if (fragments.size() > kInlineTagCapacity) { + heapTags.resize(fragments.size()); + tagSpan = heapTags; + } + for (size_t i = 0; i < fragments.size(); i++) { + tagSpan[i] = fragments[i].parentShadowView.tag; + } + + auto javaReactTags = jni::JArrayInt::newArray(fragments.size()); + javaReactTags->setRegion( + 0, static_cast(fragments.size()), tagSpan.data()); + return javaReactTags; +} + +TextMeasurement parseMeasurementsArray( + jni::alias_ref measurementsArr) { + react_native_assert(measurementsArr != nullptr); + auto measurements = measurementsArr->getRegion( + 0, static_cast(measurementsArr->size())); + + react_native_assert(measurementsArr->size() >= 2); + react_native_assert((measurementsArr->size() - 2) % 4 == 0); + + TextMeasurement textMeasurement; + textMeasurement.size.width = measurements[0]; + textMeasurement.size.height = measurements[1]; + + if (measurementsArr->size() > 2) { + textMeasurement.attachments.reserve((measurementsArr->size() - 2) / 4); + for (size_t i = 2; i < measurementsArr->size(); i += 4) { + auto top = measurements[i]; + auto left = measurements[i + 1]; + auto width = measurements[i + 2]; + auto height = measurements[i + 3]; + + if (std::isnan(top) || std::isnan(left)) { + textMeasurement.attachments.push_back( + TextMeasurement::Attachment{.frame = Rect{}, .isClipped = true}); + } else { + textMeasurement.attachments.push_back( + TextMeasurement::Attachment{ + .frame = + {.origin = {.x = left, .y = top}, + .size = {.width = width, .height = height}}, + .isClipped = false}); + } + } + } + + return textMeasurement; +} + int countAttachments(const AttributedString& attributedString) { int count = 0; @@ -297,6 +358,10 @@ TextLayoutManager::PreparedTextLayout TextLayoutManager::prepareLayout( const ParagraphAttributes& paragraphAttributes, const TextLayoutContext& layoutContext, const LayoutConstraints& layoutConstraints) const { + const bool useJavaCache = + ReactNativeFeatureFlags::useJavaPreparedLayoutCacheAndroid() && + ReactNativeFeatureFlags::preparedTextCacheSize() > 0; + static auto prepareTextLayout = jni::findClassStatic("com/facebook/react/fabric/FabricUIManager") ->getMethod("prepareTextLayout"); + static auto prepareAndMeasureTextLayoutToCache = + jni::findClassStatic("com/facebook/react/fabric/FabricUIManager") + ->getMethod("prepareAndMeasureTextLayoutToCache"); + + static std::atomic nextPreparedLayoutCacheId{0}; + static auto reusePreparedLayoutWithNewReactTags = jni::findClassStatic("com/facebook/react/fabric/FabricUIManager") ->getMethod reactTags(fragments.size()); - for (size_t i = 0; i < reactTags.size(); i++) { - reactTags[i] = fragments[i].parentShadowView.tag; + if (useJavaCache || + ReactNativeFeatureFlags::deferPreparedLayoutReactTagsToMountAndroid()) { + return preparedText->withDivergentReactTags(); } - auto javaReactTags = jni::JArrayInt::newArray(fragments.size()); - javaReactTags->setRegion( - 0, static_cast(reactTags.size()), reactTags.data()); + auto javaReactTags = makeReactTagsArray(attributedString); auto fabricUIManager = contextContainer_->at>("FabricUIManager"); @@ -378,6 +475,11 @@ TextMeasurement TextLayoutManager::measurePreparedLayout( const PreparedTextLayout& preparedLayout, const TextLayoutContext& /*layoutContext*/, const LayoutConstraints& layoutConstraints) const { + if (const auto* cached = + preparedLayout.cachedMeasurementFor(layoutConstraints)) { + return *cached; + } + auto fabricUIManager = contextContainer_->at>("FabricUIManager"); @@ -390,6 +492,69 @@ TextMeasurement TextLayoutManager::measurePreparedLayout( auto minimumSize = layoutConstraints.minimumSize; auto maximumSize = layoutConstraints.maximumSize; + if (preparedLayout.isCachedInJava()) { + static auto measurePreparedLayoutById = + jni::findClassStatic("com/facebook/react/fabric/FabricUIManager") + ->getMethod( + "measurePreparedLayoutById"); + + auto measurementsArr = measurePreparedLayoutById( + fabricUIManager, + preparedLayout.cacheId(), + minimumSize.width, + maximumSize.width, + minimumSize.height, + maximumSize.height); + if (measurementsArr != nullptr) { + return parseMeasurementsArray(measurementsArr); + } + + const auto* cachedAttributedString = + preparedLayout.cachedAttributedString(); + const auto* cachedParagraphAttributes = + preparedLayout.cachedParagraphAttributes(); + const auto* cachedConstraints = preparedLayout.cachedConstraints(); + react_native_assert( + cachedAttributedString != nullptr && + cachedParagraphAttributes != nullptr && cachedConstraints != nullptr); + + static auto prepareTextLayoutAndCache = + jni::findClassStatic("com/facebook/react/fabric/FabricUIManager") + ->getMethod("prepareTextLayoutAndCache"); + + auto attributedStringMB = JReadableMapBuffer::createWithContents( + toMapBuffer(*cachedAttributedString)); + auto paragraphAttributesMB = JReadableMapBuffer::createWithContents( + toMapBuffer(*cachedParagraphAttributes)); + auto rePrepared = prepareTextLayoutAndCache( + fabricUIManager, + preparedLayout.cacheId(), + attributedStringMB.get(), + paragraphAttributesMB.get(), + cachedConstraints->minimumSize.width, + cachedConstraints->maximumSize.width, + cachedConstraints->minimumSize.height, + cachedConstraints->maximumSize.height, + nullptr); + auto fallbackArr = measurePreparedLayout( + fabricUIManager, + rePrepared.get(), + minimumSize.width, + maximumSize.width, + minimumSize.height, + maximumSize.height); + return parseMeasurementsArray(fallbackArr); + } + auto measurementsArr = measurePreparedLayout( fabricUIManager, preparedLayout.get(), @@ -397,40 +562,76 @@ TextMeasurement TextLayoutManager::measurePreparedLayout( maximumSize.width, minimumSize.height, maximumSize.height); - auto measurements = measurementsArr->getRegion( - 0, static_cast(measurementsArr->size())); - - react_native_assert(measurementsArr->size() >= 2); - react_native_assert((measurementsArr->size() - 2) % 4 == 0); + return parseMeasurementsArray(measurementsArr); +} - TextMeasurement textMeasurement; +jni::local_ref +TextLayoutManager::resolvePreparedLayoutForMount( + const PreparedTextLayout& preparedLayout, + const AttributedString& attributedString, + const ParagraphAttributes& paragraphAttributes, + const LayoutConstraints& layoutConstraints) const { + auto fabricUIManager = + contextContainer_->at>("FabricUIManager"); - textMeasurement.size.width = measurements[0]; - textMeasurement.size.height = measurements[1]; + static auto getPreparedLayoutFromCache = + jni::findClassStatic("com/facebook/react/fabric/FabricUIManager") + ->getMethod( + "getPreparedLayoutFromCache"); - if (measurementsArr->size() > 2) { - textMeasurement.attachments.reserve((measurementsArr->size() - 2) / 4); - for (size_t i = 2; i < measurementsArr->size(); i += 4) { - auto top = measurements[i]; - auto left = measurements[i + 1]; - auto width = measurements[i + 2]; - auto height = measurements[i + 3]; + jni::local_ref javaReactTags; + if (preparedLayout.hasDivergentReactTags()) { + javaReactTags = makeReactTagsArray(attributedString); + } - if (std::isnan(top) || std::isnan(left)) { - textMeasurement.attachments.push_back( - TextMeasurement::Attachment{.frame = Rect{}, .isClipped = true}); - } else { - textMeasurement.attachments.push_back( - TextMeasurement::Attachment{ - .frame = - {.origin = {.x = left, .y = top}, - .size = {.width = width, .height = height}}, - .isClipped = false}); - } - } + auto cachedLayout = getPreparedLayoutFromCache( + fabricUIManager, preparedLayout.cacheId(), javaReactTags.get()); + if (cachedLayout != nullptr) { + return cachedLayout; } - return textMeasurement; + static auto prepareTextLayoutAndCache = + jni::findClassStatic("com/facebook/react/fabric/FabricUIManager") + ->getMethod("prepareTextLayoutAndCache"); + + // Re-cache using cacheId's canonical inputs so later mounts stay exact. + const auto& canonicalAttributedString = + preparedLayout.cachedAttributedString() != nullptr + ? *preparedLayout.cachedAttributedString() + : attributedString; + const auto& canonicalParagraphAttributes = + preparedLayout.cachedParagraphAttributes() != nullptr + ? *preparedLayout.cachedParagraphAttributes() + : paragraphAttributes; + const auto& canonicalConstraints = + preparedLayout.cachedConstraints() != nullptr + ? *preparedLayout.cachedConstraints() + : layoutConstraints; + auto attributedStringMB = JReadableMapBuffer::createWithContents( + toMapBuffer(canonicalAttributedString)); + auto paragraphAttributesMB = JReadableMapBuffer::createWithContents( + toMapBuffer(canonicalParagraphAttributes)); + auto minimumSize = canonicalConstraints.minimumSize; + auto maximumSize = canonicalConstraints.maximumSize; + + return prepareTextLayoutAndCache( + fabricUIManager, + preparedLayout.cacheId(), + attributedStringMB.get(), + paragraphAttributesMB.get(), + minimumSize.width, + maximumSize.width, + minimumSize.height, + maximumSize.height, + javaReactTags.get()); } } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h index dc2cfcd869dd..8828084e5855 100644 --- a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h +++ b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.h @@ -43,19 +43,89 @@ class TextLayoutManager { : ref_(std::make_shared>>(std::move(ref))) { } + PreparedTextLayout( + int64_t cacheId, + AttributedString attributedString, + ParagraphAttributes paragraphAttributes, + LayoutConstraints cachedConstraints, + TextMeasurement cachedMeasurement) + : javaCached_( + std::make_shared(JavaCachedLayout{ + .cacheId = cacheId, + .attributedString = std::move(attributedString), + .paragraphAttributes = std::move(paragraphAttributes), + .cachedConstraints = cachedConstraints, + .cachedMeasurement = std::move(cachedMeasurement)})) + { + } + + PreparedTextLayout withDivergentReactTags() const + { + PreparedTextLayout copy(*this); + copy.hasDivergentReactTags_ = true; + return copy; + } JPreparedLayout::javaobject get() const { return ref_ ? ref_->get() : nullptr; } + int64_t cacheId() const noexcept + { + return javaCached_ ? javaCached_->cacheId : 0; + } + + bool isCachedInJava() const noexcept + { + return javaCached_ != nullptr; + } + + bool hasDivergentReactTags() const noexcept + { + return hasDivergentReactTags_; + } + + const TextMeasurement *cachedMeasurementFor(const LayoutConstraints &layoutConstraints) const noexcept + { + if (javaCached_ && javaCached_->cachedConstraints == layoutConstraints) { + return &javaCached_->cachedMeasurement; + } + return nullptr; + } + + const AttributedString *cachedAttributedString() const noexcept + { + return javaCached_ ? &javaCached_->attributedString : nullptr; + } + + const ParagraphAttributes *cachedParagraphAttributes() const noexcept + { + return javaCached_ ? &javaCached_->paragraphAttributes : nullptr; + } + + const LayoutConstraints *cachedConstraints() const noexcept + { + return javaCached_ ? &javaCached_->cachedConstraints : nullptr; + } + explicit operator bool() const noexcept { - return ref_ && *ref_; + return (ref_ && *ref_) || javaCached_ != nullptr; } private: + struct JavaCachedLayout { + int64_t cacheId{0}; + AttributedString attributedString; + ParagraphAttributes paragraphAttributes; + LayoutConstraints cachedConstraints{}; + TextMeasurement cachedMeasurement; + }; + std::shared_ptr>> ref_; + std::shared_ptr javaCached_; + bool hasDivergentReactTags_{false}; }; TextLayoutManager(const std::shared_ptr &contextContainer); @@ -118,6 +188,17 @@ class TextLayoutManager { const TextLayoutContext &layoutContext, const LayoutConstraints &layoutConstraints) const; + /** + * Resolve a Java-cached PreparedTextLayout into a local JNI reference for + * mounting, attaching fragment React tags when divergent and re-preparing on + * cache eviction. + */ + jni::local_ref resolvePreparedLayoutForMount( + const PreparedTextLayout &preparedLayout, + const AttributedString &attributedString, + const ParagraphAttributes ¶graphAttributes, + const LayoutConstraints &layoutConstraints) const; + private: std::shared_ptr contextContainer_; TextMeasureCache textMeasureCache_; diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js index ea7af7e6f9f6..f5d2ff7a1b8a 100644 --- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js +++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js @@ -82,6 +82,17 @@ const definitions: FeatureFlagDefinitions = { }, ossReleaseStage: 'stable', }, + deferPreparedLayoutReactTagsToMountAndroid: { + defaultValue: false, + metadata: { + dateAdded: '2026-12-04', + description: + 'When enabled, cached PreparedLayout objects are shared across ParagraphShadowNodes without creating new JNI global references for differing React tags; new React tags are attached via a local JNI reference on mount.', + expectedReleaseValue: true, + purpose: 'experimentation', + }, + ossReleaseStage: 'none', + }, deferTextInputTruncationIOS: { defaultValue: false, metadata: { @@ -1038,6 +1049,17 @@ const definitions: FeatureFlagDefinitions = { }, ossReleaseStage: 'none', }, + useJavaPreparedLayoutCacheAndroid: { + defaultValue: false, + metadata: { + dateAdded: '2026-12-04', + description: + 'When enabled, PreparedLayout instances are cached in a bounded Java-side LRU cache keyed by opaque ID rather than held via JNI global references from C++.', + expectedReleaseValue: true, + purpose: 'experimentation', + }, + ossReleaseStage: 'none', + }, useNativeViewConfigsInBridgelessMode: { defaultValue: false, metadata: { diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js index 555b30cbada4..34c0744a3ca4 100644 --- a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js +++ b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js @@ -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<> + * @generated SignedSource<> * @flow strict * @noformat */ @@ -52,6 +52,7 @@ export type ReactNativeFeatureFlags = Readonly<{ commonTestFlagWithoutNativeImplementation: Getter, cdpInteractionMetricsEnabled: Getter, cxxNativeAnimatedEnabled: Getter, + deferPreparedLayoutReactTagsToMountAndroid: Getter, deferTextInputTruncationIOS: Getter, disableEarlyViewCommandExecution: Getter, disableIdleEventDispatchFrameCallbackRearmAndroid: Getter, @@ -141,6 +142,7 @@ export type ReactNativeFeatureFlags = Readonly<{ updateRuntimeShadowNodeReferencesOnCommitThread: Getter, useAlwaysAvailableJSErrorHandling: Getter, useFabricInterop: Getter, + useJavaPreparedLayoutCacheAndroid: Getter, useNativeViewConfigsInBridgelessMode: Getter, useNestedScrollViewAndroid: Getter, useSharedAnimatedBackend: Getter, @@ -239,6 +241,10 @@ export const cdpInteractionMetricsEnabled: Getter = createNativeFlagGet * Use a C++ implementation of Native Animated instead of the platform implementation. */ export const cxxNativeAnimatedEnabled: Getter = createNativeFlagGetter('cxxNativeAnimatedEnabled', true); +/** + * When enabled, cached PreparedLayout objects are shared across ParagraphShadowNodes without creating new JNI global references for differing React tags; new React tags are attached via a local JNI reference on mount. + */ +export const deferPreparedLayoutReactTagsToMountAndroid: Getter = createNativeFlagGetter('deferPreparedLayoutReactTagsToMountAndroid', false); /** * When enabled, iOS TextInput applies edits that JS transforms (e.g. maxLength truncation) incrementally after the UIKit text change delegate call returns, avoiding synchronous text and selection rewrites that can deadlock UIKeyboardTaskQueue. */ @@ -595,6 +601,10 @@ export const useAlwaysAvailableJSErrorHandling: Getter = createNativeFl * Should this application enable the Fabric Interop Layer for Android? If yes, the application will behave so that it can accept non-Fabric components and render them on Fabric. This toggle is controlling extra logic such as custom event dispatching that are needed for the Fabric Interop Layer to work correctly. */ export const useFabricInterop: Getter = createNativeFlagGetter('useFabricInterop', true); +/** + * When enabled, PreparedLayout instances are cached in a bounded Java-side LRU cache keyed by opaque ID rather than held via JNI global references from C++. + */ +export const useJavaPreparedLayoutCacheAndroid: Getter = createNativeFlagGetter('useJavaPreparedLayoutCacheAndroid', false); /** * When enabled, the native view configs are used in bridgeless mode. */ diff --git a/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js index e57521d114f1..7060c5be903c 100644 --- a/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +++ b/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js @@ -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<<41998e5b85bd36d407898c1ee516c76e>> + * @generated SignedSource<> * @flow strict * @noformat */ @@ -28,6 +28,7 @@ export interface Spec extends TurboModule { readonly commonTestFlagWithoutNativeImplementation?: () => boolean; readonly cdpInteractionMetricsEnabled?: () => boolean; readonly cxxNativeAnimatedEnabled?: () => boolean; + readonly deferPreparedLayoutReactTagsToMountAndroid?: () => boolean; readonly deferTextInputTruncationIOS?: () => boolean; readonly disableEarlyViewCommandExecution?: () => boolean; readonly disableIdleEventDispatchFrameCallbackRearmAndroid?: () => boolean; @@ -117,6 +118,7 @@ export interface Spec extends TurboModule { readonly updateRuntimeShadowNodeReferencesOnCommitThread?: () => boolean; readonly useAlwaysAvailableJSErrorHandling?: () => boolean; readonly useFabricInterop?: () => boolean; + readonly useJavaPreparedLayoutCacheAndroid?: () => boolean; readonly useNativeViewConfigsInBridgelessMode?: () => boolean; readonly useNestedScrollViewAndroid?: () => boolean; readonly useSharedAnimatedBackend?: () => boolean; diff --git a/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api b/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api index 0cf931d8a049..bcea7fe7c093 100644 --- a/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAndroidFrameworksCxx.api @@ -4039,12 +4039,22 @@ class facebook::react::TextLayoutManager { public facebook::react::TextMeasurement measure(const facebook::react::AttributedStringBox& attributedStringBox, const facebook::react::ParagraphAttributes& paragraphAttributes, const facebook::react::TextLayoutContext& layoutContext, const facebook::react::LayoutConstraints& layoutConstraints) const; public facebook::react::TextMeasurement measureCachedSpannableById(int64_t cacheId, const facebook::react::ParagraphAttributes& paragraphAttributes, const facebook::react::TextLayoutContext& layoutContext, const facebook::react::LayoutConstraints& layoutConstraints) const; public facebook::react::TextMeasurement measurePreparedLayout(const facebook::react::TextLayoutManager::PreparedTextLayout& layout, const facebook::react::TextLayoutContext& layoutContext, const facebook::react::LayoutConstraints& layoutConstraints) const; + public jni::local_ref resolvePreparedLayoutForMount(const facebook::react::TextLayoutManager::PreparedTextLayout& preparedLayout, const facebook::react::AttributedString& attributedString, const facebook::react::ParagraphAttributes& paragraphAttributes, const facebook::react::LayoutConstraints& layoutConstraints) const; } class facebook::react::TextLayoutManager::PreparedTextLayout { public JPreparedLayout::javaobject get() const; public PreparedTextLayout() = default; + public PreparedTextLayout(int64_t cacheId, facebook::react::AttributedString attributedString, facebook::react::ParagraphAttributes paragraphAttributes, facebook::react::LayoutConstraints cachedConstraints, facebook::react::TextMeasurement cachedMeasurement); public PreparedTextLayout(jni::global_ref ref); + public bool hasDivergentReactTags() const noexcept; + public bool isCachedInJava() const noexcept; + public const facebook::react::AttributedString* cachedAttributedString() const noexcept; + public const facebook::react::LayoutConstraints* cachedConstraints() const noexcept; + public const facebook::react::ParagraphAttributes* cachedParagraphAttributes() const noexcept; + public const facebook::react::TextMeasurement* cachedMeasurementFor(const facebook::react::LayoutConstraints& layoutConstraints) const noexcept; + public facebook::react::TextLayoutManager::PreparedTextLayout withDivergentReactTags() const; + public int64_t cacheId() const noexcept; public operator bool() const noexcept; }