Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/react-native/React/Fabric/RCTSurfacePresenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#import <React/RCTUtils.h>

#import <react/config/ReactNativeConfig.h>
#import <react/featureflags/ReactNativeFeatureFlags.h>
#import <react/renderer/componentregistry/ComponentDescriptorFactory.h>
#import <react/renderer/components/text/BaseTextProps.h>
#import <react/renderer/runtimescheduler/RuntimeScheduler.h>
Expand Down Expand Up @@ -301,7 +302,7 @@ - (RCTScheduler *)_createScheduler
return std::make_unique<MainRunLoopObserver>(activities, owner);
};

if (reactNativeConfig && reactNativeConfig->getBool("react_fabric:enable_background_executor_ios")) {
if (ReactNativeFeatureFlags::enableBackgroundExecutor()) {
toolbox.backgroundExecutor = RCTGetBackgroundExecutor();
}

Expand Down
1 change: 1 addition & 0 deletions packages/react-native/React/React-RCTFabric.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Pod::Spec.new do |s|
add_dependency(s, "React-nativeconfig")
add_dependency(s, "React-graphics", :additional_framework_paths => ["react/renderer/graphics/platform/ios"])
add_dependency(s, "React-ImageManager")
add_dependency(s, "React-featureflags")
add_dependency(s, "React-debug")
add_dependency(s, "React-utils")
add_dependency(s, "React-rendererdebug")
Expand Down
1 change: 0 additions & 1 deletion packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -1890,7 +1890,6 @@ public class com/facebook/react/common/network/OkHttpCallUtil {
public class com/facebook/react/config/ReactFeatureFlags {
public static field calculateTransformedFramesEnabled Z
public static field dispatchPointerEvents Z
public static field enableBackgroundExecutor Z
public static field enableBridgelessArchitecture Z
public static field enableBridgelessArchitectureNewCreateReloadDestroy Z
public static field enableBridgelessArchitectureSoftExceptions Z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ public class ReactFeatureFlags {
/** Report mount operations from the host platform to notify mount hooks. */
public static boolean enableMountHooks = false;

/** Disable the background executor for layout in Fabric */
public static boolean enableBackgroundExecutor = false;

/** Use native view configs in bridgeless mode. */
public static boolean useNativeViewConfigsInBridgelessMode = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<f5d5bb65068bb515d33da8bff665dfd2>>
* @generated SignedSource<<5af2b68c126a1f5127deba7494075b47>>
*/

/**
Expand Down Expand Up @@ -34,6 +34,12 @@ object ReactNativeFeatureFlags {
@JvmStatic
fun commonTestFlag() = accessor.commonTestFlag()

/**
* Enables the use of a background executor to compute layout and commit updates on Fabric (this system is deprecated and should not be used).
*/
@JvmStatic
fun enableBackgroundExecutor() = accessor.enableBackgroundExecutor()

/**
* When enabled, it uses the modern fork of RuntimeScheduler that allows scheduling tasks with priorities from any thread.
*/
Expand Down Expand Up @@ -84,6 +90,7 @@ object ReactNativeFeatureFlags {
* })
* ```
*/
@JvmStatic
fun override(provider: ReactNativeFeatureFlagsProvider) = accessor.override(provider)

/**
Expand All @@ -95,6 +102,7 @@ object ReactNativeFeatureFlags {
* call `dangerouslyReset` after destroying the runtime and `override`
* again before initializing the new one.
*/
@JvmStatic
fun dangerouslyReset() {
// This is necessary when the accessor interops with C++ and we need to
// remove the overrides set there.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<d4ece56f9329579346fbfe08f7681632>>
* @generated SignedSource<<1741a8a82b193bf389f45d104ae295fb>>
*/

/**
Expand All @@ -21,6 +21,7 @@ package com.facebook.react.internal.featureflags

class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccessor {
private var commonTestFlagCache: Boolean? = null
private var enableBackgroundExecutorCache: Boolean? = null
private var useModernRuntimeSchedulerCache: Boolean? = null
private var enableMicrotasksCache: Boolean? = null
private var batchRenderingUpdatesInEventLoopCache: Boolean? = null
Expand All @@ -37,6 +38,15 @@ class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAccessor {
return cached
}

override fun enableBackgroundExecutor(): Boolean {
var cached = enableBackgroundExecutorCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.enableBackgroundExecutor()
enableBackgroundExecutorCache = cached
}
return cached
}

override fun useModernRuntimeScheduler(): Boolean {
var cached = useModernRuntimeSchedulerCache
if (cached == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<41a2646126f7f448be8c8397b1698a4a>>
* @generated SignedSource<<4b555581d91d1a59b7bfccd9c3d700df>>
*/

/**
Expand All @@ -30,6 +30,8 @@ object ReactNativeFeatureFlagsCxxInterop {

@DoNotStrip @JvmStatic external fun commonTestFlag(): Boolean

@DoNotStrip @JvmStatic external fun enableBackgroundExecutor(): Boolean

@DoNotStrip @JvmStatic external fun useModernRuntimeScheduler(): Boolean

@DoNotStrip @JvmStatic external fun enableMicrotasks(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<fc15c71267f1bf2f65c4f3877599c4c7>>
* @generated SignedSource<<4fc58cba11db962f828efc4e20391303>>
*/

/**
Expand All @@ -25,6 +25,8 @@ open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvider {

override fun commonTestFlag(): Boolean = false

override fun enableBackgroundExecutor(): Boolean = false

override fun useModernRuntimeScheduler(): Boolean = false

override fun enableMicrotasks(): Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<77fc4d6577fc0e2e9a0500cc762bba77>>
* @generated SignedSource<<0aac45f1506afa2f20ad730c53755abd>>
*/

/**
Expand All @@ -25,6 +25,7 @@ class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAccessor {
private val accessedFeatureFlags = mutableSetOf<String>()

private var commonTestFlagCache: Boolean? = null
private var enableBackgroundExecutorCache: Boolean? = null
private var useModernRuntimeSchedulerCache: Boolean? = null
private var enableMicrotasksCache: Boolean? = null
private var batchRenderingUpdatesInEventLoopCache: Boolean? = null
Expand All @@ -42,6 +43,16 @@ class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAccessor {
return cached
}

override fun enableBackgroundExecutor(): Boolean {
var cached = enableBackgroundExecutorCache
if (cached == null) {
cached = currentProvider.enableBackgroundExecutor()
accessedFeatureFlags.add("enableBackgroundExecutor")
enableBackgroundExecutorCache = cached
}
return cached
}

override fun useModernRuntimeScheduler(): Boolean {
var cached = useModernRuntimeSchedulerCache
if (cached == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<49a63388fa661d81b9cec735ac705bd0>>
* @generated SignedSource<<3ec82b003df6f3743305f6161c301360>>
*/

/**
Expand All @@ -25,6 +25,8 @@ import com.facebook.proguard.annotations.DoNotStrip
interface ReactNativeFeatureFlagsProvider {
@DoNotStrip fun commonTestFlag(): Boolean

@DoNotStrip fun enableBackgroundExecutor(): Boolean

@DoNotStrip fun useModernRuntimeScheduler(): Boolean

@DoNotStrip fun enableMicrotasks(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <glog/logging.h>
#include <jsi/JSIDynamic.h>
#include <jsi/jsi.h>
#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <react/renderer/animations/LayoutAnimationDriver.h>
#include <react/renderer/componentregistry/ComponentDescriptorFactory.h>
#include <react/renderer/core/EventBeat.h>
Expand Down Expand Up @@ -435,7 +436,7 @@ void Binding::installFabricUIManager(
toolbox.synchronousEventBeatFactory = synchronousBeatFactory;
toolbox.asynchronousEventBeatFactory = asynchronousBeatFactory;

if (getFeatureFlagValue("enableBackgroundExecutor")) {
if (ReactNativeFeatureFlags::enableBackgroundExecutor()) {
backgroundExecutor_ = JBackgroundExecutor::create("fabric_bg");
toolbox.backgroundExecutor = backgroundExecutor_;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<18e31d0833fda8cfb3f31b449479297a>>
* @generated SignedSource<<e388f7ac501dba65bee597ccf8305453>>
*/

/**
Expand Down Expand Up @@ -45,6 +45,12 @@ class ReactNativeFeatureFlagsProviderHolder
return method(javaProvider_);
}

bool enableBackgroundExecutor() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableBackgroundExecutor");
return method(javaProvider_);
}

bool useModernRuntimeScheduler() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("useModernRuntimeScheduler");
Expand Down Expand Up @@ -90,6 +96,11 @@ bool JReactNativeFeatureFlagsCxxInterop::commonTestFlag(
return ReactNativeFeatureFlags::commonTestFlag();
}

bool JReactNativeFeatureFlagsCxxInterop::enableBackgroundExecutor(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::enableBackgroundExecutor();
}

bool JReactNativeFeatureFlagsCxxInterop::useModernRuntimeScheduler(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::useModernRuntimeScheduler();
Expand Down Expand Up @@ -140,6 +151,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"commonTestFlag",
JReactNativeFeatureFlagsCxxInterop::commonTestFlag),
makeNativeMethod(
"enableBackgroundExecutor",
JReactNativeFeatureFlagsCxxInterop::enableBackgroundExecutor),
makeNativeMethod(
"useModernRuntimeScheduler",
JReactNativeFeatureFlagsCxxInterop::useModernRuntimeScheduler),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<356873b4021fcfe9a2afa79417813975>>
* @generated SignedSource<<a06796ea8a786672459bcdbcc25e9b69>>
*/

/**
Expand Down Expand Up @@ -33,6 +33,9 @@ class JReactNativeFeatureFlagsCxxInterop
static bool commonTestFlag(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

static bool enableBackgroundExecutor(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

static bool useModernRuntimeScheduler(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<c43f5dfe4a0e12da0595071319c91e63>>
* @generated SignedSource<<28d4d1d52be9cb5dccd5a3802df64fc3>>
*/

/**
Expand All @@ -25,6 +25,10 @@ bool ReactNativeFeatureFlags::commonTestFlag() {
return getAccessor().commonTestFlag();
}

bool ReactNativeFeatureFlags::enableBackgroundExecutor() {
return getAccessor().enableBackgroundExecutor();
}

bool ReactNativeFeatureFlags::useModernRuntimeScheduler() {
return getAccessor().useModernRuntimeScheduler();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<<c0d0f4bb2eb2dbf385d56f58444fb16a>>
* @generated SignedSource<<979ad8a28efe3ca5d775596dc8b298d8>>
*/

/**
Expand Down Expand Up @@ -38,6 +38,11 @@ class ReactNativeFeatureFlags {
*/
static bool commonTestFlag();

/**
* Enables the use of a background executor to compute layout and commit updates on Fabric (this system is deprecated and should not be used).
*/
static bool enableBackgroundExecutor();

/**
* When enabled, it uses the modern fork of RuntimeScheduler that allows scheduling tasks with priorities from any thread.
*/
Expand Down
Loading