From 0f7274dfcf185a49398f9fd9881114fc8e302c26 Mon Sep 17 00:00:00 2001 From: David Vacca <515103+mdvacca@users.noreply.github.com> Date: Thu, 25 Jul 2024 15:17:53 -0700 Subject: [PATCH] Migrate enableEagerRootViewAttachment to ReactNativeFeatureFlags (#45604) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45604 Migrate enableEagerRootViewAttachment to ReactNativeFeatureFlags changelog: [internal] internal Reviewed By: NickGerleman Differential Revision: D60022934 --- .../ReactAndroid/api/ReactAndroid.api | 1 - .../com/facebook/react/ReactRootView.java | 3 +- .../react/config/ReactFeatureFlags.java | 3 - .../featureflags/ReactNativeFeatureFlags.kt | 8 +- .../ReactNativeFeatureFlagsCxxAccessor.kt | 12 ++- .../ReactNativeFeatureFlagsCxxInterop.kt | 4 +- .../ReactNativeFeatureFlagsDefaults.kt | 4 +- .../ReactNativeFeatureFlagsLocalAccessor.kt | 13 +++- .../ReactNativeFeatureFlagsProvider.kt | 4 +- .../JReactNativeFeatureFlagsCxxInterop.cpp | 16 +++- .../JReactNativeFeatureFlagsCxxInterop.h | 5 +- .../java/com/facebook/react/RootViewTest.kt | 10 +++ .../featureflags/ReactNativeFeatureFlags.cpp | 6 +- .../featureflags/ReactNativeFeatureFlags.h | 7 +- .../ReactNativeFeatureFlagsAccessor.cpp | 76 ++++++++++++------- .../ReactNativeFeatureFlagsAccessor.h | 6 +- .../ReactNativeFeatureFlagsDefaults.h | 6 +- .../ReactNativeFeatureFlagsProvider.h | 3 +- .../NativeReactNativeFeatureFlags.cpp | 7 +- .../NativeReactNativeFeatureFlags.h | 4 +- .../ReactNativeFeatureFlags.config.js | 5 ++ .../featureflags/ReactNativeFeatureFlags.js | 7 +- .../specs/NativeReactNativeFeatureFlags.js | 3 +- 23 files changed, 161 insertions(+), 52 deletions(-) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 8afeee79e05f9f..781f542a8a91e2 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -1965,7 +1965,6 @@ public class com/facebook/react/config/ReactFeatureFlags { public static field dispatchPointerEvents Z public static field enableBridgelessArchitecture Z public static field enableCppPropsIteratorSetter Z - public static field enableEagerRootViewAttachment Z public static field enableFabricLogs Z public static field enableFabricRenderer Z public static field enableViewRecycling Z diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index 9b52b1bea3dd96..f08550eebed950 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -49,6 +49,7 @@ import com.facebook.react.bridge.WritableNativeMap; import com.facebook.react.common.annotations.VisibleForTesting; import com.facebook.react.config.ReactFeatureFlags; +import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags; import com.facebook.react.modules.appregistry.AppRegistry; import com.facebook.react.modules.deviceinfo.DeviceInfoModule; import com.facebook.react.uimanager.DisplayMetricsHolder; @@ -478,7 +479,7 @@ public void startReactApplication( mReactInstanceManager.createReactContextInBackground(); // if in this experiment, we initialize the root earlier in startReactApplication // instead of waiting for the initial measure - if (ReactFeatureFlags.enableEagerRootViewAttachment) { + if (ReactNativeFeatureFlags.enableEagerRootViewAttachment()) { if (!mWasMeasured) { // Ideally, those values will be used by default, but we only update them here to scope // this change to `enableEagerRootViewAttachment` experiment. diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index 0e16c506580031..8185b718f13e17 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -61,9 +61,6 @@ public class ReactFeatureFlags { /** This feature flag enables logs for Fabric */ public static boolean enableFabricLogs = false; - /** Feature flag to configure eager attachment of the root view/initialisation of the JS code */ - public static boolean enableEagerRootViewAttachment = false; - public static boolean dispatchPointerEvents = false; /** 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 ace6da52e8b81d..c7ca2d4a163d68 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<> + * @generated SignedSource<> */ /** @@ -82,6 +82,12 @@ public object ReactNativeFeatureFlags { @JvmStatic public fun enableCleanTextInputYogaNode(): Boolean = accessor.enableCleanTextInputYogaNode() + /** + * Feature flag to configure eager attachment of the root view/initialisation of the JS code. + */ + @JvmStatic + public fun enableEagerRootViewAttachment(): Boolean = accessor.enableEagerRootViewAttachment() + /** * When the app is completely migrated to Fabric, set this flag to true to disable parts of Paper infrastructure that are not needed anymore but consume memory and CPU. Specifically, UIViewOperationQueue and EventDispatcherImpl will no longer work as they will not subscribe to ReactChoreographer for updates. */ 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 0b3ceebbcf2d95..464d26388204b7 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<<2a8d5ca8a0ac46b4d3177cb8b12ad7ac>> + * @generated SignedSource<<0341c3c0f1eb484c305ee8732d6fd26f>> */ /** @@ -29,6 +29,7 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso private var destroyFabricSurfacesInReactInstanceManagerCache: Boolean? = null private var enableAlignItemsBaselineOnFabricIOSCache: Boolean? = null private var enableCleanTextInputYogaNodeCache: Boolean? = null + private var enableEagerRootViewAttachmentCache: Boolean? = null private var enableFabricRendererExclusivelyCache: Boolean? = null private var enableGranularShadowTreeStateReconciliationCache: Boolean? = null private var enableLongTaskAPICache: Boolean? = null @@ -139,6 +140,15 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso return cached } + override fun enableEagerRootViewAttachment(): Boolean { + var cached = enableEagerRootViewAttachmentCache + if (cached == null) { + cached = ReactNativeFeatureFlagsCxxInterop.enableEagerRootViewAttachment() + enableEagerRootViewAttachmentCache = cached + } + return cached + } + override fun enableFabricRendererExclusively(): Boolean { var cached = enableFabricRendererExclusivelyCache 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 48394927c533d3..74c8bf6d602409 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<<82a0b829cbc75d864dba1ae4c65b2036>> */ /** @@ -46,6 +46,8 @@ public object ReactNativeFeatureFlagsCxxInterop { @DoNotStrip @JvmStatic public external fun enableCleanTextInputYogaNode(): Boolean + @DoNotStrip @JvmStatic public external fun enableEagerRootViewAttachment(): Boolean + @DoNotStrip @JvmStatic public external fun enableFabricRendererExclusively(): Boolean @DoNotStrip @JvmStatic public external fun enableGranularShadowTreeStateReconciliation(): 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 c229e8d69b91e8..9dbefd116e1817 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<<7a16361098f54ac7a114d511fce10825>> */ /** @@ -41,6 +41,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi override fun enableCleanTextInputYogaNode(): Boolean = false + override fun enableEagerRootViewAttachment(): Boolean = false + override fun enableFabricRendererExclusively(): Boolean = false override fun enableGranularShadowTreeStateReconciliation(): 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 6575e5f9146025..c9fb9929e553fb 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<<82f6d4eda4011bee81810af366f5d677>> + * @generated SignedSource<<833b024aec14737d59abd02092fcfa11>> */ /** @@ -33,6 +33,7 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces private var destroyFabricSurfacesInReactInstanceManagerCache: Boolean? = null private var enableAlignItemsBaselineOnFabricIOSCache: Boolean? = null private var enableCleanTextInputYogaNodeCache: Boolean? = null + private var enableEagerRootViewAttachmentCache: Boolean? = null private var enableFabricRendererExclusivelyCache: Boolean? = null private var enableGranularShadowTreeStateReconciliationCache: Boolean? = null private var enableLongTaskAPICache: Boolean? = null @@ -152,6 +153,16 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces return cached } + override fun enableEagerRootViewAttachment(): Boolean { + var cached = enableEagerRootViewAttachmentCache + if (cached == null) { + cached = currentProvider.enableEagerRootViewAttachment() + accessedFeatureFlags.add("enableEagerRootViewAttachment") + enableEagerRootViewAttachmentCache = cached + } + return cached + } + override fun enableFabricRendererExclusively(): Boolean { var cached = enableFabricRendererExclusivelyCache 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 0184ee6e5772e4..54539a13d06d0f 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<<69c396cad1d473c5793df517fa183f95>> */ /** @@ -41,6 +41,8 @@ public interface ReactNativeFeatureFlagsProvider { @DoNotStrip public fun enableCleanTextInputYogaNode(): Boolean + @DoNotStrip public fun enableEagerRootViewAttachment(): Boolean + @DoNotStrip public fun enableFabricRendererExclusively(): Boolean @DoNotStrip public fun enableGranularShadowTreeStateReconciliation(): Boolean 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 5719d853bcfc3b..8d1526883e516a 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<<7c14f956fd20226acfb532d806c6eb7a>> + * @generated SignedSource<> */ /** @@ -93,6 +93,12 @@ class ReactNativeFeatureFlagsProviderHolder return method(javaProvider_); } + bool enableEagerRootViewAttachment() override { + static const auto method = + getReactNativeFeatureFlagsProviderJavaClass()->getMethod("enableEagerRootViewAttachment"); + return method(javaProvider_); + } + bool enableFabricRendererExclusively() override { static const auto method = getReactNativeFeatureFlagsProviderJavaClass()->getMethod("enableFabricRendererExclusively"); @@ -310,6 +316,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableCleanTextInputYogaNode( return ReactNativeFeatureFlags::enableCleanTextInputYogaNode(); } +bool JReactNativeFeatureFlagsCxxInterop::enableEagerRootViewAttachment( + facebook::jni::alias_ref /*unused*/) { + return ReactNativeFeatureFlags::enableEagerRootViewAttachment(); +} + bool JReactNativeFeatureFlagsCxxInterop::enableFabricRendererExclusively( facebook::jni::alias_ref /*unused*/) { return ReactNativeFeatureFlags::enableFabricRendererExclusively(); @@ -494,6 +505,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() { makeNativeMethod( "enableCleanTextInputYogaNode", JReactNativeFeatureFlagsCxxInterop::enableCleanTextInputYogaNode), + makeNativeMethod( + "enableEagerRootViewAttachment", + JReactNativeFeatureFlagsCxxInterop::enableEagerRootViewAttachment), makeNativeMethod( "enableFabricRendererExclusively", JReactNativeFeatureFlagsCxxInterop::enableFabricRendererExclusively), 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 4847c7e89f5c2a..b2a94d38a298c5 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<> + * @generated SignedSource<<1722d711f77b3f47cc3c665fce026b5a>> */ /** @@ -57,6 +57,9 @@ class JReactNativeFeatureFlagsCxxInterop static bool enableCleanTextInputYogaNode( facebook::jni::alias_ref); + static bool enableEagerRootViewAttachment( + facebook::jni::alias_ref); + static bool enableFabricRendererExclusively( facebook::jni::alias_ref); diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.kt index 31855f2dba8f0b..e8f4604cf0efd7 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/RootViewTest.kt @@ -24,6 +24,7 @@ import com.facebook.react.bridge.ReactTestHelper import com.facebook.react.bridge.WritableArray import com.facebook.react.bridge.WritableMap import com.facebook.react.common.SystemClock +import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags import com.facebook.react.uimanager.DisplayMetricsHolder import com.facebook.react.uimanager.UIManagerModule import com.facebook.react.uimanager.events.Event @@ -54,8 +55,16 @@ class RootViewTest { private lateinit var arguments: MockedStatic private lateinit var systemClock: MockedStatic + private lateinit var featureFlags: MockedStatic + @Before fun setUp() { + // Avoid trying to load ReactNativeFeatureFlags JNI library + featureFlags = mockStatic(ReactNativeFeatureFlags::class.java) + featureFlags + .`when` { ReactNativeFeatureFlags.enableEagerRootViewAttachment() } + .thenAnswer { false } + arguments = Mockito.mockStatic(Arguments::class.java) arguments.`when` { Arguments.createArray() }.thenAnswer { JavaOnlyArray() } arguments.`when` { Arguments.createMap() }.thenAnswer { JavaOnlyMap() } @@ -78,6 +87,7 @@ class RootViewTest { fun tearDown() { systemClock.close() arguments.close() + featureFlags.close() } @Test diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp index 4f06af9e6dabb8..05472a54377e38 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<> + * @generated SignedSource<<459682475d0fcefcdfce6ebeb7d1db19>> */ /** @@ -57,6 +57,10 @@ bool ReactNativeFeatureFlags::enableCleanTextInputYogaNode() { return getAccessor().enableCleanTextInputYogaNode(); } +bool ReactNativeFeatureFlags::enableEagerRootViewAttachment() { + return getAccessor().enableEagerRootViewAttachment(); +} + bool ReactNativeFeatureFlags::enableFabricRendererExclusively() { return getAccessor().enableFabricRendererExclusively(); } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h index 4fe7c6ae6f921b..2e0ca68ae2b514 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<<55d6c0f7ab8abe8411194235ab362cd2>> + * @generated SignedSource<<83a6879d27dd7dbcb181f30c3b6f0225>> */ /** @@ -82,6 +82,11 @@ class ReactNativeFeatureFlags { */ RN_EXPORT static bool enableCleanTextInputYogaNode(); + /** + * Feature flag to configure eager attachment of the root view/initialisation of the JS code. + */ + RN_EXPORT static bool enableEagerRootViewAttachment(); + /** * When the app is completely migrated to Fabric, set this flag to true to disable parts of Paper infrastructure that are not needed anymore but consume memory and CPU. Specifically, UIViewOperationQueue and EventDispatcherImpl will no longer work as they will not subscribe to ReactChoreographer for updates. */ diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp index 875b1f3f50bcaf..f3d44dc622cafe 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<> + * @generated SignedSource<<35dd53999023a10892fa311732b995f5>> */ /** @@ -191,6 +191,24 @@ bool ReactNativeFeatureFlagsAccessor::enableCleanTextInputYogaNode() { return flagValue.value(); } +bool ReactNativeFeatureFlagsAccessor::enableEagerRootViewAttachment() { + auto flagValue = enableEagerRootViewAttachment_.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(9, "enableEagerRootViewAttachment"); + + flagValue = currentProvider_->enableEagerRootViewAttachment(); + enableEagerRootViewAttachment_ = flagValue; + } + + return flagValue.value(); +} + bool ReactNativeFeatureFlagsAccessor::enableFabricRendererExclusively() { auto flagValue = enableFabricRendererExclusively_.load(); @@ -200,7 +218,7 @@ bool ReactNativeFeatureFlagsAccessor::enableFabricRendererExclusively() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(9, "enableFabricRendererExclusively"); + markFlagAsAccessed(10, "enableFabricRendererExclusively"); flagValue = currentProvider_->enableFabricRendererExclusively(); enableFabricRendererExclusively_ = flagValue; @@ -218,7 +236,7 @@ bool ReactNativeFeatureFlagsAccessor::enableGranularShadowTreeStateReconciliatio // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(10, "enableGranularShadowTreeStateReconciliation"); + markFlagAsAccessed(11, "enableGranularShadowTreeStateReconciliation"); flagValue = currentProvider_->enableGranularShadowTreeStateReconciliation(); enableGranularShadowTreeStateReconciliation_ = flagValue; @@ -236,7 +254,7 @@ bool ReactNativeFeatureFlagsAccessor::enableLongTaskAPI() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(11, "enableLongTaskAPI"); + markFlagAsAccessed(12, "enableLongTaskAPI"); flagValue = currentProvider_->enableLongTaskAPI(); enableLongTaskAPI_ = flagValue; @@ -254,7 +272,7 @@ bool ReactNativeFeatureFlagsAccessor::enableMicrotasks() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(12, "enableMicrotasks"); + markFlagAsAccessed(13, "enableMicrotasks"); flagValue = currentProvider_->enableMicrotasks(); enableMicrotasks_ = flagValue; @@ -272,7 +290,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(13, "enablePropsUpdateReconciliationAndroid"); + markFlagAsAccessed(14, "enablePropsUpdateReconciliationAndroid"); flagValue = currentProvider_->enablePropsUpdateReconciliationAndroid(); enablePropsUpdateReconciliationAndroid_ = flagValue; @@ -290,7 +308,7 @@ bool ReactNativeFeatureFlagsAccessor::enableReportEventPaintTime() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(14, "enableReportEventPaintTime"); + markFlagAsAccessed(15, "enableReportEventPaintTime"); flagValue = currentProvider_->enableReportEventPaintTime(); enableReportEventPaintTime_ = flagValue; @@ -308,7 +326,7 @@ bool ReactNativeFeatureFlagsAccessor::enableSynchronousStateUpdates() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(15, "enableSynchronousStateUpdates"); + markFlagAsAccessed(16, "enableSynchronousStateUpdates"); flagValue = currentProvider_->enableSynchronousStateUpdates(); enableSynchronousStateUpdates_ = flagValue; @@ -326,7 +344,7 @@ bool ReactNativeFeatureFlagsAccessor::enableUIConsistency() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(16, "enableUIConsistency"); + markFlagAsAccessed(17, "enableUIConsistency"); flagValue = currentProvider_->enableUIConsistency(); enableUIConsistency_ = flagValue; @@ -344,7 +362,7 @@ bool ReactNativeFeatureFlagsAccessor::excludeYogaFromRawProps() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(17, "excludeYogaFromRawProps"); + markFlagAsAccessed(18, "excludeYogaFromRawProps"); flagValue = currentProvider_->excludeYogaFromRawProps(); excludeYogaFromRawProps_ = flagValue; @@ -362,7 +380,7 @@ bool ReactNativeFeatureFlagsAccessor::fetchImagesInViewPreallocation() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(18, "fetchImagesInViewPreallocation"); + markFlagAsAccessed(19, "fetchImagesInViewPreallocation"); flagValue = currentProvider_->fetchImagesInViewPreallocation(); fetchImagesInViewPreallocation_ = flagValue; @@ -380,7 +398,7 @@ bool ReactNativeFeatureFlagsAccessor::fixIncorrectScrollViewStateUpdateOnAndroid // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(19, "fixIncorrectScrollViewStateUpdateOnAndroid"); + markFlagAsAccessed(20, "fixIncorrectScrollViewStateUpdateOnAndroid"); flagValue = currentProvider_->fixIncorrectScrollViewStateUpdateOnAndroid(); fixIncorrectScrollViewStateUpdateOnAndroid_ = flagValue; @@ -398,7 +416,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(20, "fixMappingOfEventPrioritiesBetweenFabricAndReact"); + markFlagAsAccessed(21, "fixMappingOfEventPrioritiesBetweenFabricAndReact"); flagValue = currentProvider_->fixMappingOfEventPrioritiesBetweenFabricAndReact(); fixMappingOfEventPrioritiesBetweenFabricAndReact_ = flagValue; @@ -416,7 +434,7 @@ bool ReactNativeFeatureFlagsAccessor::fixMissedFabricStateUpdatesOnAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(21, "fixMissedFabricStateUpdatesOnAndroid"); + markFlagAsAccessed(22, "fixMissedFabricStateUpdatesOnAndroid"); flagValue = currentProvider_->fixMissedFabricStateUpdatesOnAndroid(); fixMissedFabricStateUpdatesOnAndroid_ = flagValue; @@ -434,7 +452,7 @@ bool ReactNativeFeatureFlagsAccessor::forceBatchingMountItemsOnAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(22, "forceBatchingMountItemsOnAndroid"); + markFlagAsAccessed(23, "forceBatchingMountItemsOnAndroid"); flagValue = currentProvider_->forceBatchingMountItemsOnAndroid(); forceBatchingMountItemsOnAndroid_ = flagValue; @@ -452,7 +470,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxEnabledDebug() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(23, "fuseboxEnabledDebug"); + markFlagAsAccessed(24, "fuseboxEnabledDebug"); flagValue = currentProvider_->fuseboxEnabledDebug(); fuseboxEnabledDebug_ = flagValue; @@ -470,7 +488,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(24, "fuseboxEnabledRelease"); + markFlagAsAccessed(25, "fuseboxEnabledRelease"); flagValue = currentProvider_->fuseboxEnabledRelease(); fuseboxEnabledRelease_ = flagValue; @@ -488,7 +506,7 @@ bool ReactNativeFeatureFlagsAccessor::initEagerTurboModulesOnNativeModulesQueueA // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(25, "initEagerTurboModulesOnNativeModulesQueueAndroid"); + markFlagAsAccessed(26, "initEagerTurboModulesOnNativeModulesQueueAndroid"); flagValue = currentProvider_->initEagerTurboModulesOnNativeModulesQueueAndroid(); initEagerTurboModulesOnNativeModulesQueueAndroid_ = flagValue; @@ -506,7 +524,7 @@ bool ReactNativeFeatureFlagsAccessor::lazyAnimationCallbacks() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(26, "lazyAnimationCallbacks"); + markFlagAsAccessed(27, "lazyAnimationCallbacks"); flagValue = currentProvider_->lazyAnimationCallbacks(); lazyAnimationCallbacks_ = flagValue; @@ -524,7 +542,7 @@ bool ReactNativeFeatureFlagsAccessor::loadVectorDrawablesOnImages() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(27, "loadVectorDrawablesOnImages"); + markFlagAsAccessed(28, "loadVectorDrawablesOnImages"); flagValue = currentProvider_->loadVectorDrawablesOnImages(); loadVectorDrawablesOnImages_ = flagValue; @@ -542,7 +560,7 @@ bool ReactNativeFeatureFlagsAccessor::setAndroidLayoutDirection() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(28, "setAndroidLayoutDirection"); + markFlagAsAccessed(29, "setAndroidLayoutDirection"); flagValue = currentProvider_->setAndroidLayoutDirection(); setAndroidLayoutDirection_ = flagValue; @@ -560,7 +578,7 @@ bool ReactNativeFeatureFlagsAccessor::useImmediateExecutorInAndroidBridgeless() // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(29, "useImmediateExecutorInAndroidBridgeless"); + markFlagAsAccessed(30, "useImmediateExecutorInAndroidBridgeless"); flagValue = currentProvider_->useImmediateExecutorInAndroidBridgeless(); useImmediateExecutorInAndroidBridgeless_ = flagValue; @@ -578,7 +596,7 @@ bool ReactNativeFeatureFlagsAccessor::useModernRuntimeScheduler() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(30, "useModernRuntimeScheduler"); + markFlagAsAccessed(31, "useModernRuntimeScheduler"); flagValue = currentProvider_->useModernRuntimeScheduler(); useModernRuntimeScheduler_ = flagValue; @@ -596,7 +614,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(31, "useNativeViewConfigsInBridgelessMode"); + markFlagAsAccessed(32, "useNativeViewConfigsInBridgelessMode"); flagValue = currentProvider_->useNativeViewConfigsInBridgelessMode(); useNativeViewConfigsInBridgelessMode_ = flagValue; @@ -614,7 +632,7 @@ bool ReactNativeFeatureFlagsAccessor::useNewReactImageViewBackgroundDrawing() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(32, "useNewReactImageViewBackgroundDrawing"); + markFlagAsAccessed(33, "useNewReactImageViewBackgroundDrawing"); flagValue = currentProvider_->useNewReactImageViewBackgroundDrawing(); useNewReactImageViewBackgroundDrawing_ = flagValue; @@ -632,7 +650,7 @@ bool ReactNativeFeatureFlagsAccessor::useOptimisedViewPreallocationOnAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(33, "useOptimisedViewPreallocationOnAndroid"); + markFlagAsAccessed(34, "useOptimisedViewPreallocationOnAndroid"); flagValue = currentProvider_->useOptimisedViewPreallocationOnAndroid(); useOptimisedViewPreallocationOnAndroid_ = flagValue; @@ -650,7 +668,7 @@ bool ReactNativeFeatureFlagsAccessor::useRuntimeShadowNodeReferenceUpdate() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(34, "useRuntimeShadowNodeReferenceUpdate"); + markFlagAsAccessed(35, "useRuntimeShadowNodeReferenceUpdate"); flagValue = currentProvider_->useRuntimeShadowNodeReferenceUpdate(); useRuntimeShadowNodeReferenceUpdate_ = flagValue; @@ -668,7 +686,7 @@ bool ReactNativeFeatureFlagsAccessor::useRuntimeShadowNodeReferenceUpdateOnLayou // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(35, "useRuntimeShadowNodeReferenceUpdateOnLayout"); + markFlagAsAccessed(36, "useRuntimeShadowNodeReferenceUpdateOnLayout"); flagValue = currentProvider_->useRuntimeShadowNodeReferenceUpdateOnLayout(); useRuntimeShadowNodeReferenceUpdateOnLayout_ = flagValue; @@ -686,7 +704,7 @@ bool ReactNativeFeatureFlagsAccessor::useStateAlignmentMechanism() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(36, "useStateAlignmentMechanism"); + markFlagAsAccessed(37, "useStateAlignmentMechanism"); flagValue = currentProvider_->useStateAlignmentMechanism(); useStateAlignmentMechanism_ = flagValue; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h index c3261cb03d1eaa..4204b8a58539c2 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<<9a44283006da4b6f6700dc2aa4520bc7>> */ /** @@ -40,6 +40,7 @@ class ReactNativeFeatureFlagsAccessor { bool destroyFabricSurfacesInReactInstanceManager(); bool enableAlignItemsBaselineOnFabricIOS(); bool enableCleanTextInputYogaNode(); + bool enableEagerRootViewAttachment(); bool enableFabricRendererExclusively(); bool enableGranularShadowTreeStateReconciliation(); bool enableLongTaskAPI(); @@ -78,7 +79,7 @@ class ReactNativeFeatureFlagsAccessor { std::unique_ptr currentProvider_; bool wasOverridden_; - std::array, 37> accessedFeatureFlags_; + std::array, 38> accessedFeatureFlags_; std::atomic> commonTestFlag_; std::atomic> allowCollapsableChildren_; @@ -89,6 +90,7 @@ class ReactNativeFeatureFlagsAccessor { std::atomic> destroyFabricSurfacesInReactInstanceManager_; std::atomic> enableAlignItemsBaselineOnFabricIOS_; std::atomic> enableCleanTextInputYogaNode_; + std::atomic> enableEagerRootViewAttachment_; std::atomic> enableFabricRendererExclusively_; std::atomic> enableGranularShadowTreeStateReconciliation_; std::atomic> enableLongTaskAPI_; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h index d8a87d08373658..a1a6abd6d11f94 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<<436dd66c962b5bd70cc574d573ddfc0a>> + * @generated SignedSource<> */ /** @@ -63,6 +63,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider { return false; } + bool enableEagerRootViewAttachment() override { + return false; + } + bool enableFabricRendererExclusively() override { return false; } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h index 8d044153ae659c..d97d39c2fc65e3 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<<48be14c9be6da39c4acbf449d9ec8741>> + * @generated SignedSource<<23af20797f2656d3acc95b65d394ab37>> */ /** @@ -34,6 +34,7 @@ class ReactNativeFeatureFlagsProvider { virtual bool destroyFabricSurfacesInReactInstanceManager() = 0; virtual bool enableAlignItemsBaselineOnFabricIOS() = 0; virtual bool enableCleanTextInputYogaNode() = 0; + virtual bool enableEagerRootViewAttachment() = 0; virtual bool enableFabricRendererExclusively() = 0; virtual bool enableGranularShadowTreeStateReconciliation() = 0; virtual bool enableLongTaskAPI() = 0; diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp index 4ddfea42f3f031..521df1ec997fda 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<> + * @generated SignedSource<> */ /** @@ -82,6 +82,11 @@ bool NativeReactNativeFeatureFlags::enableCleanTextInputYogaNode( return ReactNativeFeatureFlags::enableCleanTextInputYogaNode(); } +bool NativeReactNativeFeatureFlags::enableEagerRootViewAttachment( + jsi::Runtime& /*runtime*/) { + return ReactNativeFeatureFlags::enableEagerRootViewAttachment(); +} + bool NativeReactNativeFeatureFlags::enableFabricRendererExclusively( jsi::Runtime& /*runtime*/) { return ReactNativeFeatureFlags::enableFabricRendererExclusively(); diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h index ffee73a8b3b758..8204a311755dd1 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<> + * @generated SignedSource<<0ccdff52b79d102449efeb684b1d5fac>> */ /** @@ -53,6 +53,8 @@ class NativeReactNativeFeatureFlags bool enableCleanTextInputYogaNode(jsi::Runtime& runtime); + bool enableEagerRootViewAttachment(jsi::Runtime& runtime); + bool enableFabricRendererExclusively(jsi::Runtime& runtime); bool enableGranularShadowTreeStateReconciliation(jsi::Runtime& runtime); diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js index f092601a56ad1d..59e22f7f785162 100644 --- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js +++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js @@ -78,6 +78,11 @@ const definitions: FeatureFlagDefinitions = { defaultValue: false, description: 'Clean yoga node when does not change.', }, + enableEagerRootViewAttachment: { + defaultValue: false, + description: + 'Feature flag to configure eager attachment of the root view/initialisation of the JS code.', + }, enableFabricRendererExclusively: { defaultValue: false, description: diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js index f396bc2e38f85b..b0c3b89e79d88f 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<<54cf84552d315ee05d38f52e907cec65>> * @flow strict-local */ @@ -53,6 +53,7 @@ export type ReactNativeFeatureFlags = { destroyFabricSurfacesInReactInstanceManager: Getter, enableAlignItemsBaselineOnFabricIOS: Getter, enableCleanTextInputYogaNode: Getter, + enableEagerRootViewAttachment: Getter, enableFabricRendererExclusively: Getter, enableGranularShadowTreeStateReconciliation: Getter, enableLongTaskAPI: Getter, @@ -179,6 +180,10 @@ export const enableAlignItemsBaselineOnFabricIOS: Getter = createNative * Clean yoga node when does not change. */ export const enableCleanTextInputYogaNode: Getter = createNativeFlagGetter('enableCleanTextInputYogaNode', false); +/** + * Feature flag to configure eager attachment of the root view/initialisation of the JS code. + */ +export const enableEagerRootViewAttachment: Getter = createNativeFlagGetter('enableEagerRootViewAttachment', false); /** * When the app is completely migrated to Fabric, set this flag to true to disable parts of Paper infrastructure that are not needed anymore but consume memory and CPU. Specifically, UIViewOperationQueue and EventDispatcherImpl will no longer work as they will not subscribe to ReactChoreographer for updates. */ diff --git a/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js index 39090d741680a8..c28d03c8e9505e 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<> + * @generated SignedSource<<1b5138c76e8bf814bc85340c9a734744>> * @flow strict-local */ @@ -32,6 +32,7 @@ export interface Spec extends TurboModule { +destroyFabricSurfacesInReactInstanceManager?: () => boolean; +enableAlignItemsBaselineOnFabricIOS?: () => boolean; +enableCleanTextInputYogaNode?: () => boolean; + +enableEagerRootViewAttachment?: () => boolean; +enableFabricRendererExclusively?: () => boolean; +enableGranularShadowTreeStateReconciliation?: () => boolean; +enableLongTaskAPI?: () => boolean;