Migrate ReactFeatureFlags.enableFabricRenderer -> ReactNativeFeatureFlags (#46493)

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

Migrate:
- ReactFeatureFlags.enableFabricRenderer -> ReactNativeFeatureFlags.enableFabricRenderer()
- ReactFeatureFlags.useTurboModules -> ReactNativeFeatureFlags.useTurboModules()
- Rename ReactFeatureFlags.enableBridgelessArchitecture -> ReactNativeFeatureFlags.enableBridgelessArchitecture()

changelog: [Android][Breaking] Delete useTurboModules, enableFabricRenderer and enableBridgelessArchitecture fields from ReactFeatureFlags class

Reviewed By: rubennorte

Differential Revision: D60364016

fbshipit-source-id: e10a44fc08deb8969104b5cb0bd426dfb0a45d30
This commit is contained in:
David Vacca
2024-09-26 04:29:27 -07:00
committed by Facebook GitHub Bot
parent 038e6eda6d
commit 10a33e0479
37 changed files with 454 additions and 178 deletions
@@ -2041,10 +2041,7 @@ public final class com/facebook/react/common/network/OkHttpCallUtil {
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 enableFabricRenderer Z
public static field useTurboModules Z
public fun <init> ()V
}
@@ -13,7 +13,7 @@ import com.facebook.react.bridge.ModuleHolder;
import com.facebook.react.bridge.ModuleSpec;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
import com.facebook.react.module.model.ReactModuleInfo;
import com.facebook.react.module.model.ReactModuleInfoProvider;
import com.facebook.react.uimanager.ViewManager;
@@ -73,7 +73,7 @@ public abstract class BaseReactPackage implements ReactPackage {
// This Iterator is used to create the NativeModule registry. The NativeModule
// registry must not have TurboModules. Therefore, if TurboModules are enabled, and
// the current NativeModule is a TurboModule, we need to skip iterating over it.
if (ReactFeatureFlags.useTurboModules && reactModuleInfo.isTurboModule()) {
if (ReactNativeFeatureFlags.useTurboModules() && reactModuleInfo.isTurboModule()) {
continue;
}
@@ -19,7 +19,7 @@ import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
import com.facebook.react.jstasks.HeadlessJsTaskConfig;
import com.facebook.react.jstasks.HeadlessJsTaskContext;
import com.facebook.react.jstasks.HeadlessJsTaskEventListener;
@@ -167,7 +167,7 @@ public abstract class HeadlessJsTaskService extends Service implements HeadlessJ
}
protected ReactContext getReactContext() {
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactNativeFeatureFlags.enableBridgelessArchitecture()) {
ReactHost reactHost = getReactHost();
Assertions.assertNotNull(reactHost, "getReactHost() is null in New Architecture");
return reactHost.getCurrentReactContext();
@@ -18,7 +18,7 @@ import android.view.KeyEvent;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.Callback;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
import com.facebook.react.modules.core.PermissionListener;
/**
@@ -107,7 +107,7 @@ public class ReactActivityDelegate {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && isWideColorGamutEnabled()) {
mActivity.getWindow().setColorMode(ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT);
}
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactNativeFeatureFlags.enableBridgelessArchitecture()) {
mReactDelegate =
new ReactDelegate(getPlainActivity(), getReactHost(), mainComponentName, launchOptions);
} else {
@@ -226,7 +226,7 @@ public class ReactActivityDelegate {
* @return true if Fabric is enabled for this Activity, false otherwise.
*/
protected boolean isFabricEnabled() {
return ReactFeatureFlags.enableFabricRenderer;
return ReactNativeFeatureFlags.enableFabricRenderer();
}
/**
@@ -15,11 +15,11 @@ import android.view.KeyEvent;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.devsupport.DoubleTapReloadRecognizer;
import com.facebook.react.devsupport.ReleaseDevSupportManager;
import com.facebook.react.devsupport.interfaces.DevSupportManager;
import com.facebook.react.interfaces.fabric.ReactSurface;
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
/**
@@ -43,7 +43,7 @@ public class ReactDelegate {
@Nullable private ReactSurface mReactSurface;
private boolean mFabricEnabled = ReactFeatureFlags.enableFabricRenderer;
private boolean mFabricEnabled = ReactNativeFeatureFlags.enableFabricRenderer();
/**
* Do not use this constructor as it's not accounting for New Architecture at all. You should
@@ -94,7 +94,7 @@ public class ReactDelegate {
@Nullable
private DevSupportManager getDevSupportManager() {
if (ReactFeatureFlags.enableBridgelessArchitecture
if (ReactNativeFeatureFlags.enableBridgelessArchitecture()
&& mReactHost != null
&& mReactHost.getDevSupportManager() != null) {
return mReactHost.getDevSupportManager();
@@ -111,7 +111,7 @@ public class ReactDelegate {
throw new ClassCastException(
"Host Activity does not implement DefaultHardwareBackBtnHandler");
}
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactNativeFeatureFlags.enableBridgelessArchitecture()) {
mReactHost.onHostResume(mActivity, (DefaultHardwareBackBtnHandler) mActivity);
} else {
if (getReactNativeHost().hasInstance()) {
@@ -123,7 +123,7 @@ public class ReactDelegate {
}
public void onUserLeaveHint() {
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactNativeFeatureFlags.enableBridgelessArchitecture()) {
mReactHost.onHostLeaveHint(mActivity);
} else {
if (getReactNativeHost().hasInstance()) {
@@ -133,7 +133,7 @@ public class ReactDelegate {
}
public void onHostPause() {
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactNativeFeatureFlags.enableBridgelessArchitecture()) {
mReactHost.onHostPause(mActivity);
} else {
if (getReactNativeHost().hasInstance()) {
@@ -144,7 +144,7 @@ public class ReactDelegate {
public void onHostDestroy() {
unloadApp();
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactNativeFeatureFlags.enableBridgelessArchitecture()) {
mReactHost.onHostDestroy(mActivity);
} else {
if (getReactNativeHost().hasInstance()) {
@@ -154,7 +154,7 @@ public class ReactDelegate {
}
public boolean onBackPressed() {
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactNativeFeatureFlags.enableBridgelessArchitecture()) {
mReactHost.onBackPressed();
return true;
} else {
@@ -167,7 +167,7 @@ public class ReactDelegate {
}
public boolean onNewIntent(Intent intent) {
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactNativeFeatureFlags.enableBridgelessArchitecture()) {
mReactHost.onNewIntent(intent);
return true;
} else {
@@ -181,7 +181,7 @@ public class ReactDelegate {
public void onActivityResult(
int requestCode, int resultCode, Intent data, boolean shouldForwardToReactInstance) {
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactNativeFeatureFlags.enableBridgelessArchitecture()) {
mReactHost.onActivityResult(mActivity, requestCode, resultCode, data);
} else {
if (getReactNativeHost().hasInstance() && shouldForwardToReactInstance) {
@@ -193,7 +193,7 @@ public class ReactDelegate {
}
public void onWindowFocusChanged(boolean hasFocus) {
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactNativeFeatureFlags.enableBridgelessArchitecture()) {
mReactHost.onWindowFocusChange(hasFocus);
} else {
if (getReactNativeHost().hasInstance()) {
@@ -203,7 +203,7 @@ public class ReactDelegate {
}
public void onConfigurationChanged(Configuration newConfig) {
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactNativeFeatureFlags.enableBridgelessArchitecture()) {
mReactHost.onConfigurationChanged(Assertions.assertNotNull(mActivity));
} else {
if (getReactNativeHost().hasInstance()) {
@@ -215,7 +215,7 @@ public class ReactDelegate {
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD
&& ((ReactFeatureFlags.enableBridgelessArchitecture
&& ((ReactNativeFeatureFlags.enableBridgelessArchitecture()
&& mReactHost != null
&& mReactHost.getDevSupportManager() != null)
|| (getReactNativeHost().hasInstance()
@@ -228,7 +228,7 @@ public class ReactDelegate {
public boolean onKeyLongPress(int keyCode) {
if (keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
if (ReactFeatureFlags.enableBridgelessArchitecture && mReactHost != null) {
if (ReactNativeFeatureFlags.enableBridgelessArchitecture() && mReactHost != null) {
DevSupportManager devSupportManager = mReactHost.getDevSupportManager();
// onKeyLongPress is a Dev API and not supported in RELEASE mode.
if (devSupportManager != null && !(devSupportManager instanceof ReleaseDevSupportManager)) {
@@ -254,7 +254,7 @@ public class ReactDelegate {
// Reload in RELEASE mode
if (devSupportManager instanceof ReleaseDevSupportManager) {
// Do not reload the bundle from JS as there is no bundler running in release mode.
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactNativeFeatureFlags.enableBridgelessArchitecture()) {
if (mReactHost != null) {
mReactHost.reload("ReactDelegate.reload()");
}
@@ -286,7 +286,7 @@ public class ReactDelegate {
*/
public void loadApp(String appKey) {
// With Bridgeless enabled, create and start the surface
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactNativeFeatureFlags.enableBridgelessArchitecture()) {
if (mReactSurface == null) {
// Create a ReactSurface
mReactSurface = mReactHost.createSurface(mActivity, appKey, mLaunchOptions);
@@ -306,7 +306,7 @@ public class ReactDelegate {
/** Stop the React surface started with {@link ReactDelegate#loadApp()}. */
public void unloadApp() {
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactNativeFeatureFlags.enableBridgelessArchitecture()) {
if (mReactSurface != null) {
mReactSurface.stop();
mReactSurface = null;
@@ -321,7 +321,7 @@ public class ReactDelegate {
@Nullable
public ReactRootView getReactRootView() {
if (ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactNativeFeatureFlags.enableBridgelessArchitecture()) {
return (ReactRootView) mReactSurface.getView();
} else {
return mReactRootView;
@@ -80,7 +80,6 @@ import com.facebook.react.common.ReactConstants;
import com.facebook.react.common.SurfaceDelegateFactory;
import com.facebook.react.common.annotations.StableReactNativeAPI;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.devsupport.DevSupportManagerFactory;
import com.facebook.react.devsupport.InspectorFlags;
import com.facebook.react.devsupport.ReactInstanceDevHelper;
@@ -355,7 +354,7 @@ public class ReactInstanceManager {
Activity currentActivity = getCurrentActivity();
if (currentActivity != null) {
ReactRootView rootView = new ReactRootView(currentActivity);
boolean isFabric = ReactFeatureFlags.enableFabricRenderer;
boolean isFabric = ReactNativeFeatureFlags.enableFabricRenderer();
rootView.setIsFabric(isFabric);
rootView.startReactApplication(ReactInstanceManager.this, appKey, new Bundle());
return rootView;
@@ -1470,7 +1469,7 @@ public class ReactInstanceManager {
// architecture so it will always be there.
catalystInstance.getRuntimeScheduler();
if (ReactFeatureFlags.useTurboModules && mTMMDelegateBuilder != null) {
if (ReactNativeFeatureFlags.useTurboModules() && mTMMDelegateBuilder != null) {
TurboModuleManagerDelegate tmmDelegate =
mTMMDelegateBuilder
.setPackages(mPackages)
@@ -14,7 +14,6 @@ import com.facebook.react.bridge.CxxModuleWrapper;
import com.facebook.react.bridge.ModuleSpec;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
import com.facebook.react.internal.turbomodule.core.TurboModuleManagerDelegate;
import com.facebook.react.module.annotations.ReactModule;
@@ -37,7 +36,7 @@ public abstract class ReactPackageTurboModuleManagerDelegate extends TurboModule
new HashMap<>();
private final boolean mShouldEnableLegacyModuleInterop =
ReactFeatureFlags.enableBridgelessArchitecture
ReactNativeFeatureFlags.enableBridgelessArchitecture()
&& ReactNativeFeatureFlags.useTurboModuleInterop();
// Lazy Props
@@ -26,7 +26,7 @@ import com.facebook.react.bridge.queue.ReactQueueConfigurationImpl;
import com.facebook.react.bridge.queue.ReactQueueConfigurationSpec;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
import com.facebook.react.internal.turbomodule.core.interfaces.TurboModuleRegistry;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.turbomodule.core.CallInvokerHolderImpl;
@@ -459,7 +459,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
}
private TurboModuleRegistry getTurboModuleRegistry() {
if (ReactFeatureFlags.useTurboModules) {
if (ReactNativeFeatureFlags.useTurboModules()) {
return Assertions.assertNotNull(
mTurboModuleRegistry,
"TurboModules are enabled, but mTurboModuleRegistry hasn't been set.");
@@ -9,7 +9,6 @@ package com.facebook.react.bridge.interop;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
import java.util.HashMap;
@@ -52,6 +51,7 @@ public class InteropModuleRegistry {
}
private boolean checkReactFeatureFlagsConditions() {
return ReactFeatureFlags.enableFabricRenderer && ReactNativeFeatureFlags.useFabricInterop();
return ReactNativeFeatureFlags.enableFabricRenderer()
&& ReactNativeFeatureFlags.useFabricInterop();
}
}
@@ -21,40 +21,6 @@ import com.facebook.proguard.annotations.DoNotStripAny;
@Deprecated(since = "Use com.facebook.react.internal.featureflags.ReactNativeFeatureFlags instead.")
@DoNotStripAny
public class ReactFeatureFlags {
/**
* Should this application use TurboModules? If yes, then any module that inherits {@link
* com.facebook.react.turbomodule.core.interfaces.TurboModule} will NOT be passed in to C++
* CatalystInstanceImpl
*/
@Deprecated(
since =
"useTurboModules will be deleted in 0.77, please use"
+ " DefaultNewArchitectureEntryPoint.load() to enable TurboModules instead.",
forRemoval = true)
public static volatile boolean useTurboModules = false;
/**
* Should this application use the new (Fabric) Renderer? If yes, all rendering in this app will
* use Fabric instead of the legacy renderer.
*/
@Deprecated(
since =
"enableFabricRenderer will be deleted in 0.77, please use"
+ " DefaultNewArchitectureEntryPoint.load() to enable fabric instead.",
forRemoval = true)
public static volatile boolean enableFabricRenderer = false;
/**
* Feature flag to enable the new bridgeless architecture. Note: Enabling this will force enable
* the following flags: `useTurboModules` & `enableFabricRenderer`.
*/
@Deprecated(
since =
"enableBridgelessArchitecture will be deleted in 0.77, please use"
+ " DefaultNewArchitectureEntryPoint.load() to enable bridgeless architecture"
+ " instead.",
forRemoval = true)
public static boolean enableBridgelessArchitecture = false;
public static boolean dispatchPointerEvents = false;
@@ -10,7 +10,6 @@
package com.facebook.react.defaults
import com.facebook.react.common.annotations.VisibleForTesting
import com.facebook.react.config.ReactFeatureFlags
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
import com.facebook.react.internal.featureflags.ReactNativeNewArchitectureFeatureFlagsDefaults
@@ -39,18 +38,20 @@ public object DefaultNewArchitectureEntryPoint {
if (!isValid) {
error(errorMessage)
}
ReactFeatureFlags.useTurboModules = turboModulesEnabled
ReactFeatureFlags.enableFabricRenderer = fabricEnabled
if (bridgelessEnabled) {
ReactNativeFeatureFlags.override(
object : ReactNativeNewArchitectureFeatureFlagsDefaults() {
override fun useFabricInterop(): Boolean = fabricEnabled
override fun enableFabricRenderer(): Boolean = fabricEnabled
// We turn this feature flag to true for OSS to fix #44610 and #45126 and other
// similar bugs related to pressable.
override fun enableEventEmitterRetentionDuringGesturesOnAndroid(): Boolean =
fabricEnabled
override fun useTurboModules(): Boolean = turboModulesEnabled
})
}
@@ -50,7 +50,6 @@ import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.common.build.ReactBuildConfig;
import com.facebook.react.common.mapbuffer.ReadableMapBuffer;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.fabric.events.EventEmitterWrapper;
import com.facebook.react.fabric.events.FabricEventEmitter;
import com.facebook.react.fabric.internal.interop.InteropUIBlockListener;
@@ -442,7 +441,7 @@ public class FabricUIManager
// responsible for initializing and deallocating EventDispatcher. StaticViewConfigs is enabled
// only in Bridgeless for now.
// TODO T83943316: Remove this IF once StaticViewConfigs are enabled by default
if (!ReactFeatureFlags.enableBridgelessArchitecture) {
if (!ReactNativeFeatureFlags.enableBridgelessArchitecture()) {
mEventDispatcher.onCatalystInstanceDestroyed();
}
}
@@ -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<<73409b567e77f17838ae9681a8e20be6>>
* @generated SignedSource<<bce0548a9e58299746c75aad95a25275>>
*/
/**
@@ -82,6 +82,12 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun enableBackgroundStyleApplicator(): Boolean = accessor.enableBackgroundStyleApplicator()
/**
* Feature flag to enable the new bridgeless architecture. Note: Enabling this will force enable the following flags: `useTurboModules` & `enableFabricRenderer.
*/
@JvmStatic
public fun enableBridgelessArchitecture(): Boolean = accessor.enableBridgelessArchitecture()
/**
* Clean yoga node when <TextInput /> does not change.
*/
@@ -112,6 +118,12 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun enableFabricLogs(): Boolean = accessor.enableFabricLogs()
/**
* Enables the use of the Fabric renderer in the whole app.
*/
@JvmStatic
public fun enableFabricRenderer(): Boolean = accessor.enableFabricRenderer()
/**
* 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.
*/
@@ -334,6 +346,12 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun useTurboModuleInterop(): Boolean = accessor.useTurboModuleInterop()
/**
* When enabled, NativeModules will be executed by using the TurboModule system
*/
@JvmStatic
public fun useTurboModules(): Boolean = accessor.useTurboModules()
/**
* Overrides the feature flags with the ones provided by the given provider
* (generally one that extends `ReactNativeFeatureFlagsDefaults`).
@@ -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<<9f2978b5a732a3ca4f3c3d74debba782>>
* @generated SignedSource<<19dca512d93d689e927ee5988a43e646>>
*/
/**
@@ -29,11 +29,13 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
private var enableAndroidLineHeightCenteringCache: Boolean? = null
private var enableAndroidMixBlendModePropCache: Boolean? = null
private var enableBackgroundStyleApplicatorCache: Boolean? = null
private var enableBridgelessArchitectureCache: Boolean? = null
private var enableCleanTextInputYogaNodeCache: Boolean? = null
private var enableDeletionOfUnmountedViewsCache: Boolean? = null
private var enableEagerRootViewAttachmentCache: Boolean? = null
private var enableEventEmitterRetentionDuringGesturesOnAndroidCache: Boolean? = null
private var enableFabricLogsCache: Boolean? = null
private var enableFabricRendererCache: Boolean? = null
private var enableFabricRendererExclusivelyCache: Boolean? = null
private var enableGranularShadowTreeStateReconciliationCache: Boolean? = null
private var enableIOSViewClipToPaddingBoxCache: Boolean? = null
@@ -71,6 +73,7 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
private var useRuntimeShadowNodeReferenceUpdateOnLayoutCache: Boolean? = null
private var useStateAlignmentMechanismCache: Boolean? = null
private var useTurboModuleInteropCache: Boolean? = null
private var useTurboModulesCache: Boolean? = null
override fun commonTestFlag(): Boolean {
var cached = commonTestFlagCache
@@ -153,6 +156,15 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
return cached
}
override fun enableBridgelessArchitecture(): Boolean {
var cached = enableBridgelessArchitectureCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.enableBridgelessArchitecture()
enableBridgelessArchitectureCache = cached
}
return cached
}
override fun enableCleanTextInputYogaNode(): Boolean {
var cached = enableCleanTextInputYogaNodeCache
if (cached == null) {
@@ -198,6 +210,15 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
return cached
}
override fun enableFabricRenderer(): Boolean {
var cached = enableFabricRendererCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.enableFabricRenderer()
enableFabricRendererCache = cached
}
return cached
}
override fun enableFabricRendererExclusively(): Boolean {
var cached = enableFabricRendererExclusivelyCache
if (cached == null) {
@@ -531,6 +552,15 @@ public class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccesso
return cached
}
override fun useTurboModules(): Boolean {
var cached = useTurboModulesCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.useTurboModules()
useTurboModulesCache = cached
}
return cached
}
override fun override(provider: ReactNativeFeatureFlagsProvider): Unit =
ReactNativeFeatureFlagsCxxInterop.override(provider as Any)
@@ -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<<0d2f5427661ce67e468aea47bdd29802>>
* @generated SignedSource<<76eebf045692e945d39a4ea27a63ae02>>
*/
/**
@@ -46,6 +46,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
@DoNotStrip @JvmStatic public external fun enableBackgroundStyleApplicator(): Boolean
@DoNotStrip @JvmStatic public external fun enableBridgelessArchitecture(): Boolean
@DoNotStrip @JvmStatic public external fun enableCleanTextInputYogaNode(): Boolean
@DoNotStrip @JvmStatic public external fun enableDeletionOfUnmountedViews(): Boolean
@@ -56,6 +58,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
@DoNotStrip @JvmStatic public external fun enableFabricLogs(): Boolean
@DoNotStrip @JvmStatic public external fun enableFabricRenderer(): Boolean
@DoNotStrip @JvmStatic public external fun enableFabricRendererExclusively(): Boolean
@DoNotStrip @JvmStatic public external fun enableGranularShadowTreeStateReconciliation(): Boolean
@@ -130,6 +134,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
@DoNotStrip @JvmStatic public external fun useTurboModuleInterop(): Boolean
@DoNotStrip @JvmStatic public external fun useTurboModules(): Boolean
@DoNotStrip @JvmStatic public external fun override(provider: Any)
@DoNotStrip @JvmStatic public external fun dangerouslyReset()
@@ -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<<72e3e7b5a53e64f8f48310d8b07cdf76>>
* @generated SignedSource<<8155a9c1309145fefdb19feb33c241db>>
*/
/**
@@ -41,6 +41,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
override fun enableBackgroundStyleApplicator(): Boolean = true
override fun enableBridgelessArchitecture(): Boolean = false
override fun enableCleanTextInputYogaNode(): Boolean = false
override fun enableDeletionOfUnmountedViews(): Boolean = false
@@ -51,6 +53,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
override fun enableFabricLogs(): Boolean = false
override fun enableFabricRenderer(): Boolean = false
override fun enableFabricRendererExclusively(): Boolean = false
override fun enableGranularShadowTreeStateReconciliation(): Boolean = false
@@ -124,4 +128,6 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
override fun useStateAlignmentMechanism(): Boolean = false
override fun useTurboModuleInterop(): Boolean = false
override fun useTurboModules(): Boolean = false
}
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<e1a44f8e54709e70934f1d418d4ed80f>>
* @generated SignedSource<<5e4e474b62996caec15bbf8af9622a0a>>
*/
/**
@@ -33,11 +33,13 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
private var enableAndroidLineHeightCenteringCache: Boolean? = null
private var enableAndroidMixBlendModePropCache: Boolean? = null
private var enableBackgroundStyleApplicatorCache: Boolean? = null
private var enableBridgelessArchitectureCache: Boolean? = null
private var enableCleanTextInputYogaNodeCache: Boolean? = null
private var enableDeletionOfUnmountedViewsCache: Boolean? = null
private var enableEagerRootViewAttachmentCache: Boolean? = null
private var enableEventEmitterRetentionDuringGesturesOnAndroidCache: Boolean? = null
private var enableFabricLogsCache: Boolean? = null
private var enableFabricRendererCache: Boolean? = null
private var enableFabricRendererExclusivelyCache: Boolean? = null
private var enableGranularShadowTreeStateReconciliationCache: Boolean? = null
private var enableIOSViewClipToPaddingBoxCache: Boolean? = null
@@ -75,6 +77,7 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
private var useRuntimeShadowNodeReferenceUpdateOnLayoutCache: Boolean? = null
private var useStateAlignmentMechanismCache: Boolean? = null
private var useTurboModuleInteropCache: Boolean? = null
private var useTurboModulesCache: Boolean? = null
override fun commonTestFlag(): Boolean {
var cached = commonTestFlagCache
@@ -166,6 +169,16 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
return cached
}
override fun enableBridgelessArchitecture(): Boolean {
var cached = enableBridgelessArchitectureCache
if (cached == null) {
cached = currentProvider.enableBridgelessArchitecture()
accessedFeatureFlags.add("enableBridgelessArchitecture")
enableBridgelessArchitectureCache = cached
}
return cached
}
override fun enableCleanTextInputYogaNode(): Boolean {
var cached = enableCleanTextInputYogaNodeCache
if (cached == null) {
@@ -216,6 +229,16 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
return cached
}
override fun enableFabricRenderer(): Boolean {
var cached = enableFabricRendererCache
if (cached == null) {
cached = currentProvider.enableFabricRenderer()
accessedFeatureFlags.add("enableFabricRenderer")
enableFabricRendererCache = cached
}
return cached
}
override fun enableFabricRendererExclusively(): Boolean {
var cached = enableFabricRendererExclusivelyCache
if (cached == null) {
@@ -586,6 +609,16 @@ public class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcces
return cached
}
override fun useTurboModules(): Boolean {
var cached = useTurboModulesCache
if (cached == null) {
cached = currentProvider.useTurboModules()
accessedFeatureFlags.add("useTurboModules")
useTurboModulesCache = cached
}
return cached
}
override fun override(provider: ReactNativeFeatureFlagsProvider) {
if (accessedFeatureFlags.isNotEmpty()) {
val accessedFeatureFlagsStr = accessedFeatureFlags.joinToString(separator = ", ") { it }
@@ -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<<0f6129ccbcf7857785724f14b41edb2d>>
* @generated SignedSource<<97eddbbd75ff7cfd0f1c905d72e9eafd>>
*/
/**
@@ -41,6 +41,8 @@ public interface ReactNativeFeatureFlagsProvider {
@DoNotStrip public fun enableBackgroundStyleApplicator(): Boolean
@DoNotStrip public fun enableBridgelessArchitecture(): Boolean
@DoNotStrip public fun enableCleanTextInputYogaNode(): Boolean
@DoNotStrip public fun enableDeletionOfUnmountedViews(): Boolean
@@ -51,6 +53,8 @@ public interface ReactNativeFeatureFlagsProvider {
@DoNotStrip public fun enableFabricLogs(): Boolean
@DoNotStrip public fun enableFabricRenderer(): Boolean
@DoNotStrip public fun enableFabricRendererExclusively(): Boolean
@DoNotStrip public fun enableGranularShadowTreeStateReconciliation(): Boolean
@@ -124,4 +128,6 @@ public interface ReactNativeFeatureFlagsProvider {
@DoNotStrip public fun useStateAlignmentMechanism(): Boolean
@DoNotStrip public fun useTurboModuleInterop(): Boolean
@DoNotStrip public fun useTurboModules(): Boolean
}
@@ -1,10 +1,14 @@
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
/*
* 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.
*/
@file:Suppress("DEPRECATION") // We want to use ReactFeatureFlags here specifically
package com.facebook.react.internal.featureflags
import com.facebook.react.config.ReactFeatureFlags
/**
* This class initializes default values for ReactNativeFeatureFlags when the New architecture is
* enabled. This class is meant to be overrode only by internal apps migrating to the new
@@ -12,23 +16,14 @@ import com.facebook.react.config.ReactFeatureFlags
*
* NOTE: Be aware that as a side effect this class also modifies static fields in {@link
* com.facebook.react.config.ReactFeatureFlags} when newArchitectureEnabled is true.
*
* When the new architecture is enabled, we want to set the default values of the flags for Fabric,
* TurboModules and Bridgeless as enabled by default.
*/
public open class ReactNativeNewArchitectureFeatureFlagsDefaults(
private val newArchitectureEnabled: Boolean = true
) : ReactNativeFeatureFlagsDefaults() {
init {
if (newArchitectureEnabled) {
// When the new architecture is enabled, we want to set the default values of the flags for
// Fabric, TurboModules and Bridgeless as enabled by default.
// ReactFeatureFlags is deprecated and will be deleted in 0.77, this code is temporary to
// support the new architecture before 0.77 cut.
ReactFeatureFlags.enableFabricRenderer = true
ReactFeatureFlags.useTurboModules = true
ReactFeatureFlags.enableBridgelessArchitecture = true
}
}
override fun batchRenderingUpdatesInEventLoop(): Boolean =
newArchitectureEnabled || super.batchRenderingUpdatesInEventLoop()
@@ -37,7 +32,13 @@ public open class ReactNativeNewArchitectureFeatureFlagsDefaults(
override fun useModernRuntimeScheduler(): Boolean = true
override fun enableBridgelessArchitecture(): Boolean = newArchitectureEnabled
override fun enableMicrotasks(): Boolean = true
override fun enableFabricRenderer(): Boolean = newArchitectureEnabled
override fun useNativeViewConfigsInBridgelessMode(): Boolean = true
override fun useTurboModules(): Boolean = newArchitectureEnabled
}
@@ -13,7 +13,6 @@ import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.common.build.ReactBuildConfig;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
import java.util.ArrayList;
import java.util.HashMap;
@@ -135,7 +134,8 @@ public class UIManagerModuleConstantsHelper {
Map viewManagerBubblingEvents = viewManager.getExportedCustomBubblingEventTypeConstants();
if (viewManagerBubblingEvents != null) {
if (ReactFeatureFlags.enableFabricRenderer && ReactNativeFeatureFlags.useFabricInterop()) {
if (ReactNativeFeatureFlags.enableFabricRenderer()
&& ReactNativeFeatureFlags.useFabricInterop()) {
// For Fabric, events needs to be fired with a "top" prefix.
// For the sake of Fabric Interop, here we normalize events adding "top" in their
// name if the user hasn't provided it.
@@ -151,7 +151,8 @@ public class UIManagerModuleConstantsHelper {
Map viewManagerDirectEvents = viewManager.getExportedCustomDirectEventTypeConstants();
validateDirectEventNames(viewManager.getName(), viewManagerDirectEvents);
if (viewManagerDirectEvents != null) {
if (ReactFeatureFlags.enableFabricRenderer && ReactNativeFeatureFlags.useFabricInterop()) {
if (ReactNativeFeatureFlags.enableFabricRenderer()
&& ReactNativeFeatureFlags.useFabricInterop()) {
// For Fabric, events needs to be fired with a "top" prefix.
// For the sake of Fabric Interop, here we normalize events adding "top" in their
// name if the user hasn't provided it.
@@ -47,7 +47,7 @@ import com.facebook.react.bridge.ReadableMap
import com.facebook.react.common.annotations.UnstableReactNativeAPI
import com.facebook.react.common.annotations.VisibleForTesting
import com.facebook.react.common.build.ReactBuildConfig
import com.facebook.react.config.ReactFeatureFlags
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags.loadVectorDrawablesOnImages
import com.facebook.react.modules.fresco.ReactNetworkImageRequest
import com.facebook.react.uimanager.BackgroundStyleApplicator
@@ -590,7 +590,7 @@ public class ReactImageView(
// 3. ReactImageView detects the null src; displays a warning in LogBox (via this code).
// 3. LogBox renders an <Image/>, which fabric preallocates.
// 4. Rinse and repeat.
if (ReactBuildConfig.DEBUG && !ReactFeatureFlags.enableBridgelessArchitecture) {
if (ReactBuildConfig.DEBUG && !ReactNativeFeatureFlags.enableBridgelessArchitecture()) {
RNLog.w(context as ReactContext, "ReactImageView: Image source \"$uri\" doesn't exist")
}
}
@@ -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<<43b92dd984e985e09e3efad9c8fedf44>>
* @generated SignedSource<<383e9749c506bc2326455ef907e06a4c>>
*/
/**
@@ -93,6 +93,12 @@ class ReactNativeFeatureFlagsProviderHolder
return method(javaProvider_);
}
bool enableBridgelessArchitecture() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableBridgelessArchitecture");
return method(javaProvider_);
}
bool enableCleanTextInputYogaNode() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableCleanTextInputYogaNode");
@@ -123,6 +129,12 @@ class ReactNativeFeatureFlagsProviderHolder
return method(javaProvider_);
}
bool enableFabricRenderer() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableFabricRenderer");
return method(javaProvider_);
}
bool enableFabricRendererExclusively() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableFabricRendererExclusively");
@@ -345,6 +357,12 @@ class ReactNativeFeatureFlagsProviderHolder
return method(javaProvider_);
}
bool useTurboModules() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("useTurboModules");
return method(javaProvider_);
}
private:
jni::global_ref<jobject> javaProvider_;
};
@@ -394,6 +412,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableBackgroundStyleApplicator(
return ReactNativeFeatureFlags::enableBackgroundStyleApplicator();
}
bool JReactNativeFeatureFlagsCxxInterop::enableBridgelessArchitecture(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::enableBridgelessArchitecture();
}
bool JReactNativeFeatureFlagsCxxInterop::enableCleanTextInputYogaNode(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::enableCleanTextInputYogaNode();
@@ -419,6 +442,11 @@ bool JReactNativeFeatureFlagsCxxInterop::enableFabricLogs(
return ReactNativeFeatureFlags::enableFabricLogs();
}
bool JReactNativeFeatureFlagsCxxInterop::enableFabricRenderer(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::enableFabricRenderer();
}
bool JReactNativeFeatureFlagsCxxInterop::enableFabricRendererExclusively(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::enableFabricRendererExclusively();
@@ -604,6 +632,11 @@ bool JReactNativeFeatureFlagsCxxInterop::useTurboModuleInterop(
return ReactNativeFeatureFlags::useTurboModuleInterop();
}
bool JReactNativeFeatureFlagsCxxInterop::useTurboModules(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::useTurboModules();
}
void JReactNativeFeatureFlagsCxxInterop::override(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/,
jni::alias_ref<jobject> provider) {
@@ -648,6 +681,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"enableBackgroundStyleApplicator",
JReactNativeFeatureFlagsCxxInterop::enableBackgroundStyleApplicator),
makeNativeMethod(
"enableBridgelessArchitecture",
JReactNativeFeatureFlagsCxxInterop::enableBridgelessArchitecture),
makeNativeMethod(
"enableCleanTextInputYogaNode",
JReactNativeFeatureFlagsCxxInterop::enableCleanTextInputYogaNode),
@@ -663,6 +699,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"enableFabricLogs",
JReactNativeFeatureFlagsCxxInterop::enableFabricLogs),
makeNativeMethod(
"enableFabricRenderer",
JReactNativeFeatureFlagsCxxInterop::enableFabricRenderer),
makeNativeMethod(
"enableFabricRendererExclusively",
JReactNativeFeatureFlagsCxxInterop::enableFabricRendererExclusively),
@@ -774,6 +813,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"useTurboModuleInterop",
JReactNativeFeatureFlagsCxxInterop::useTurboModuleInterop),
makeNativeMethod(
"useTurboModules",
JReactNativeFeatureFlagsCxxInterop::useTurboModules),
});
}
@@ -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<<54c94f9bfa07e41d978899dbce03469f>>
* @generated SignedSource<<293ed423f770e7e0ba95b19eb5c28dc2>>
*/
/**
@@ -57,6 +57,9 @@ class JReactNativeFeatureFlagsCxxInterop
static bool enableBackgroundStyleApplicator(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool enableBridgelessArchitecture(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool enableCleanTextInputYogaNode(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
@@ -72,6 +75,9 @@ class JReactNativeFeatureFlagsCxxInterop
static bool enableFabricLogs(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool enableFabricRenderer(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool enableFabricRendererExclusively(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
@@ -183,6 +189,9 @@ class JReactNativeFeatureFlagsCxxInterop
static bool useTurboModuleInterop(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool useTurboModules(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static void override(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>,
jni::alias_ref<jobject> provider);
@@ -11,7 +11,6 @@
package com.facebook.react.bridge.interop
import com.facebook.react.common.annotations.UnstableReactNativeAPI
import com.facebook.react.config.ReactFeatureFlags
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsDefaults
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsForTests
@@ -40,38 +39,28 @@ class InteropModuleRegistryTest {
@Test
fun shouldReturnInteropModule_withFabricDisabled_returnsFalse() {
ReactFeatureFlags.enableFabricRenderer = false
overrideFeatureFlags(false, false)
assertThat(underTest.shouldReturnInteropModule(RCTEventEmitter::class.java)).isFalse()
}
@Test
fun shouldReturnInteropModule_withFabricInteropDisabled_returnsFalse() {
ReactFeatureFlags.enableFabricRenderer = true
overrideUseFabricInteropFlag(false)
overrideFeatureFlags(false, true)
assertThat(underTest.shouldReturnInteropModule(RCTEventEmitter::class.java)).isFalse()
}
private fun overrideUseFabricInteropFlag(value: Boolean) {
ReactNativeFeatureFlags.override(
object : ReactNativeFeatureFlagsDefaults() {
override fun useFabricInterop(): Boolean = value
})
}
@Test
fun shouldReturnInteropModule_withUnregisteredClass_returnsFalse() {
ReactFeatureFlags.enableFabricRenderer = true
overrideUseFabricInteropFlag(true)
overrideFeatureFlags(true, true)
assertThat(underTest.shouldReturnInteropModule(JSTimers::class.java)).isFalse()
}
@Test
fun shouldReturnInteropModule_withRegisteredClass_returnsTrue() {
ReactFeatureFlags.enableFabricRenderer = true
overrideUseFabricInteropFlag(true)
overrideFeatureFlags(true, true)
underTest.registerInteropModule(RCTEventEmitter::class.java, FakeRCTEventEmitter())
@@ -80,8 +69,7 @@ class InteropModuleRegistryTest {
@Test
fun getInteropModule_withRegisteredClassAndInvalidFlags_returnsNull() {
ReactFeatureFlags.enableFabricRenderer = false
overrideUseFabricInteropFlag(false)
overrideFeatureFlags(false, false)
underTest.registerInteropModule(RCTEventEmitter::class.java, FakeRCTEventEmitter())
val interopModule = underTest.getInteropModule(RCTEventEmitter::class.java)
@@ -91,8 +79,7 @@ class InteropModuleRegistryTest {
@Test
fun getInteropModule_withRegisteredClassAndValidFlags_returnsInteropModule() {
ReactFeatureFlags.enableFabricRenderer = true
overrideUseFabricInteropFlag(true)
overrideFeatureFlags(true, true)
underTest.registerInteropModule(RCTEventEmitter::class.java, FakeRCTEventEmitter())
val interopModule = underTest.getInteropModule(RCTEventEmitter::class.java)
@@ -102,10 +89,18 @@ class InteropModuleRegistryTest {
@Test
fun getInteropModule_withUnregisteredClass_returnsNull() {
ReactFeatureFlags.enableFabricRenderer = true
overrideUseFabricInteropFlag(true)
overrideFeatureFlags(true, true)
val missingModule = underTest.getInteropModule(JSTimers::class.java)
assertThat(missingModule).isNull()
}
private fun overrideFeatureFlags(useFabricInterop: Boolean, enableFabricRenderer: Boolean) {
ReactNativeFeatureFlags.override(
object : ReactNativeFeatureFlagsDefaults() {
override fun useFabricInterop(): Boolean = useFabricInterop
override fun enableFabricRenderer(): Boolean = enableFabricRenderer
})
}
}
@@ -12,6 +12,7 @@ import com.facebook.react.bridge.JavaOnlyMap
import com.facebook.react.bridge.ReactContext
import com.facebook.react.bridge.ReactTestHelper
import com.facebook.react.bridge.WritableMap
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsForTests
import com.facebook.react.uimanager.DisplayMetricsHolder
import junit.framework.TestCase
import org.assertj.core.api.Assertions
@@ -37,6 +38,7 @@ class DeviceInfoModuleTest : TestCase() {
@Before
public override fun setUp() {
ReactNativeFeatureFlagsForTests.setUp()
fakePortraitDisplayMetrics = JavaOnlyMap()
fakePortraitDisplayMetrics.putInt("width", 100)
fakePortraitDisplayMetrics.putInt("height", 200)
@@ -10,6 +10,7 @@ package com.facebook.react.uimanager
import android.view.View
import com.facebook.react.bridge.BridgeReactContext
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsForTests
import org.assertj.core.api.Assertions
import org.assertj.core.data.MapEntry
import org.junit.Before
@@ -54,6 +55,7 @@ class UIManagerModuleConstantsTest {
@Before
fun setUp() {
ReactNativeFeatureFlagsForTests.setUp()
reactContext = BridgeReactContext(RuntimeEnvironment.getApplication())
}
@@ -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<<b04a641595d870bd9666281b3f0cfec5>>
* @generated SignedSource<<85cdb5a41317e9671cc23b2c7345c04d>>
*/
/**
@@ -57,6 +57,10 @@ bool ReactNativeFeatureFlags::enableBackgroundStyleApplicator() {
return getAccessor().enableBackgroundStyleApplicator();
}
bool ReactNativeFeatureFlags::enableBridgelessArchitecture() {
return getAccessor().enableBridgelessArchitecture();
}
bool ReactNativeFeatureFlags::enableCleanTextInputYogaNode() {
return getAccessor().enableCleanTextInputYogaNode();
}
@@ -77,6 +81,10 @@ bool ReactNativeFeatureFlags::enableFabricLogs() {
return getAccessor().enableFabricLogs();
}
bool ReactNativeFeatureFlags::enableFabricRenderer() {
return getAccessor().enableFabricRenderer();
}
bool ReactNativeFeatureFlags::enableFabricRendererExclusively() {
return getAccessor().enableFabricRendererExclusively();
}
@@ -225,6 +233,10 @@ bool ReactNativeFeatureFlags::useTurboModuleInterop() {
return getAccessor().useTurboModuleInterop();
}
bool ReactNativeFeatureFlags::useTurboModules() {
return getAccessor().useTurboModules();
}
void ReactNativeFeatureFlags::override(
std::unique_ptr<ReactNativeFeatureFlagsProvider> provider) {
getAccessor().override(std::move(provider));
@@ -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<<2cde82b474ab94cd05bdf5e04e700c13>>
* @generated SignedSource<<ea2c2d19e83630b549e719057cd1982e>>
*/
/**
@@ -82,6 +82,11 @@ class ReactNativeFeatureFlags {
*/
RN_EXPORT static bool enableBackgroundStyleApplicator();
/**
* Feature flag to enable the new bridgeless architecture. Note: Enabling this will force enable the following flags: `useTurboModules` & `enableFabricRenderer.
*/
RN_EXPORT static bool enableBridgelessArchitecture();
/**
* Clean yoga node when <TextInput /> does not change.
*/
@@ -107,6 +112,11 @@ class ReactNativeFeatureFlags {
*/
RN_EXPORT static bool enableFabricLogs();
/**
* Enables the use of the Fabric renderer in the whole app.
*/
RN_EXPORT static bool enableFabricRenderer();
/**
* 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.
*/
@@ -292,6 +302,11 @@ class ReactNativeFeatureFlags {
*/
RN_EXPORT static bool useTurboModuleInterop();
/**
* When enabled, NativeModules will be executed by using the TurboModule system
*/
RN_EXPORT static bool useTurboModules();
/**
* Overrides the feature flags with the ones provided by the given provider
* (generally one that extends `ReactNativeFeatureFlagsDefaults`).
@@ -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<<bad25041142c5acf6f1de3ccf96deb2b>>
* @generated SignedSource<<daeeaa9fbbc3f9eb9d1b4164f6e8c954>>
*/
/**
@@ -191,6 +191,24 @@ bool ReactNativeFeatureFlagsAccessor::enableBackgroundStyleApplicator() {
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::enableBridgelessArchitecture() {
auto flagValue = enableBridgelessArchitecture_.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, "enableBridgelessArchitecture");
flagValue = currentProvider_->enableBridgelessArchitecture();
enableBridgelessArchitecture_ = flagValue;
}
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::enableCleanTextInputYogaNode() {
auto flagValue = enableCleanTextInputYogaNode_.load();
@@ -200,7 +218,7 @@ bool ReactNativeFeatureFlagsAccessor::enableCleanTextInputYogaNode() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(9, "enableCleanTextInputYogaNode");
markFlagAsAccessed(10, "enableCleanTextInputYogaNode");
flagValue = currentProvider_->enableCleanTextInputYogaNode();
enableCleanTextInputYogaNode_ = flagValue;
@@ -218,7 +236,7 @@ bool ReactNativeFeatureFlagsAccessor::enableDeletionOfUnmountedViews() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(10, "enableDeletionOfUnmountedViews");
markFlagAsAccessed(11, "enableDeletionOfUnmountedViews");
flagValue = currentProvider_->enableDeletionOfUnmountedViews();
enableDeletionOfUnmountedViews_ = flagValue;
@@ -236,7 +254,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(11, "enableEagerRootViewAttachment");
markFlagAsAccessed(12, "enableEagerRootViewAttachment");
flagValue = currentProvider_->enableEagerRootViewAttachment();
enableEagerRootViewAttachment_ = flagValue;
@@ -254,7 +272,7 @@ bool ReactNativeFeatureFlagsAccessor::enableEventEmitterRetentionDuringGesturesO
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(12, "enableEventEmitterRetentionDuringGesturesOnAndroid");
markFlagAsAccessed(13, "enableEventEmitterRetentionDuringGesturesOnAndroid");
flagValue = currentProvider_->enableEventEmitterRetentionDuringGesturesOnAndroid();
enableEventEmitterRetentionDuringGesturesOnAndroid_ = flagValue;
@@ -272,7 +290,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(13, "enableFabricLogs");
markFlagAsAccessed(14, "enableFabricLogs");
flagValue = currentProvider_->enableFabricLogs();
enableFabricLogs_ = flagValue;
@@ -281,6 +299,24 @@ bool ReactNativeFeatureFlagsAccessor::enableFabricLogs() {
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::enableFabricRenderer() {
auto flagValue = enableFabricRenderer_.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(15, "enableFabricRenderer");
flagValue = currentProvider_->enableFabricRenderer();
enableFabricRenderer_ = flagValue;
}
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::enableFabricRendererExclusively() {
auto flagValue = enableFabricRendererExclusively_.load();
@@ -290,7 +326,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(14, "enableFabricRendererExclusively");
markFlagAsAccessed(16, "enableFabricRendererExclusively");
flagValue = currentProvider_->enableFabricRendererExclusively();
enableFabricRendererExclusively_ = flagValue;
@@ -308,7 +344,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(15, "enableGranularShadowTreeStateReconciliation");
markFlagAsAccessed(17, "enableGranularShadowTreeStateReconciliation");
flagValue = currentProvider_->enableGranularShadowTreeStateReconciliation();
enableGranularShadowTreeStateReconciliation_ = flagValue;
@@ -326,7 +362,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(16, "enableIOSViewClipToPaddingBox");
markFlagAsAccessed(18, "enableIOSViewClipToPaddingBox");
flagValue = currentProvider_->enableIOSViewClipToPaddingBox();
enableIOSViewClipToPaddingBox_ = flagValue;
@@ -344,7 +380,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(17, "enableLayoutAnimationsOnIOS");
markFlagAsAccessed(19, "enableLayoutAnimationsOnIOS");
flagValue = currentProvider_->enableLayoutAnimationsOnIOS();
enableLayoutAnimationsOnIOS_ = flagValue;
@@ -362,7 +398,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(18, "enableLongTaskAPI");
markFlagAsAccessed(20, "enableLongTaskAPI");
flagValue = currentProvider_->enableLongTaskAPI();
enableLongTaskAPI_ = flagValue;
@@ -380,7 +416,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(19, "enableMicrotasks");
markFlagAsAccessed(21, "enableMicrotasks");
flagValue = currentProvider_->enableMicrotasks();
enableMicrotasks_ = flagValue;
@@ -398,7 +434,7 @@ bool ReactNativeFeatureFlagsAccessor::enablePreciseSchedulingForPremountItemsOnA
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(20, "enablePreciseSchedulingForPremountItemsOnAndroid");
markFlagAsAccessed(22, "enablePreciseSchedulingForPremountItemsOnAndroid");
flagValue = currentProvider_->enablePreciseSchedulingForPremountItemsOnAndroid();
enablePreciseSchedulingForPremountItemsOnAndroid_ = flagValue;
@@ -416,7 +452,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(21, "enablePropsUpdateReconciliationAndroid");
markFlagAsAccessed(23, "enablePropsUpdateReconciliationAndroid");
flagValue = currentProvider_->enablePropsUpdateReconciliationAndroid();
enablePropsUpdateReconciliationAndroid_ = flagValue;
@@ -434,7 +470,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(22, "enableReportEventPaintTime");
markFlagAsAccessed(24, "enableReportEventPaintTime");
flagValue = currentProvider_->enableReportEventPaintTime();
enableReportEventPaintTime_ = flagValue;
@@ -452,7 +488,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(23, "enableSynchronousStateUpdates");
markFlagAsAccessed(25, "enableSynchronousStateUpdates");
flagValue = currentProvider_->enableSynchronousStateUpdates();
enableSynchronousStateUpdates_ = flagValue;
@@ -470,7 +506,7 @@ bool ReactNativeFeatureFlagsAccessor::enableTextPreallocationOptimisation() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(24, "enableTextPreallocationOptimisation");
markFlagAsAccessed(26, "enableTextPreallocationOptimisation");
flagValue = currentProvider_->enableTextPreallocationOptimisation();
enableTextPreallocationOptimisation_ = flagValue;
@@ -488,7 +524,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(25, "enableUIConsistency");
markFlagAsAccessed(27, "enableUIConsistency");
flagValue = currentProvider_->enableUIConsistency();
enableUIConsistency_ = flagValue;
@@ -506,7 +542,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(26, "enableViewRecycling");
markFlagAsAccessed(28, "enableViewRecycling");
flagValue = currentProvider_->enableViewRecycling();
enableViewRecycling_ = flagValue;
@@ -524,7 +560,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(27, "excludeYogaFromRawProps");
markFlagAsAccessed(29, "excludeYogaFromRawProps");
flagValue = currentProvider_->excludeYogaFromRawProps();
excludeYogaFromRawProps_ = flagValue;
@@ -542,7 +578,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(28, "fetchImagesInViewPreallocation");
markFlagAsAccessed(30, "fetchImagesInViewPreallocation");
flagValue = currentProvider_->fetchImagesInViewPreallocation();
fetchImagesInViewPreallocation_ = flagValue;
@@ -560,7 +596,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(29, "fixMappingOfEventPrioritiesBetweenFabricAndReact");
markFlagAsAccessed(31, "fixMappingOfEventPrioritiesBetweenFabricAndReact");
flagValue = currentProvider_->fixMappingOfEventPrioritiesBetweenFabricAndReact();
fixMappingOfEventPrioritiesBetweenFabricAndReact_ = flagValue;
@@ -578,7 +614,7 @@ bool ReactNativeFeatureFlagsAccessor::fixMountingCoordinatorReportedPendingTrans
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(30, "fixMountingCoordinatorReportedPendingTransactionsOnAndroid");
markFlagAsAccessed(32, "fixMountingCoordinatorReportedPendingTransactionsOnAndroid");
flagValue = currentProvider_->fixMountingCoordinatorReportedPendingTransactionsOnAndroid();
fixMountingCoordinatorReportedPendingTransactionsOnAndroid_ = flagValue;
@@ -596,7 +632,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(31, "forceBatchingMountItemsOnAndroid");
markFlagAsAccessed(33, "forceBatchingMountItemsOnAndroid");
flagValue = currentProvider_->forceBatchingMountItemsOnAndroid();
forceBatchingMountItemsOnAndroid_ = flagValue;
@@ -614,7 +650,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(32, "fuseboxEnabledDebug");
markFlagAsAccessed(34, "fuseboxEnabledDebug");
flagValue = currentProvider_->fuseboxEnabledDebug();
fuseboxEnabledDebug_ = flagValue;
@@ -632,7 +668,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(33, "fuseboxEnabledRelease");
markFlagAsAccessed(35, "fuseboxEnabledRelease");
flagValue = currentProvider_->fuseboxEnabledRelease();
fuseboxEnabledRelease_ = flagValue;
@@ -650,7 +686,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(34, "initEagerTurboModulesOnNativeModulesQueueAndroid");
markFlagAsAccessed(36, "initEagerTurboModulesOnNativeModulesQueueAndroid");
flagValue = currentProvider_->initEagerTurboModulesOnNativeModulesQueueAndroid();
initEagerTurboModulesOnNativeModulesQueueAndroid_ = flagValue;
@@ -668,7 +704,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(35, "lazyAnimationCallbacks");
markFlagAsAccessed(37, "lazyAnimationCallbacks");
flagValue = currentProvider_->lazyAnimationCallbacks();
lazyAnimationCallbacks_ = flagValue;
@@ -686,7 +722,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(36, "loadVectorDrawablesOnImages");
markFlagAsAccessed(38, "loadVectorDrawablesOnImages");
flagValue = currentProvider_->loadVectorDrawablesOnImages();
loadVectorDrawablesOnImages_ = flagValue;
@@ -704,7 +740,7 @@ bool ReactNativeFeatureFlagsAccessor::removeNestedCallsToDispatchMountItemsOnAnd
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(37, "removeNestedCallsToDispatchMountItemsOnAndroid");
markFlagAsAccessed(39, "removeNestedCallsToDispatchMountItemsOnAndroid");
flagValue = currentProvider_->removeNestedCallsToDispatchMountItemsOnAndroid();
removeNestedCallsToDispatchMountItemsOnAndroid_ = flagValue;
@@ -722,7 +758,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(38, "setAndroidLayoutDirection");
markFlagAsAccessed(40, "setAndroidLayoutDirection");
flagValue = currentProvider_->setAndroidLayoutDirection();
setAndroidLayoutDirection_ = flagValue;
@@ -740,7 +776,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(39, "traceTurboModulePromiseRejectionsOnAndroid");
markFlagAsAccessed(41, "traceTurboModulePromiseRejectionsOnAndroid");
flagValue = currentProvider_->traceTurboModulePromiseRejectionsOnAndroid();
traceTurboModulePromiseRejectionsOnAndroid_ = flagValue;
@@ -758,7 +794,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(40, "useFabricInterop");
markFlagAsAccessed(42, "useFabricInterop");
flagValue = currentProvider_->useFabricInterop();
useFabricInterop_ = flagValue;
@@ -776,7 +812,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(41, "useImmediateExecutorInAndroidBridgeless");
markFlagAsAccessed(43, "useImmediateExecutorInAndroidBridgeless");
flagValue = currentProvider_->useImmediateExecutorInAndroidBridgeless();
useImmediateExecutorInAndroidBridgeless_ = flagValue;
@@ -794,7 +830,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(42, "useModernRuntimeScheduler");
markFlagAsAccessed(44, "useModernRuntimeScheduler");
flagValue = currentProvider_->useModernRuntimeScheduler();
useModernRuntimeScheduler_ = flagValue;
@@ -812,7 +848,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(43, "useNativeViewConfigsInBridgelessMode");
markFlagAsAccessed(45, "useNativeViewConfigsInBridgelessMode");
flagValue = currentProvider_->useNativeViewConfigsInBridgelessMode();
useNativeViewConfigsInBridgelessMode_ = flagValue;
@@ -830,7 +866,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(44, "useNewReactImageViewBackgroundDrawing");
markFlagAsAccessed(46, "useNewReactImageViewBackgroundDrawing");
flagValue = currentProvider_->useNewReactImageViewBackgroundDrawing();
useNewReactImageViewBackgroundDrawing_ = flagValue;
@@ -848,7 +884,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(45, "useOptimisedViewPreallocationOnAndroid");
markFlagAsAccessed(47, "useOptimisedViewPreallocationOnAndroid");
flagValue = currentProvider_->useOptimisedViewPreallocationOnAndroid();
useOptimisedViewPreallocationOnAndroid_ = flagValue;
@@ -866,7 +902,7 @@ bool ReactNativeFeatureFlagsAccessor::useOptimizedEventBatchingOnAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(46, "useOptimizedEventBatchingOnAndroid");
markFlagAsAccessed(48, "useOptimizedEventBatchingOnAndroid");
flagValue = currentProvider_->useOptimizedEventBatchingOnAndroid();
useOptimizedEventBatchingOnAndroid_ = flagValue;
@@ -884,7 +920,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(47, "useRuntimeShadowNodeReferenceUpdate");
markFlagAsAccessed(49, "useRuntimeShadowNodeReferenceUpdate");
flagValue = currentProvider_->useRuntimeShadowNodeReferenceUpdate();
useRuntimeShadowNodeReferenceUpdate_ = flagValue;
@@ -902,7 +938,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(48, "useRuntimeShadowNodeReferenceUpdateOnLayout");
markFlagAsAccessed(50, "useRuntimeShadowNodeReferenceUpdateOnLayout");
flagValue = currentProvider_->useRuntimeShadowNodeReferenceUpdateOnLayout();
useRuntimeShadowNodeReferenceUpdateOnLayout_ = flagValue;
@@ -920,7 +956,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(49, "useStateAlignmentMechanism");
markFlagAsAccessed(51, "useStateAlignmentMechanism");
flagValue = currentProvider_->useStateAlignmentMechanism();
useStateAlignmentMechanism_ = flagValue;
@@ -938,7 +974,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(50, "useTurboModuleInterop");
markFlagAsAccessed(52, "useTurboModuleInterop");
flagValue = currentProvider_->useTurboModuleInterop();
useTurboModuleInterop_ = flagValue;
@@ -947,6 +983,24 @@ bool ReactNativeFeatureFlagsAccessor::useTurboModuleInterop() {
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::useTurboModules() {
auto flagValue = useTurboModules_.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(53, "useTurboModules");
flagValue = currentProvider_->useTurboModules();
useTurboModules_ = flagValue;
}
return flagValue.value();
}
void ReactNativeFeatureFlagsAccessor::override(
std::unique_ptr<ReactNativeFeatureFlagsProvider> provider) {
if (wasOverridden_) {
@@ -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<<3273d68bcf8118b939e11dde654c3e34>>
* @generated SignedSource<<5f2c9b500fc26e68d56efae08b15575f>>
*/
/**
@@ -40,11 +40,13 @@ class ReactNativeFeatureFlagsAccessor {
bool enableAndroidLineHeightCentering();
bool enableAndroidMixBlendModeProp();
bool enableBackgroundStyleApplicator();
bool enableBridgelessArchitecture();
bool enableCleanTextInputYogaNode();
bool enableDeletionOfUnmountedViews();
bool enableEagerRootViewAttachment();
bool enableEventEmitterRetentionDuringGesturesOnAndroid();
bool enableFabricLogs();
bool enableFabricRenderer();
bool enableFabricRendererExclusively();
bool enableGranularShadowTreeStateReconciliation();
bool enableIOSViewClipToPaddingBox();
@@ -82,6 +84,7 @@ class ReactNativeFeatureFlagsAccessor {
bool useRuntimeShadowNodeReferenceUpdateOnLayout();
bool useStateAlignmentMechanism();
bool useTurboModuleInterop();
bool useTurboModules();
void override(std::unique_ptr<ReactNativeFeatureFlagsProvider> provider);
@@ -92,7 +95,7 @@ class ReactNativeFeatureFlagsAccessor {
std::unique_ptr<ReactNativeFeatureFlagsProvider> currentProvider_;
bool wasOverridden_;
std::array<std::atomic<const char*>, 51> accessedFeatureFlags_;
std::array<std::atomic<const char*>, 54> accessedFeatureFlags_;
std::atomic<std::optional<bool>> commonTestFlag_;
std::atomic<std::optional<bool>> allowRecursiveCommitsWithSynchronousMountOnAndroid_;
@@ -103,11 +106,13 @@ class ReactNativeFeatureFlagsAccessor {
std::atomic<std::optional<bool>> enableAndroidLineHeightCentering_;
std::atomic<std::optional<bool>> enableAndroidMixBlendModeProp_;
std::atomic<std::optional<bool>> enableBackgroundStyleApplicator_;
std::atomic<std::optional<bool>> enableBridgelessArchitecture_;
std::atomic<std::optional<bool>> enableCleanTextInputYogaNode_;
std::atomic<std::optional<bool>> enableDeletionOfUnmountedViews_;
std::atomic<std::optional<bool>> enableEagerRootViewAttachment_;
std::atomic<std::optional<bool>> enableEventEmitterRetentionDuringGesturesOnAndroid_;
std::atomic<std::optional<bool>> enableFabricLogs_;
std::atomic<std::optional<bool>> enableFabricRenderer_;
std::atomic<std::optional<bool>> enableFabricRendererExclusively_;
std::atomic<std::optional<bool>> enableGranularShadowTreeStateReconciliation_;
std::atomic<std::optional<bool>> enableIOSViewClipToPaddingBox_;
@@ -145,6 +150,7 @@ class ReactNativeFeatureFlagsAccessor {
std::atomic<std::optional<bool>> useRuntimeShadowNodeReferenceUpdateOnLayout_;
std::atomic<std::optional<bool>> useStateAlignmentMechanism_;
std::atomic<std::optional<bool>> useTurboModuleInterop_;
std::atomic<std::optional<bool>> useTurboModules_;
};
} // namespace facebook::react
@@ -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<<3ba99bf8dd5f7e146e3488dbc8bc59c8>>
* @generated SignedSource<<fb3d7a930222a40e9a8c377989713b07>>
*/
/**
@@ -63,6 +63,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
return true;
}
bool enableBridgelessArchitecture() override {
return false;
}
bool enableCleanTextInputYogaNode() override {
return false;
}
@@ -83,6 +87,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
return false;
}
bool enableFabricRenderer() override {
return false;
}
bool enableFabricRendererExclusively() override {
return false;
}
@@ -230,6 +238,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
bool useTurboModuleInterop() override {
return false;
}
bool useTurboModules() override {
return false;
}
};
} // namespace facebook::react
@@ -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<<727c5ccb59b23aa6e14d58121e0007bd>>
* @generated SignedSource<<aaa516b2c719cb871f08c65bd7ce072f>>
*/
/**
@@ -34,11 +34,13 @@ class ReactNativeFeatureFlagsProvider {
virtual bool enableAndroidLineHeightCentering() = 0;
virtual bool enableAndroidMixBlendModeProp() = 0;
virtual bool enableBackgroundStyleApplicator() = 0;
virtual bool enableBridgelessArchitecture() = 0;
virtual bool enableCleanTextInputYogaNode() = 0;
virtual bool enableDeletionOfUnmountedViews() = 0;
virtual bool enableEagerRootViewAttachment() = 0;
virtual bool enableEventEmitterRetentionDuringGesturesOnAndroid() = 0;
virtual bool enableFabricLogs() = 0;
virtual bool enableFabricRenderer() = 0;
virtual bool enableFabricRendererExclusively() = 0;
virtual bool enableGranularShadowTreeStateReconciliation() = 0;
virtual bool enableIOSViewClipToPaddingBox() = 0;
@@ -76,6 +78,7 @@ class ReactNativeFeatureFlagsProvider {
virtual bool useRuntimeShadowNodeReferenceUpdateOnLayout() = 0;
virtual bool useStateAlignmentMechanism() = 0;
virtual bool useTurboModuleInterop() = 0;
virtual bool useTurboModules() = 0;
};
} // namespace facebook::react
@@ -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<<b166070ae3a427dd654ebc16e77fb8e3>>
* @generated SignedSource<<2b484558d552981e4ec0644d75849dde>>
*/
/**
@@ -82,6 +82,11 @@ bool NativeReactNativeFeatureFlags::enableBackgroundStyleApplicator(
return ReactNativeFeatureFlags::enableBackgroundStyleApplicator();
}
bool NativeReactNativeFeatureFlags::enableBridgelessArchitecture(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::enableBridgelessArchitecture();
}
bool NativeReactNativeFeatureFlags::enableCleanTextInputYogaNode(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::enableCleanTextInputYogaNode();
@@ -107,6 +112,11 @@ bool NativeReactNativeFeatureFlags::enableFabricLogs(
return ReactNativeFeatureFlags::enableFabricLogs();
}
bool NativeReactNativeFeatureFlags::enableFabricRenderer(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::enableFabricRenderer();
}
bool NativeReactNativeFeatureFlags::enableFabricRendererExclusively(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::enableFabricRendererExclusively();
@@ -292,4 +302,9 @@ bool NativeReactNativeFeatureFlags::useTurboModuleInterop(
return ReactNativeFeatureFlags::useTurboModuleInterop();
}
bool NativeReactNativeFeatureFlags::useTurboModules(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::useTurboModules();
}
} // namespace facebook::react
@@ -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<<596ec10892f79595c352d27574a0c5a3>>
* @generated SignedSource<<94afee988401ba2af586ec8fe310cb8b>>
*/
/**
@@ -53,6 +53,8 @@ class NativeReactNativeFeatureFlags
bool enableBackgroundStyleApplicator(jsi::Runtime& runtime);
bool enableBridgelessArchitecture(jsi::Runtime& runtime);
bool enableCleanTextInputYogaNode(jsi::Runtime& runtime);
bool enableDeletionOfUnmountedViews(jsi::Runtime& runtime);
@@ -63,6 +65,8 @@ class NativeReactNativeFeatureFlags
bool enableFabricLogs(jsi::Runtime& runtime);
bool enableFabricRenderer(jsi::Runtime& runtime);
bool enableFabricRendererExclusively(jsi::Runtime& runtime);
bool enableGranularShadowTreeStateReconciliation(jsi::Runtime& runtime);
@@ -136,6 +140,8 @@ class NativeReactNativeFeatureFlags
bool useStateAlignmentMechanism(jsi::Runtime& runtime);
bool useTurboModuleInterop(jsi::Runtime& runtime);
bool useTurboModules(jsi::Runtime& runtime);
};
} // namespace facebook::react
@@ -115,6 +115,14 @@ const definitions: FeatureFlagDefinitions = {
purpose: 'experimentation',
},
},
enableBridgelessArchitecture: {
defaultValue: false,
metadata: {
description:
'Feature flag to enable the new bridgeless architecture. Note: Enabling this will force enable the following flags: `useTurboModules` & `enableFabricRenderer.',
purpose: 'release',
},
},
enableCleanTextInputYogaNode: {
defaultValue: false,
metadata: {
@@ -157,6 +165,13 @@ const definitions: FeatureFlagDefinitions = {
purpose: 'operational',
},
},
enableFabricRenderer: {
defaultValue: false,
metadata: {
description: 'Enables the use of the Fabric renderer in the whole app.',
purpose: 'release',
},
},
enableFabricRendererExclusively: {
defaultValue: false,
metadata: {
@@ -478,6 +493,14 @@ const definitions: FeatureFlagDefinitions = {
purpose: 'experimentation',
},
},
useTurboModules: {
defaultValue: false,
metadata: {
description:
'When enabled, NativeModules will be executed by using the TurboModule system',
purpose: 'release',
},
},
},
jsOnly: {
@@ -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<<b7171b730c25a06f13d74306e1bffd8b>>
* @generated SignedSource<<c9497d9d49c14ab537fd8b337f1c5836>>
* @flow strict
*/
@@ -58,11 +58,13 @@ export type ReactNativeFeatureFlags = {
enableAndroidLineHeightCentering: Getter<boolean>,
enableAndroidMixBlendModeProp: Getter<boolean>,
enableBackgroundStyleApplicator: Getter<boolean>,
enableBridgelessArchitecture: Getter<boolean>,
enableCleanTextInputYogaNode: Getter<boolean>,
enableDeletionOfUnmountedViews: Getter<boolean>,
enableEagerRootViewAttachment: Getter<boolean>,
enableEventEmitterRetentionDuringGesturesOnAndroid: Getter<boolean>,
enableFabricLogs: Getter<boolean>,
enableFabricRenderer: Getter<boolean>,
enableFabricRendererExclusively: Getter<boolean>,
enableGranularShadowTreeStateReconciliation: Getter<boolean>,
enableIOSViewClipToPaddingBox: Getter<boolean>,
@@ -100,6 +102,7 @@ export type ReactNativeFeatureFlags = {
useRuntimeShadowNodeReferenceUpdateOnLayout: Getter<boolean>,
useStateAlignmentMechanism: Getter<boolean>,
useTurboModuleInterop: Getter<boolean>,
useTurboModules: Getter<boolean>,
}
/**
@@ -218,6 +221,10 @@ export const enableAndroidMixBlendModeProp: Getter<boolean> = createNativeFlagGe
* Use BackgroundStyleApplicator in place of other background/border drawing code
*/
export const enableBackgroundStyleApplicator: Getter<boolean> = createNativeFlagGetter('enableBackgroundStyleApplicator', true);
/**
* Feature flag to enable the new bridgeless architecture. Note: Enabling this will force enable the following flags: `useTurboModules` & `enableFabricRenderer.
*/
export const enableBridgelessArchitecture: Getter<boolean> = createNativeFlagGetter('enableBridgelessArchitecture', false);
/**
* Clean yoga node when <TextInput /> does not change.
*/
@@ -238,6 +245,10 @@ export const enableEventEmitterRetentionDuringGesturesOnAndroid: Getter<boolean>
* This feature flag enables logs for Fabric.
*/
export const enableFabricLogs: Getter<boolean> = createNativeFlagGetter('enableFabricLogs', false);
/**
* Enables the use of the Fabric renderer in the whole app.
*/
export const enableFabricRenderer: Getter<boolean> = createNativeFlagGetter('enableFabricRenderer', 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.
*/
@@ -386,6 +397,10 @@ export const useStateAlignmentMechanism: Getter<boolean> = createNativeFlagGette
* In Bridgeless mode, should legacy NativeModules use the TurboModule system?
*/
export const useTurboModuleInterop: Getter<boolean> = createNativeFlagGetter('useTurboModuleInterop', false);
/**
* When enabled, NativeModules will be executed by using the TurboModule system
*/
export const useTurboModules: Getter<boolean> = createNativeFlagGetter('useTurboModules', false);
/**
* Overrides the feature flags with the provided methods.
@@ -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<<ee3f60941427d4efa2f5b03bf0b78514>>
* @generated SignedSource<<0467a8715892bbeca0a08681c730aeab>>
* @flow strict
*/
@@ -32,11 +32,13 @@ export interface Spec extends TurboModule {
+enableAndroidLineHeightCentering?: () => boolean;
+enableAndroidMixBlendModeProp?: () => boolean;
+enableBackgroundStyleApplicator?: () => boolean;
+enableBridgelessArchitecture?: () => boolean;
+enableCleanTextInputYogaNode?: () => boolean;
+enableDeletionOfUnmountedViews?: () => boolean;
+enableEagerRootViewAttachment?: () => boolean;
+enableEventEmitterRetentionDuringGesturesOnAndroid?: () => boolean;
+enableFabricLogs?: () => boolean;
+enableFabricRenderer?: () => boolean;
+enableFabricRendererExclusively?: () => boolean;
+enableGranularShadowTreeStateReconciliation?: () => boolean;
+enableIOSViewClipToPaddingBox?: () => boolean;
@@ -74,6 +76,7 @@ export interface Spec extends TurboModule {
+useRuntimeShadowNodeReferenceUpdateOnLayout?: () => boolean;
+useStateAlignmentMechanism?: () => boolean;
+useTurboModuleInterop?: () => boolean;
+useTurboModules?: () => boolean;
}
const NativeReactNativeFeatureFlags: ?Spec = TurboModuleRegistry.get<Spec>(