From bd8b0213afb89b07f4d0d686598310e5d175d13e Mon Sep 17 00:00:00 2001 From: David Vacca <515103+mdvacca@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:44:40 -0700 Subject: [PATCH 1/2] Migrate enableFabricRendererExclusively to ReactNativeFeatureFlags Summary: Migrate enableFabricRendererExclusively to ReactNativeFeatureFlags changelog: [internal] internal Differential Revision: D60022933 --- .../ReactAndroid/api/ReactAndroid.api | 1 - .../react/config/ReactFeatureFlags.java | 8 --- .../featureflags/ReactNativeFeatureFlags.kt | 8 ++- .../ReactNativeFeatureFlagsCxxAccessor.kt | 12 +++- .../ReactNativeFeatureFlagsCxxInterop.kt | 4 +- .../ReactNativeFeatureFlagsDefaults.kt | 4 +- .../ReactNativeFeatureFlagsLocalAccessor.kt | 13 +++- .../ReactNativeFeatureFlagsProvider.kt | 4 +- .../react/uimanager/UIViewOperationQueue.java | 4 +- .../uimanager/events/EventDispatcherImpl.java | 4 +- .../JReactNativeFeatureFlagsCxxInterop.cpp | 16 ++++- .../JReactNativeFeatureFlagsCxxInterop.h | 5 +- .../featureflags/ReactNativeFeatureFlags.cpp | 6 +- .../featureflags/ReactNativeFeatureFlags.h | 7 +- .../ReactNativeFeatureFlagsAccessor.cpp | 68 ++++++++++++------- .../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, 149 insertions(+), 56 deletions(-) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 8cc66c6cd974..dc404a3b849b 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -1968,7 +1968,6 @@ public class com/facebook/react/config/ReactFeatureFlags { public static field enableEagerRootViewAttachment Z public static field enableFabricLogs Z public static field enableFabricRenderer Z - public static field enableFabricRendererExclusively Z public static field enableViewRecycling Z public static field excludeYogaFromRawProps Z public static field rejectTurboModulePromiseOnNativeError Z 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 4f38fe0cc5a1..4327e9e87cbb 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 @@ -90,12 +90,4 @@ public class ReactFeatureFlags { * in JS will be rejected (The JS error will include native stack) */ public static boolean rejectTurboModulePromiseOnNativeError = true; - - /* - * 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 won't subscribe to ReactChoreographer for updates. - */ - public static boolean enableFabricRendererExclusively = 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 3fd9cab87e06..26ba789a1e9d 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<<687c29d850df9a857749d06c54cbddb7>> + * @generated SignedSource<<74d986b082e44be1b358d5442f4d133d>> */ /** @@ -82,6 +82,12 @@ public object ReactNativeFeatureFlags { @JvmStatic public fun enableCleanTextInputYogaNode(): Boolean = accessor.enableCleanTextInputYogaNode() + /** + * 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. + */ + @JvmStatic + public fun enableFabricRendererExclusively(): Boolean = accessor.enableFabricRendererExclusively() + /** * When enabled, the renderer would only fail commits when they propagate state and the last commit that updated state changed before committing. */ 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 d015715e250c..55740dccbb75 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<> + * @generated SignedSource<<375e752a672912488b52e34f39b5ed8c>> */ /** @@ -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 enableFabricRendererExclusivelyCache: Boolean? = null private var enableGranularShadowTreeStateReconciliationCache: Boolean? = null private var enableLongTaskAPICache: Boolean? = null private var enableMicrotasksCache: Boolean? = null @@ -135,6 +136,15 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso return cached } + override fun enableFabricRendererExclusively(): Boolean { + var cached = enableFabricRendererExclusivelyCache + if (cached == null) { + cached = ReactNativeFeatureFlagsCxxInterop.enableFabricRendererExclusively() + enableFabricRendererExclusivelyCache = cached + } + return cached + } + override fun enableGranularShadowTreeStateReconciliation(): Boolean { var cached = enableGranularShadowTreeStateReconciliationCache 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 73489e6f07a8..137eaec170df 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<<143e35723bffbb6ba5be2cfa4a497f0b>> */ /** @@ -46,6 +46,8 @@ public object ReactNativeFeatureFlagsCxxInterop { @DoNotStrip @JvmStatic public external fun enableCleanTextInputYogaNode(): Boolean + @DoNotStrip @JvmStatic public external fun enableFabricRendererExclusively(): Boolean + @DoNotStrip @JvmStatic public external fun enableGranularShadowTreeStateReconciliation(): Boolean @DoNotStrip @JvmStatic public external fun enableLongTaskAPI(): 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 072db8e72a0d..7b86d2ed5c44 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<<8903d3fb0088fcdd9ac3e789299b8b6c>> + * @generated SignedSource<<841edbe102ebbd78040892cf76f79bba>> */ /** @@ -41,6 +41,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi override fun enableCleanTextInputYogaNode(): Boolean = false + override fun enableFabricRendererExclusively(): Boolean = false + override fun enableGranularShadowTreeStateReconciliation(): Boolean = false override fun enableLongTaskAPI(): 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 4e095d9baeed..b3a62e70eeb9 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<<58cd9d65067ed758ecad65ad22737b6c>> */ /** @@ -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 enableFabricRendererExclusivelyCache: Boolean? = null private var enableGranularShadowTreeStateReconciliationCache: Boolean? = null private var enableLongTaskAPICache: Boolean? = null private var enableMicrotasksCache: Boolean? = null @@ -148,6 +149,16 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces return cached } + override fun enableFabricRendererExclusively(): Boolean { + var cached = enableFabricRendererExclusivelyCache + if (cached == null) { + cached = currentProvider.enableFabricRendererExclusively() + accessedFeatureFlags.add("enableFabricRendererExclusively") + enableFabricRendererExclusivelyCache = cached + } + return cached + } + override fun enableGranularShadowTreeStateReconciliation(): Boolean { var cached = enableGranularShadowTreeStateReconciliationCache 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 ade464ad88c2..8749196c0fe7 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<<0284ff2541a06bfa36bb7049d47cb4d2>> + * @generated SignedSource<<7f753a763c3f4c0bcbdad268e32b21fb>> */ /** @@ -41,6 +41,8 @@ public interface ReactNativeFeatureFlagsProvider { @DoNotStrip public fun enableCleanTextInputYogaNode(): Boolean + @DoNotStrip public fun enableFabricRendererExclusively(): Boolean + @DoNotStrip public fun enableGranularShadowTreeStateReconciliation(): Boolean @DoNotStrip public fun enableLongTaskAPI(): Boolean diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java index ad07257fb1bf..40eaf820f216 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java @@ -25,7 +25,7 @@ import com.facebook.react.bridge.SoftAssertions; import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.common.ReactConstants; -import com.facebook.react.config.ReactFeatureFlags; +import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags; import com.facebook.react.modules.core.ReactChoreographer; import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener; import com.facebook.systrace.Systrace; @@ -928,7 +928,7 @@ public void runGuarded() { /* package */ void resumeFrameCallback() { mIsDispatchUIFrameCallbackEnqueued = true; - if (!ReactFeatureFlags.enableFabricRendererExclusively) { + if (!ReactNativeFeatureFlags.enableFabricRendererExclusively()) { ReactChoreographer.getInstance() .postFrameCallback(ReactChoreographer.CallbackType.DISPATCH_UI, mDispatchUIFrameCallback); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcherImpl.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcherImpl.java index b97726ce69ae..5411670b3083 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcherImpl.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcherImpl.java @@ -15,7 +15,7 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.common.MapBuilder; -import com.facebook.react.config.ReactFeatureFlags; +import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags; import com.facebook.react.modules.core.ReactChoreographer; import com.facebook.react.uimanager.common.UIManagerType; import com.facebook.systrace.Systrace; @@ -318,7 +318,7 @@ public void maybePost() { } private void post() { - if (!ReactFeatureFlags.enableFabricRendererExclusively) { + if (!ReactNativeFeatureFlags.enableFabricRendererExclusively()) { ReactChoreographer.getInstance() .postFrameCallback( ReactChoreographer.CallbackType.TIMERS_EVENTS, mCurrentFrameCallback); 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 fa825c68adf1..e81dc81ccd90 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<> */ /** @@ -93,6 +93,12 @@ class ReactNativeFeatureFlagsProviderHolder return method(javaProvider_); } + bool enableFabricRendererExclusively() override { + static const auto method = + getReactNativeFeatureFlagsProviderJavaClass()->getMethod("enableFabricRendererExclusively"); + return method(javaProvider_); + } + bool enableGranularShadowTreeStateReconciliation() override { static const auto method = getReactNativeFeatureFlagsProviderJavaClass()->getMethod("enableGranularShadowTreeStateReconciliation"); @@ -286,6 +292,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableCleanTextInputYogaNode( return ReactNativeFeatureFlags::enableCleanTextInputYogaNode(); } +bool JReactNativeFeatureFlagsCxxInterop::enableFabricRendererExclusively( + facebook::jni::alias_ref /*unused*/) { + return ReactNativeFeatureFlags::enableFabricRendererExclusively(); +} + bool JReactNativeFeatureFlagsCxxInterop::enableGranularShadowTreeStateReconciliation( facebook::jni::alias_ref /*unused*/) { return ReactNativeFeatureFlags::enableGranularShadowTreeStateReconciliation(); @@ -450,6 +461,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() { makeNativeMethod( "enableCleanTextInputYogaNode", JReactNativeFeatureFlagsCxxInterop::enableCleanTextInputYogaNode), + makeNativeMethod( + "enableFabricRendererExclusively", + JReactNativeFeatureFlagsCxxInterop::enableFabricRendererExclusively), makeNativeMethod( "enableGranularShadowTreeStateReconciliation", JReactNativeFeatureFlagsCxxInterop::enableGranularShadowTreeStateReconciliation), 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 0950344e1825..0383d197884e 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<<732d3c3f973e966f958945c566de2870>> + * @generated SignedSource<> */ /** @@ -57,6 +57,9 @@ class JReactNativeFeatureFlagsCxxInterop static bool enableCleanTextInputYogaNode( facebook::jni::alias_ref); + static bool enableFabricRendererExclusively( + facebook::jni::alias_ref); + static bool enableGranularShadowTreeStateReconciliation( facebook::jni::alias_ref); diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp index 57b88a764020..e84a46472290 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<<38c8d62457ec2b8c6333131c68dd4935>> + * @generated SignedSource<> */ /** @@ -57,6 +57,10 @@ bool ReactNativeFeatureFlags::enableCleanTextInputYogaNode() { return getAccessor().enableCleanTextInputYogaNode(); } +bool ReactNativeFeatureFlags::enableFabricRendererExclusively() { + return getAccessor().enableFabricRendererExclusively(); +} + bool ReactNativeFeatureFlags::enableGranularShadowTreeStateReconciliation() { return getAccessor().enableGranularShadowTreeStateReconciliation(); } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h index 5eda8e84567e..263744bf9bf2 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<<64e825121244867e1ee6b1b8e54158f2>> + * @generated SignedSource<<9a8e9432a444aaa9d997a91a77e17fa9>> */ /** @@ -82,6 +82,11 @@ class ReactNativeFeatureFlags { */ RN_EXPORT static bool enableCleanTextInputYogaNode(); + /** + * 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. + */ + RN_EXPORT static bool enableFabricRendererExclusively(); + /** * When enabled, the renderer would only fail commits when they propagate state and the last commit that updated state changed before committing. */ diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp index 97e58fbc5962..ea3bfa8c0c68 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<<7a2df536af010a897cf36295fccb9040>> */ /** @@ -191,6 +191,24 @@ bool ReactNativeFeatureFlagsAccessor::enableCleanTextInputYogaNode() { return flagValue.value(); } +bool ReactNativeFeatureFlagsAccessor::enableFabricRendererExclusively() { + auto flagValue = enableFabricRendererExclusively_.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, "enableFabricRendererExclusively"); + + flagValue = currentProvider_->enableFabricRendererExclusively(); + enableFabricRendererExclusively_ = flagValue; + } + + return flagValue.value(); +} + bool ReactNativeFeatureFlagsAccessor::enableGranularShadowTreeStateReconciliation() { auto flagValue = enableGranularShadowTreeStateReconciliation_.load(); @@ -200,7 +218,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(9, "enableGranularShadowTreeStateReconciliation"); + markFlagAsAccessed(10, "enableGranularShadowTreeStateReconciliation"); flagValue = currentProvider_->enableGranularShadowTreeStateReconciliation(); enableGranularShadowTreeStateReconciliation_ = flagValue; @@ -218,7 +236,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(10, "enableLongTaskAPI"); + markFlagAsAccessed(11, "enableLongTaskAPI"); flagValue = currentProvider_->enableLongTaskAPI(); enableLongTaskAPI_ = flagValue; @@ -236,7 +254,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(11, "enableMicrotasks"); + markFlagAsAccessed(12, "enableMicrotasks"); flagValue = currentProvider_->enableMicrotasks(); enableMicrotasks_ = flagValue; @@ -254,7 +272,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(12, "enablePropsUpdateReconciliationAndroid"); + markFlagAsAccessed(13, "enablePropsUpdateReconciliationAndroid"); flagValue = currentProvider_->enablePropsUpdateReconciliationAndroid(); enablePropsUpdateReconciliationAndroid_ = flagValue; @@ -272,7 +290,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(13, "enableSynchronousStateUpdates"); + markFlagAsAccessed(14, "enableSynchronousStateUpdates"); flagValue = currentProvider_->enableSynchronousStateUpdates(); enableSynchronousStateUpdates_ = flagValue; @@ -290,7 +308,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(14, "enableUIConsistency"); + markFlagAsAccessed(15, "enableUIConsistency"); flagValue = currentProvider_->enableUIConsistency(); enableUIConsistency_ = flagValue; @@ -308,7 +326,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(15, "fetchImagesInViewPreallocation"); + markFlagAsAccessed(16, "fetchImagesInViewPreallocation"); flagValue = currentProvider_->fetchImagesInViewPreallocation(); fetchImagesInViewPreallocation_ = flagValue; @@ -326,7 +344,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(16, "fixIncorrectScrollViewStateUpdateOnAndroid"); + markFlagAsAccessed(17, "fixIncorrectScrollViewStateUpdateOnAndroid"); flagValue = currentProvider_->fixIncorrectScrollViewStateUpdateOnAndroid(); fixIncorrectScrollViewStateUpdateOnAndroid_ = flagValue; @@ -344,7 +362,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(17, "fixMappingOfEventPrioritiesBetweenFabricAndReact"); + markFlagAsAccessed(18, "fixMappingOfEventPrioritiesBetweenFabricAndReact"); flagValue = currentProvider_->fixMappingOfEventPrioritiesBetweenFabricAndReact(); fixMappingOfEventPrioritiesBetweenFabricAndReact_ = flagValue; @@ -362,7 +380,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(18, "fixMissedFabricStateUpdatesOnAndroid"); + markFlagAsAccessed(19, "fixMissedFabricStateUpdatesOnAndroid"); flagValue = currentProvider_->fixMissedFabricStateUpdatesOnAndroid(); fixMissedFabricStateUpdatesOnAndroid_ = flagValue; @@ -380,7 +398,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(19, "forceBatchingMountItemsOnAndroid"); + markFlagAsAccessed(20, "forceBatchingMountItemsOnAndroid"); flagValue = currentProvider_->forceBatchingMountItemsOnAndroid(); forceBatchingMountItemsOnAndroid_ = flagValue; @@ -398,7 +416,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(20, "fuseboxEnabledDebug"); + markFlagAsAccessed(21, "fuseboxEnabledDebug"); flagValue = currentProvider_->fuseboxEnabledDebug(); fuseboxEnabledDebug_ = flagValue; @@ -416,7 +434,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(21, "fuseboxEnabledRelease"); + markFlagAsAccessed(22, "fuseboxEnabledRelease"); flagValue = currentProvider_->fuseboxEnabledRelease(); fuseboxEnabledRelease_ = flagValue; @@ -434,7 +452,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(22, "initEagerTurboModulesOnNativeModulesQueueAndroid"); + markFlagAsAccessed(23, "initEagerTurboModulesOnNativeModulesQueueAndroid"); flagValue = currentProvider_->initEagerTurboModulesOnNativeModulesQueueAndroid(); initEagerTurboModulesOnNativeModulesQueueAndroid_ = flagValue; @@ -452,7 +470,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(23, "lazyAnimationCallbacks"); + markFlagAsAccessed(24, "lazyAnimationCallbacks"); flagValue = currentProvider_->lazyAnimationCallbacks(); lazyAnimationCallbacks_ = flagValue; @@ -470,7 +488,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(24, "loadVectorDrawablesOnImages"); + markFlagAsAccessed(25, "loadVectorDrawablesOnImages"); flagValue = currentProvider_->loadVectorDrawablesOnImages(); loadVectorDrawablesOnImages_ = flagValue; @@ -488,7 +506,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(25, "setAndroidLayoutDirection"); + markFlagAsAccessed(26, "setAndroidLayoutDirection"); flagValue = currentProvider_->setAndroidLayoutDirection(); setAndroidLayoutDirection_ = flagValue; @@ -506,7 +524,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(26, "useImmediateExecutorInAndroidBridgeless"); + markFlagAsAccessed(27, "useImmediateExecutorInAndroidBridgeless"); flagValue = currentProvider_->useImmediateExecutorInAndroidBridgeless(); useImmediateExecutorInAndroidBridgeless_ = flagValue; @@ -524,7 +542,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(27, "useModernRuntimeScheduler"); + markFlagAsAccessed(28, "useModernRuntimeScheduler"); flagValue = currentProvider_->useModernRuntimeScheduler(); useModernRuntimeScheduler_ = flagValue; @@ -542,7 +560,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(28, "useNativeViewConfigsInBridgelessMode"); + markFlagAsAccessed(29, "useNativeViewConfigsInBridgelessMode"); flagValue = currentProvider_->useNativeViewConfigsInBridgelessMode(); useNativeViewConfigsInBridgelessMode_ = flagValue; @@ -560,7 +578,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(29, "useNewReactImageViewBackgroundDrawing"); + markFlagAsAccessed(30, "useNewReactImageViewBackgroundDrawing"); flagValue = currentProvider_->useNewReactImageViewBackgroundDrawing(); useNewReactImageViewBackgroundDrawing_ = flagValue; @@ -578,7 +596,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(30, "useRuntimeShadowNodeReferenceUpdate"); + markFlagAsAccessed(31, "useRuntimeShadowNodeReferenceUpdate"); flagValue = currentProvider_->useRuntimeShadowNodeReferenceUpdate(); useRuntimeShadowNodeReferenceUpdate_ = flagValue; @@ -596,7 +614,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(31, "useRuntimeShadowNodeReferenceUpdateOnLayout"); + markFlagAsAccessed(32, "useRuntimeShadowNodeReferenceUpdateOnLayout"); flagValue = currentProvider_->useRuntimeShadowNodeReferenceUpdateOnLayout(); useRuntimeShadowNodeReferenceUpdateOnLayout_ = flagValue; @@ -614,7 +632,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(32, "useStateAlignmentMechanism"); + markFlagAsAccessed(33, "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 72904401056f..120706787767 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<<34b4357de2df4d7b5a5022c7d29451d3>> + * @generated SignedSource<<8ba2e36038a0158a9bcfa5ba7603f2f5>> */ /** @@ -40,6 +40,7 @@ class ReactNativeFeatureFlagsAccessor { bool destroyFabricSurfacesInReactInstanceManager(); bool enableAlignItemsBaselineOnFabricIOS(); bool enableCleanTextInputYogaNode(); + bool enableFabricRendererExclusively(); bool enableGranularShadowTreeStateReconciliation(); bool enableLongTaskAPI(); bool enableMicrotasks(); @@ -74,7 +75,7 @@ class ReactNativeFeatureFlagsAccessor { std::unique_ptr currentProvider_; bool wasOverridden_; - std::array, 33> accessedFeatureFlags_; + std::array, 34> accessedFeatureFlags_; std::atomic> commonTestFlag_; std::atomic> allowCollapsableChildren_; @@ -85,6 +86,7 @@ class ReactNativeFeatureFlagsAccessor { std::atomic> destroyFabricSurfacesInReactInstanceManager_; std::atomic> enableAlignItemsBaselineOnFabricIOS_; std::atomic> enableCleanTextInputYogaNode_; + std::atomic> enableFabricRendererExclusively_; std::atomic> enableGranularShadowTreeStateReconciliation_; std::atomic> enableLongTaskAPI_; std::atomic> enableMicrotasks_; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h index 0264a02e1edc..f6ee78e41ad6 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<<308807b5ebe2d3d1d17452b73be2d82b>> + * @generated SignedSource<<2442bf826489b9fcc06afa172efa8d9d>> */ /** @@ -63,6 +63,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider { return false; } + bool enableFabricRendererExclusively() override { + return false; + } + bool enableGranularShadowTreeStateReconciliation() override { return false; } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h index 3b55a35033dc..406491351f55 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<<54eb612f9d3cb0c7214ed32263ab9318>> + * @generated SignedSource<<4cbbd04eb5f72a2e5f5414276c3561a5>> */ /** @@ -34,6 +34,7 @@ class ReactNativeFeatureFlagsProvider { virtual bool destroyFabricSurfacesInReactInstanceManager() = 0; virtual bool enableAlignItemsBaselineOnFabricIOS() = 0; virtual bool enableCleanTextInputYogaNode() = 0; + virtual bool enableFabricRendererExclusively() = 0; virtual bool enableGranularShadowTreeStateReconciliation() = 0; virtual bool enableLongTaskAPI() = 0; virtual bool enableMicrotasks() = 0; diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp index 5163a2133d5a..9eade36c7878 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<<601dcb3b536fc5452b51049c96383139>> + * @generated SignedSource<<8f5a7c45dad6a49355e0823bb6e16b3e>> */ /** @@ -82,6 +82,11 @@ bool NativeReactNativeFeatureFlags::enableCleanTextInputYogaNode( return ReactNativeFeatureFlags::enableCleanTextInputYogaNode(); } +bool NativeReactNativeFeatureFlags::enableFabricRendererExclusively( + jsi::Runtime& /*runtime*/) { + return ReactNativeFeatureFlags::enableFabricRendererExclusively(); +} + bool NativeReactNativeFeatureFlags::enableGranularShadowTreeStateReconciliation( jsi::Runtime& /*runtime*/) { return ReactNativeFeatureFlags::enableGranularShadowTreeStateReconciliation(); diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h index 0454be1baa42..5148d3ebf084 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<<6514becef3f2e550d7de6d089a2400db>> + * @generated SignedSource<<929fb57602a8fe468707047daa05a8a7>> */ /** @@ -53,6 +53,8 @@ class NativeReactNativeFeatureFlags bool enableCleanTextInputYogaNode(jsi::Runtime& runtime); + bool enableFabricRendererExclusively(jsi::Runtime& runtime); + bool enableGranularShadowTreeStateReconciliation(jsi::Runtime& runtime); bool enableLongTaskAPI(jsi::Runtime& runtime); diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js index 288def4c9963..26c9d92f807f 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.', }, + enableFabricRendererExclusively: { + defaultValue: false, + description: + '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.', + }, enableGranularShadowTreeStateReconciliation: { defaultValue: false, description: diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js index f16abfd470a7..13ecf9e34271 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<<34a6877ad6f40b5a43a833a66b5591ae>> + * @generated SignedSource<> * @flow strict-local */ @@ -52,6 +52,7 @@ export type ReactNativeFeatureFlags = { destroyFabricSurfacesInReactInstanceManager: Getter, enableAlignItemsBaselineOnFabricIOS: Getter, enableCleanTextInputYogaNode: Getter, + enableFabricRendererExclusively: Getter, enableGranularShadowTreeStateReconciliation: Getter, enableLongTaskAPI: Getter, enableMicrotasks: Getter, @@ -169,6 +170,10 @@ export const enableAlignItemsBaselineOnFabricIOS: Getter = createNative * Clean yoga node when does not change. */ export const enableCleanTextInputYogaNode: Getter = createNativeFlagGetter('enableCleanTextInputYogaNode', 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. + */ +export const enableFabricRendererExclusively: Getter = createNativeFlagGetter('enableFabricRendererExclusively', false); /** * When enabled, the renderer would only fail commits when they propagate state and the last commit that updated state changed before committing. */ diff --git a/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js index 7e3bc8b4d277..e12ab9eaabac 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<<20f7827abf86b1c39f676486bcf03d92>> * @flow strict-local */ @@ -32,6 +32,7 @@ export interface Spec extends TurboModule { +destroyFabricSurfacesInReactInstanceManager?: () => boolean; +enableAlignItemsBaselineOnFabricIOS?: () => boolean; +enableCleanTextInputYogaNode?: () => boolean; + +enableFabricRendererExclusively?: () => boolean; +enableGranularShadowTreeStateReconciliation?: () => boolean; +enableLongTaskAPI?: () => boolean; +enableMicrotasks?: () => boolean; From 55bfb19f6b8e005f7e2d744a84445853f19c4733 Mon Sep 17 00:00:00 2001 From: David Vacca <515103+mdvacca@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:44:40 -0700 Subject: [PATCH 2/2] Delete ReactFeatureFlags.rejectTurboModulePromiseOnNativeError (#45583) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45583 ReactFeatureFlags.rejectTurboModulePromiseOnNativeError is not used, I'm deleteing it changelog: [internal] internal Reviewed By: NickGerleman Differential Revision: D60022938 --- .../ReactAndroid/api/ReactAndroid.api | 1 - .../react/config/ReactFeatureFlags.java | 6 ------ .../android/ReactCommon/JavaTurboModule.cpp | 18 +++++------------- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index dc404a3b849b..cf049483a40f 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -1970,7 +1970,6 @@ public class com/facebook/react/config/ReactFeatureFlags { public static field enableFabricRenderer Z public static field enableViewRecycling Z public static field excludeYogaFromRawProps Z - public static field rejectTurboModulePromiseOnNativeError Z public static field traceTurboModulePromiseRejections Z public static field unstable_enableTurboModuleSyncVoidMethods Z public static field unstable_useFabricInterop Z 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 4327e9e87cbb..0412836ff34e 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 @@ -84,10 +84,4 @@ public class ReactFeatureFlags { * of Promise rejection and tracing the cause. */ public static boolean traceTurboModulePromiseRejections = ReactBuildConfig.DEBUG; - - /** - * Enables auto rejecting promises from Turbo Modules method calls. If native error occurs Promise - * in JS will be rejected (The JS error will include native stack) - */ - public static boolean rejectTurboModulePromiseOnNativeError = true; } diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp b/packages/react-native/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp index 52039dd6cdb3..9bbde075ad64 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp +++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp @@ -75,12 +75,6 @@ bool traceTurboModulePromiseRejections() { return traceRejections; } -bool rejectTurboModulePromiseOnNativeError() { - static bool rejectOnError = - getFeatureFlagBoolValue("rejectTurboModulePromiseOnNativeError"); - return rejectOnError; -} - struct JNIArgs { JNIArgs(size_t count) : args(count) {} JNIArgs(const JNIArgs&) = delete; @@ -900,12 +894,10 @@ jsi::Value JavaTurboModule::invokeJavaMethod( throw jsi::JSError(runtime, "Incorrect number of arguments"); } - if (rejectTurboModulePromiseOnNativeError()) { - nativeRejectCallback = AsyncCallback( - runtime, - args[1].getObject(runtime).getFunction(runtime), - jsInvoker_); - } + nativeRejectCallback = AsyncCallback( + runtime, + args[1].getObject(runtime).getFunction(runtime), + jsInvoker_); auto resolve = createJavaCallback( runtime, @@ -975,7 +967,7 @@ jsi::Value JavaTurboModule::invokeJavaMethod( try { FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); } catch (...) { - if (rejectTurboModulePromiseOnNativeError() && rejectCallback) { + if (rejectCallback) { auto exception = std::current_exception(); rejectWithException( *rejectCallback, exception, jsInvocationStack);