Remove enableMainQueueCoordinatorOnIOS, make coordinator always-on (#56935)

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

The `enableMainQueueCoordinatorOnIOS` flag has finished rollout. Drop it from the feature-flag config, regenerate the per-language accessors, and inline the previously-gated paths:

- `RCTUtils.mm`: `RCTUnsafeExecuteOnMainQueueSync` and the `RCTUnsafeExecuteOnMainQueueOnceSync` helper always use `unsafeExecuteOnMainThreadSync` on iOS (the TV fallback to `dispatch_sync(main, ...)` stays).
- `RuntimeExecutorSyncUIThreadUtils.mm`: `executeSynchronouslyOnSameThread_CAN_DEADLOCK` switches between two paths based on the calling thread instead of the feature flag. Main-thread callers (production) take the coordinator path that pumps UI tasks while waiting for JS; off-main callers (e.g. RuntimeScheduler unit tests) take a simpler path that just waits for the runtime and runs `runtimeWork` synchronously on the calling thread. Trimmed the `runtimeCaptureBlockDone` plumbing that an old TODO already flagged as unnecessary.

Also drops the iOS override in the Wilde plugin, the now-dead `rn_fling.enable_main_queue_coordinator_on_ios` MobileConfig param, and the `flagOff` variant of the characterization test (the on-path test still pins the contract).

Changelog:
[iOS][Changed] - `RCTUnsafeExecuteOnMainQueueSync` and bridgeless sync runtime-thread calls now always use the coordinator implementation that pumps UI tasks while waiting for JS, eliminating a class of deadlocks. The previous opt-in flag has been removed.

Reviewed By: sammy-SC

Differential Revision: D105984547

fbshipit-source-id: 1eee1b6e5875b108e145fdd295dd3951ba1d839b
This commit is contained in:
Pieter De Baets authored and meta-codesync[bot] committed 2026-05-27 13:26:26 -07:00
1 parent f14207f9bd
commit eaf770433a
24 files changed
+104 -304

No files matched your search

+6 -13
View File
@@ -11,7 +11,6 @@
#import <mach/mach_time.h>
#import <objc/message.h>
#import <objc/runtime.h>
#import <react/featureflags/ReactNativeFeatureFlags.h>
#import <zlib.h>
#import <UIKit/UIKit.h>
@@ -312,15 +311,12 @@ void RCTUnsafeExecuteOnMainQueueSync(dispatch_block_t block)
}
#if !TARGET_OS_TV
if (ReactNativeFeatureFlags::enableMainQueueCoordinatorOnIOS()) {
unsafeExecuteOnMainThreadSync(block);
return;
}
#endif
unsafeExecuteOnMainThreadSync(block);
#else
dispatch_sync(dispatch_get_main_queue(), ^{
block();
});
#endif
}
static void RCTUnsafeExecuteOnMainQueueOnceSync(dispatch_once_t *onceToken, dispatch_block_t block)
@@ -342,13 +338,10 @@ static void RCTUnsafeExecuteOnMainQueueOnceSync(dispatch_once_t *onceToken, disp
}
#if !TARGET_OS_TV
if (ReactNativeFeatureFlags::enableMainQueueCoordinatorOnIOS()) {
unsafeExecuteOnMainThreadSync(block);
return;
}
#endif
unsafeExecuteOnMainThreadSync(block);
#else
dispatch_sync(dispatch_get_main_queue(), executeOnce);
#endif
}
CGFloat RCTScreenScale(void)
@@ -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<<fa3d35be13801d5991e6bfb2cef2ef43>>
* @generated SignedSource<<86c797c19cc585b74714ca3aa75bbd6d>>
*/
/**
@@ -240,12 +240,6 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun enableLayoutAnimationsOnIOS(): Boolean = accessor.enableLayoutAnimationsOnIOS()
/**
* Make RCTUnsafeExecuteOnMainQueueSync less likely to deadlock, when used in conjuction with sync rendering/events.
*/
@JvmStatic
public fun enableMainQueueCoordinatorOnIOS(): Boolean = accessor.enableMainQueueCoordinatorOnIOS()
/**
* Enable NSNull conversion when handling module arguments on iOS
*/
@@ -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<<c8e71de4517634933754c6e7a6e8ac92>>
* @generated SignedSource<<d71556cf1226fe6a41dd388568153d3a>>
*/
/**
@@ -55,7 +55,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
private var enableKeyEventsCache: Boolean? = null
private var enableLayoutAnimationsOnAndroidCache: Boolean? = null
private var enableLayoutAnimationsOnIOSCache: Boolean? = null
private var enableMainQueueCoordinatorOnIOSCache: Boolean? = null
private var enableModuleArgumentNSNullConversionIOSCache: Boolean? = null
private var enableMutationObserverByDefaultCache: Boolean? = null
private var enableNativeCSSParsingCache: Boolean? = null
@@ -424,15 +423,6 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
return cached
}
override fun enableMainQueueCoordinatorOnIOS(): Boolean {
var cached = enableMainQueueCoordinatorOnIOSCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.enableMainQueueCoordinatorOnIOS()
enableMainQueueCoordinatorOnIOSCache = cached
}
return cached
}
override fun enableModuleArgumentNSNullConversionIOS(): Boolean {
var cached = enableModuleArgumentNSNullConversionIOSCache
if (cached == null) {
@@ -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<<9d3495c774e4367973974a4f83ea7d16>>
* @generated SignedSource<<2ee82b1e1dcae3ea10dbd92549d65a6c>>
*/
/**
@@ -98,8 +98,6 @@ public object ReactNativeFeatureFlagsCxxInterop {
@DoNotStrip @JvmStatic public external fun enableLayoutAnimationsOnIOS(): Boolean
@DoNotStrip @JvmStatic public external fun enableMainQueueCoordinatorOnIOS(): Boolean
@DoNotStrip @JvmStatic public external fun enableModuleArgumentNSNullConversionIOS(): Boolean
@DoNotStrip @JvmStatic public external fun enableMutationObserverByDefault(): Boolean
@@ -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<<811ccbada43f15c9418e0177041c5747>>
* @generated SignedSource<<738a114e73ddb940fb14efd0dff79d1b>>
*/
/**
@@ -93,8 +93,6 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
override fun enableLayoutAnimationsOnIOS(): Boolean = true
override fun enableMainQueueCoordinatorOnIOS(): Boolean = false
override fun enableModuleArgumentNSNullConversionIOS(): Boolean = false
override fun enableMutationObserverByDefault(): 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<<69c333993720f22c6db80f3aceae32cd>>
* @generated SignedSource<<d5b84c7e0c58f61d891e0dd63f61b4c0>>
*/
/**
@@ -59,7 +59,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
private var enableKeyEventsCache: Boolean? = null
private var enableLayoutAnimationsOnAndroidCache: Boolean? = null
private var enableLayoutAnimationsOnIOSCache: Boolean? = null
private var enableMainQueueCoordinatorOnIOSCache: Boolean? = null
private var enableModuleArgumentNSNullConversionIOSCache: Boolean? = null
private var enableMutationObserverByDefaultCache: Boolean? = null
private var enableNativeCSSParsingCache: Boolean? = null
@@ -463,16 +462,6 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
return cached
}
override fun enableMainQueueCoordinatorOnIOS(): Boolean {
var cached = enableMainQueueCoordinatorOnIOSCache
if (cached == null) {
cached = currentProvider.enableMainQueueCoordinatorOnIOS()
accessedFeatureFlags.add("enableMainQueueCoordinatorOnIOS")
enableMainQueueCoordinatorOnIOSCache = cached
}
return cached
}
override fun enableModuleArgumentNSNullConversionIOS(): Boolean {
var cached = enableModuleArgumentNSNullConversionIOSCache
if (cached == null) {
@@ -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<<cb5de865c68dfd9b7b7b2d86d9fb090b>>
* @generated SignedSource<<a3dbeb4eec6efecc4fc355b15a984e58>>
*/
/**
@@ -93,8 +93,6 @@ public interface ReactNativeFeatureFlagsProvider {
@DoNotStrip public fun enableLayoutAnimationsOnIOS(): Boolean
@DoNotStrip public fun enableMainQueueCoordinatorOnIOS(): Boolean
@DoNotStrip public fun enableModuleArgumentNSNullConversionIOS(): Boolean
@DoNotStrip public fun enableMutationObserverByDefault(): Boolean
@@ -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<<f667d1281347eeacfca65411acdf6dc7>>
* @generated SignedSource<<99f843dd0784f9fe372f943767e2033c>>
*/
/**
@@ -249,12 +249,6 @@ class ReactNativeFeatureFlagsJavaProvider
return method(javaProvider_);
}
bool enableMainQueueCoordinatorOnIOS() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableMainQueueCoordinatorOnIOS");
return method(javaProvider_);
}
bool enableModuleArgumentNSNullConversionIOS() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("enableModuleArgumentNSNullConversionIOS");
@@ -746,11 +740,6 @@ bool JReactNativeFeatureFlagsCxxInterop::enableLayoutAnimationsOnIOS(
return ReactNativeFeatureFlags::enableLayoutAnimationsOnIOS();
}
bool JReactNativeFeatureFlagsCxxInterop::enableMainQueueCoordinatorOnIOS(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::enableMainQueueCoordinatorOnIOS();
}
bool JReactNativeFeatureFlagsCxxInterop::enableModuleArgumentNSNullConversionIOS(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::enableModuleArgumentNSNullConversionIOS();
@@ -1147,9 +1136,6 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"enableLayoutAnimationsOnIOS",
JReactNativeFeatureFlagsCxxInterop::enableLayoutAnimationsOnIOS),
makeNativeMethod(
"enableMainQueueCoordinatorOnIOS",
JReactNativeFeatureFlagsCxxInterop::enableMainQueueCoordinatorOnIOS),
makeNativeMethod(
"enableModuleArgumentNSNullConversionIOS",
JReactNativeFeatureFlagsCxxInterop::enableModuleArgumentNSNullConversionIOS),
@@ -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<<f2dbc5e247060946295f35a07191c213>>
* @generated SignedSource<<05716b6ab8139bc31b962f9158acd6b6>>
*/
/**
@@ -135,9 +135,6 @@ class JReactNativeFeatureFlagsCxxInterop
static bool enableLayoutAnimationsOnIOS(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool enableMainQueueCoordinatorOnIOS(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
static bool enableModuleArgumentNSNullConversionIOS(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
@@ -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<<177c370caf828494ce42486af0d8c698>>
* @generated SignedSource<<dda96e26972d745fa18d802035194cf0>>
*/
/**
@@ -166,10 +166,6 @@ bool ReactNativeFeatureFlags::enableLayoutAnimationsOnIOS() {
return getAccessor().enableLayoutAnimationsOnIOS();
}
bool ReactNativeFeatureFlags::enableMainQueueCoordinatorOnIOS() {
return getAccessor().enableMainQueueCoordinatorOnIOS();
}
bool ReactNativeFeatureFlags::enableModuleArgumentNSNullConversionIOS() {
return getAccessor().enableModuleArgumentNSNullConversionIOS();
}
@@ -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<<5ff6ec567d516d966cb2fadfc5cc93b3>>
* @generated SignedSource<<dcb1e3ba662f28194124dc63879f4fde>>
*/
/**
@@ -214,11 +214,6 @@ class ReactNativeFeatureFlags {
*/
RN_EXPORT static bool enableLayoutAnimationsOnIOS();
/**
* Make RCTUnsafeExecuteOnMainQueueSync less likely to deadlock, when used in conjuction with sync rendering/events.
*/
RN_EXPORT static bool enableMainQueueCoordinatorOnIOS();
/**
* Enable NSNull conversion when handling module arguments on iOS
*/
@@ -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<<015535e3b014cc48e24628deeb6209de>>
* @generated SignedSource<<802368c8b05006c737ab106bcb9ecf00>>
*/
/**
@@ -659,24 +659,6 @@ bool ReactNativeFeatureFlagsAccessor::enableLayoutAnimationsOnIOS() {
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::enableMainQueueCoordinatorOnIOS() {
auto flagValue = enableMainQueueCoordinatorOnIOS_.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(35, "enableMainQueueCoordinatorOnIOS");
flagValue = currentProvider_->enableMainQueueCoordinatorOnIOS();
enableMainQueueCoordinatorOnIOS_ = flagValue;
}
return flagValue.value();
}
bool ReactNativeFeatureFlagsAccessor::enableModuleArgumentNSNullConversionIOS() {
auto flagValue = enableModuleArgumentNSNullConversionIOS_.load();
@@ -686,7 +668,7 @@ bool ReactNativeFeatureFlagsAccessor::enableModuleArgumentNSNullConversionIOS()
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(36, "enableModuleArgumentNSNullConversionIOS");
markFlagAsAccessed(35, "enableModuleArgumentNSNullConversionIOS");
flagValue = currentProvider_->enableModuleArgumentNSNullConversionIOS();
enableModuleArgumentNSNullConversionIOS_ = flagValue;
@@ -704,7 +686,7 @@ bool ReactNativeFeatureFlagsAccessor::enableMutationObserverByDefault() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(37, "enableMutationObserverByDefault");
markFlagAsAccessed(36, "enableMutationObserverByDefault");
flagValue = currentProvider_->enableMutationObserverByDefault();
enableMutationObserverByDefault_ = flagValue;
@@ -722,7 +704,7 @@ bool ReactNativeFeatureFlagsAccessor::enableNativeCSSParsing() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(38, "enableNativeCSSParsing");
markFlagAsAccessed(37, "enableNativeCSSParsing");
flagValue = currentProvider_->enableNativeCSSParsing();
enableNativeCSSParsing_ = flagValue;
@@ -740,7 +722,7 @@ bool ReactNativeFeatureFlagsAccessor::enableNetworkEventReporting() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(39, "enableNetworkEventReporting");
markFlagAsAccessed(38, "enableNetworkEventReporting");
flagValue = currentProvider_->enableNetworkEventReporting();
enableNetworkEventReporting_ = flagValue;
@@ -758,7 +740,7 @@ bool ReactNativeFeatureFlagsAccessor::enablePreparedTextLayout() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(40, "enablePreparedTextLayout");
markFlagAsAccessed(39, "enablePreparedTextLayout");
flagValue = currentProvider_->enablePreparedTextLayout();
enablePreparedTextLayout_ = flagValue;
@@ -776,7 +758,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(41, "enablePropsUpdateReconciliationAndroid");
markFlagAsAccessed(40, "enablePropsUpdateReconciliationAndroid");
flagValue = currentProvider_->enablePropsUpdateReconciliationAndroid();
enablePropsUpdateReconciliationAndroid_ = flagValue;
@@ -794,7 +776,7 @@ bool ReactNativeFeatureFlagsAccessor::enableRuntimeSchedulerQueueClearingOnError
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(42, "enableRuntimeSchedulerQueueClearingOnError");
markFlagAsAccessed(41, "enableRuntimeSchedulerQueueClearingOnError");
flagValue = currentProvider_->enableRuntimeSchedulerQueueClearingOnError();
enableRuntimeSchedulerQueueClearingOnError_ = flagValue;
@@ -812,7 +794,7 @@ bool ReactNativeFeatureFlagsAccessor::enableSchedulerDelegateInvalidation() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(43, "enableSchedulerDelegateInvalidation");
markFlagAsAccessed(42, "enableSchedulerDelegateInvalidation");
flagValue = currentProvider_->enableSchedulerDelegateInvalidation();
enableSchedulerDelegateInvalidation_ = flagValue;
@@ -830,7 +812,7 @@ bool ReactNativeFeatureFlagsAccessor::enableSwiftUIBasedFilters() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(44, "enableSwiftUIBasedFilters");
markFlagAsAccessed(43, "enableSwiftUIBasedFilters");
flagValue = currentProvider_->enableSwiftUIBasedFilters();
enableSwiftUIBasedFilters_ = flagValue;
@@ -848,7 +830,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewCulling() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(45, "enableViewCulling");
markFlagAsAccessed(44, "enableViewCulling");
flagValue = currentProvider_->enableViewCulling();
enableViewCulling_ = flagValue;
@@ -866,7 +848,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(46, "enableViewRecycling");
markFlagAsAccessed(45, "enableViewRecycling");
flagValue = currentProvider_->enableViewRecycling();
enableViewRecycling_ = flagValue;
@@ -884,7 +866,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForImage() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(47, "enableViewRecyclingForImage");
markFlagAsAccessed(46, "enableViewRecyclingForImage");
flagValue = currentProvider_->enableViewRecyclingForImage();
enableViewRecyclingForImage_ = flagValue;
@@ -902,7 +884,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForScrollView() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(48, "enableViewRecyclingForScrollView");
markFlagAsAccessed(47, "enableViewRecyclingForScrollView");
flagValue = currentProvider_->enableViewRecyclingForScrollView();
enableViewRecyclingForScrollView_ = flagValue;
@@ -920,7 +902,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForText() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(49, "enableViewRecyclingForText");
markFlagAsAccessed(48, "enableViewRecyclingForText");
flagValue = currentProvider_->enableViewRecyclingForText();
enableViewRecyclingForText_ = flagValue;
@@ -938,7 +920,7 @@ bool ReactNativeFeatureFlagsAccessor::enableViewRecyclingForView() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(50, "enableViewRecyclingForView");
markFlagAsAccessed(49, "enableViewRecyclingForView");
flagValue = currentProvider_->enableViewRecyclingForView();
enableViewRecyclingForView_ = flagValue;
@@ -956,7 +938,7 @@ bool ReactNativeFeatureFlagsAccessor::enableVirtualViewContainerStateExperimenta
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(51, "enableVirtualViewContainerStateExperimental");
markFlagAsAccessed(50, "enableVirtualViewContainerStateExperimental");
flagValue = currentProvider_->enableVirtualViewContainerStateExperimental();
enableVirtualViewContainerStateExperimental_ = flagValue;
@@ -974,7 +956,7 @@ bool ReactNativeFeatureFlagsAccessor::fixDifferentiatorParentTagForUnflattenCase
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(52, "fixDifferentiatorParentTagForUnflattenCase");
markFlagAsAccessed(51, "fixDifferentiatorParentTagForUnflattenCase");
flagValue = currentProvider_->fixDifferentiatorParentTagForUnflattenCase();
fixDifferentiatorParentTagForUnflattenCase_ = flagValue;
@@ -992,7 +974,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(53, "fixMappingOfEventPrioritiesBetweenFabricAndReact");
markFlagAsAccessed(52, "fixMappingOfEventPrioritiesBetweenFabricAndReact");
flagValue = currentProvider_->fixMappingOfEventPrioritiesBetweenFabricAndReact();
fixMappingOfEventPrioritiesBetweenFabricAndReact_ = flagValue;
@@ -1010,7 +992,7 @@ bool ReactNativeFeatureFlagsAccessor::fixYogaFlexBasisFitContentInMainAxis() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(54, "fixYogaFlexBasisFitContentInMainAxis");
markFlagAsAccessed(53, "fixYogaFlexBasisFitContentInMainAxis");
flagValue = currentProvider_->fixYogaFlexBasisFitContentInMainAxis();
fixYogaFlexBasisFitContentInMainAxis_ = flagValue;
@@ -1028,7 +1010,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxAssertSingleHostState() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(55, "fuseboxAssertSingleHostState");
markFlagAsAccessed(54, "fuseboxAssertSingleHostState");
flagValue = currentProvider_->fuseboxAssertSingleHostState();
fuseboxAssertSingleHostState_ = flagValue;
@@ -1046,7 +1028,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(56, "fuseboxEnabledRelease");
markFlagAsAccessed(55, "fuseboxEnabledRelease");
flagValue = currentProvider_->fuseboxEnabledRelease();
fuseboxEnabledRelease_ = flagValue;
@@ -1064,7 +1046,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxFrameRecordingEnabled() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(57, "fuseboxFrameRecordingEnabled");
markFlagAsAccessed(56, "fuseboxFrameRecordingEnabled");
flagValue = currentProvider_->fuseboxFrameRecordingEnabled();
fuseboxFrameRecordingEnabled_ = flagValue;
@@ -1082,7 +1064,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxNetworkInspectionEnabled() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(58, "fuseboxNetworkInspectionEnabled");
markFlagAsAccessed(57, "fuseboxNetworkInspectionEnabled");
flagValue = currentProvider_->fuseboxNetworkInspectionEnabled();
fuseboxNetworkInspectionEnabled_ = flagValue;
@@ -1100,7 +1082,7 @@ bool ReactNativeFeatureFlagsAccessor::fuseboxScreenshotCaptureEnabled() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(59, "fuseboxScreenshotCaptureEnabled");
markFlagAsAccessed(58, "fuseboxScreenshotCaptureEnabled");
flagValue = currentProvider_->fuseboxScreenshotCaptureEnabled();
fuseboxScreenshotCaptureEnabled_ = flagValue;
@@ -1118,7 +1100,7 @@ bool ReactNativeFeatureFlagsAccessor::hideOffscreenVirtualViewsOnIOS() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(60, "hideOffscreenVirtualViewsOnIOS");
markFlagAsAccessed(59, "hideOffscreenVirtualViewsOnIOS");
flagValue = currentProvider_->hideOffscreenVirtualViewsOnIOS();
hideOffscreenVirtualViewsOnIOS_ = flagValue;
@@ -1136,7 +1118,7 @@ bool ReactNativeFeatureFlagsAccessor::optimizedAnimatedPropUpdates() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(61, "optimizedAnimatedPropUpdates");
markFlagAsAccessed(60, "optimizedAnimatedPropUpdates");
flagValue = currentProvider_->optimizedAnimatedPropUpdates();
optimizedAnimatedPropUpdates_ = flagValue;
@@ -1154,7 +1136,7 @@ bool ReactNativeFeatureFlagsAccessor::overrideBySynchronousMountPropsAtMountingA
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(62, "overrideBySynchronousMountPropsAtMountingAndroid");
markFlagAsAccessed(61, "overrideBySynchronousMountPropsAtMountingAndroid");
flagValue = currentProvider_->overrideBySynchronousMountPropsAtMountingAndroid();
overrideBySynchronousMountPropsAtMountingAndroid_ = flagValue;
@@ -1172,7 +1154,7 @@ bool ReactNativeFeatureFlagsAccessor::perfIssuesEnabled() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(63, "perfIssuesEnabled");
markFlagAsAccessed(62, "perfIssuesEnabled");
flagValue = currentProvider_->perfIssuesEnabled();
perfIssuesEnabled_ = flagValue;
@@ -1190,7 +1172,7 @@ bool ReactNativeFeatureFlagsAccessor::perfMonitorV2Enabled() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(64, "perfMonitorV2Enabled");
markFlagAsAccessed(63, "perfMonitorV2Enabled");
flagValue = currentProvider_->perfMonitorV2Enabled();
perfMonitorV2Enabled_ = flagValue;
@@ -1208,7 +1190,7 @@ double ReactNativeFeatureFlagsAccessor::preparedTextCacheSize() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(65, "preparedTextCacheSize");
markFlagAsAccessed(64, "preparedTextCacheSize");
flagValue = currentProvider_->preparedTextCacheSize();
preparedTextCacheSize_ = flagValue;
@@ -1226,7 +1208,7 @@ bool ReactNativeFeatureFlagsAccessor::preventShadowTreeCommitExhaustion() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(66, "preventShadowTreeCommitExhaustion");
markFlagAsAccessed(65, "preventShadowTreeCommitExhaustion");
flagValue = currentProvider_->preventShadowTreeCommitExhaustion();
preventShadowTreeCommitExhaustion_ = flagValue;
@@ -1244,7 +1226,7 @@ bool ReactNativeFeatureFlagsAccessor::redBoxV2Android() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(67, "redBoxV2Android");
markFlagAsAccessed(66, "redBoxV2Android");
flagValue = currentProvider_->redBoxV2Android();
redBoxV2Android_ = flagValue;
@@ -1262,7 +1244,7 @@ bool ReactNativeFeatureFlagsAccessor::redBoxV2IOS() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(68, "redBoxV2IOS");
markFlagAsAccessed(67, "redBoxV2IOS");
flagValue = currentProvider_->redBoxV2IOS();
redBoxV2IOS_ = flagValue;
@@ -1280,7 +1262,7 @@ bool ReactNativeFeatureFlagsAccessor::shouldPressibilityUseW3CPointerEventsForHo
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(69, "shouldPressibilityUseW3CPointerEventsForHover");
markFlagAsAccessed(68, "shouldPressibilityUseW3CPointerEventsForHover");
flagValue = currentProvider_->shouldPressibilityUseW3CPointerEventsForHover();
shouldPressibilityUseW3CPointerEventsForHover_ = flagValue;
@@ -1298,7 +1280,7 @@ bool ReactNativeFeatureFlagsAccessor::shouldTriggerResponderTransferOnScrollAndr
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(70, "shouldTriggerResponderTransferOnScrollAndroid");
markFlagAsAccessed(69, "shouldTriggerResponderTransferOnScrollAndroid");
flagValue = currentProvider_->shouldTriggerResponderTransferOnScrollAndroid();
shouldTriggerResponderTransferOnScrollAndroid_ = flagValue;
@@ -1316,7 +1298,7 @@ bool ReactNativeFeatureFlagsAccessor::skipActivityIdentityAssertionOnHostPause()
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(71, "skipActivityIdentityAssertionOnHostPause");
markFlagAsAccessed(70, "skipActivityIdentityAssertionOnHostPause");
flagValue = currentProvider_->skipActivityIdentityAssertionOnHostPause();
skipActivityIdentityAssertionOnHostPause_ = flagValue;
@@ -1334,7 +1316,7 @@ bool ReactNativeFeatureFlagsAccessor::syncAndroidClipBoundsWithOverflow() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(72, "syncAndroidClipBoundsWithOverflow");
markFlagAsAccessed(71, "syncAndroidClipBoundsWithOverflow");
flagValue = currentProvider_->syncAndroidClipBoundsWithOverflow();
syncAndroidClipBoundsWithOverflow_ = flagValue;
@@ -1352,7 +1334,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(73, "traceTurboModulePromiseRejectionsOnAndroid");
markFlagAsAccessed(72, "traceTurboModulePromiseRejectionsOnAndroid");
flagValue = currentProvider_->traceTurboModulePromiseRejectionsOnAndroid();
traceTurboModulePromiseRejectionsOnAndroid_ = flagValue;
@@ -1370,7 +1352,7 @@ bool ReactNativeFeatureFlagsAccessor::updateRuntimeShadowNodeReferencesOnCommit(
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(74, "updateRuntimeShadowNodeReferencesOnCommit");
markFlagAsAccessed(73, "updateRuntimeShadowNodeReferencesOnCommit");
flagValue = currentProvider_->updateRuntimeShadowNodeReferencesOnCommit();
updateRuntimeShadowNodeReferencesOnCommit_ = flagValue;
@@ -1388,7 +1370,7 @@ bool ReactNativeFeatureFlagsAccessor::updateRuntimeShadowNodeReferencesOnCommitT
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(75, "updateRuntimeShadowNodeReferencesOnCommitThread");
markFlagAsAccessed(74, "updateRuntimeShadowNodeReferencesOnCommitThread");
flagValue = currentProvider_->updateRuntimeShadowNodeReferencesOnCommitThread();
updateRuntimeShadowNodeReferencesOnCommitThread_ = flagValue;
@@ -1406,7 +1388,7 @@ bool ReactNativeFeatureFlagsAccessor::useAlwaysAvailableJSErrorHandling() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(76, "useAlwaysAvailableJSErrorHandling");
markFlagAsAccessed(75, "useAlwaysAvailableJSErrorHandling");
flagValue = currentProvider_->useAlwaysAvailableJSErrorHandling();
useAlwaysAvailableJSErrorHandling_ = flagValue;
@@ -1424,7 +1406,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(77, "useFabricInterop");
markFlagAsAccessed(76, "useFabricInterop");
flagValue = currentProvider_->useFabricInterop();
useFabricInterop_ = flagValue;
@@ -1442,7 +1424,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(78, "useNativeViewConfigsInBridgelessMode");
markFlagAsAccessed(77, "useNativeViewConfigsInBridgelessMode");
flagValue = currentProvider_->useNativeViewConfigsInBridgelessMode();
useNativeViewConfigsInBridgelessMode_ = flagValue;
@@ -1460,7 +1442,7 @@ bool ReactNativeFeatureFlagsAccessor::useNestedScrollViewAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(79, "useNestedScrollViewAndroid");
markFlagAsAccessed(78, "useNestedScrollViewAndroid");
flagValue = currentProvider_->useNestedScrollViewAndroid();
useNestedScrollViewAndroid_ = flagValue;
@@ -1478,7 +1460,7 @@ bool ReactNativeFeatureFlagsAccessor::useOptimizedViewRegistryOnAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(80, "useOptimizedViewRegistryOnAndroid");
markFlagAsAccessed(79, "useOptimizedViewRegistryOnAndroid");
flagValue = currentProvider_->useOptimizedViewRegistryOnAndroid();
useOptimizedViewRegistryOnAndroid_ = flagValue;
@@ -1496,7 +1478,7 @@ bool ReactNativeFeatureFlagsAccessor::useSharedAnimatedBackend() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(81, "useSharedAnimatedBackend");
markFlagAsAccessed(80, "useSharedAnimatedBackend");
flagValue = currentProvider_->useSharedAnimatedBackend();
useSharedAnimatedBackend_ = flagValue;
@@ -1514,7 +1496,7 @@ bool ReactNativeFeatureFlagsAccessor::useTraitHiddenOnAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(82, "useTraitHiddenOnAndroid");
markFlagAsAccessed(81, "useTraitHiddenOnAndroid");
flagValue = currentProvider_->useTraitHiddenOnAndroid();
useTraitHiddenOnAndroid_ = flagValue;
@@ -1532,7 +1514,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(83, "useTurboModuleInterop");
markFlagAsAccessed(82, "useTurboModuleInterop");
flagValue = currentProvider_->useTurboModuleInterop();
useTurboModuleInterop_ = flagValue;
@@ -1550,7 +1532,7 @@ double ReactNativeFeatureFlagsAccessor::viewCullingOutsetRatio() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(84, "viewCullingOutsetRatio");
markFlagAsAccessed(83, "viewCullingOutsetRatio");
flagValue = currentProvider_->viewCullingOutsetRatio();
viewCullingOutsetRatio_ = flagValue;
@@ -1568,7 +1550,7 @@ bool ReactNativeFeatureFlagsAccessor::viewTransitionEnabled() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(85, "viewTransitionEnabled");
markFlagAsAccessed(84, "viewTransitionEnabled");
flagValue = currentProvider_->viewTransitionEnabled();
viewTransitionEnabled_ = flagValue;
@@ -1586,7 +1568,7 @@ bool ReactNativeFeatureFlagsAccessor::viewTransitionUseHardwareBitmapAndroid() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(86, "viewTransitionUseHardwareBitmapAndroid");
markFlagAsAccessed(85, "viewTransitionUseHardwareBitmapAndroid");
flagValue = currentProvider_->viewTransitionUseHardwareBitmapAndroid();
viewTransitionUseHardwareBitmapAndroid_ = flagValue;
@@ -1604,7 +1586,7 @@ double ReactNativeFeatureFlagsAccessor::virtualViewPrerenderRatio() {
// be accessing the provider multiple times but the end state of this
// instance and the returned flag value would be the same.
markFlagAsAccessed(87, "virtualViewPrerenderRatio");
markFlagAsAccessed(86, "virtualViewPrerenderRatio");
flagValue = currentProvider_->virtualViewPrerenderRatio();
virtualViewPrerenderRatio_ = flagValue;
@@ -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<<4b9621fa4f180c100cece906c0d4db34>>
* @generated SignedSource<<6126d94aaf219c0d4a3ffe84c05b0fb2>>
*/
/**
@@ -67,7 +67,6 @@ class ReactNativeFeatureFlagsAccessor {
bool enableKeyEvents();
bool enableLayoutAnimationsOnAndroid();
bool enableLayoutAnimationsOnIOS();
bool enableMainQueueCoordinatorOnIOS();
bool enableModuleArgumentNSNullConversionIOS();
bool enableMutationObserverByDefault();
bool enableNativeCSSParsing();
@@ -131,7 +130,7 @@ class ReactNativeFeatureFlagsAccessor {
std::unique_ptr<ReactNativeFeatureFlagsProvider> currentProvider_;
bool wasOverridden_;
std::array<std::atomic<const char*>, 88> accessedFeatureFlags_;
std::array<std::atomic<const char*>, 87> accessedFeatureFlags_;
std::atomic<std::optional<bool>> commonTestFlag_;
std::atomic<std::optional<bool>> cdpInteractionMetricsEnabled_;
@@ -168,7 +167,6 @@ class ReactNativeFeatureFlagsAccessor {
std::atomic<std::optional<bool>> enableKeyEvents_;
std::atomic<std::optional<bool>> enableLayoutAnimationsOnAndroid_;
std::atomic<std::optional<bool>> enableLayoutAnimationsOnIOS_;
std::atomic<std::optional<bool>> enableMainQueueCoordinatorOnIOS_;
std::atomic<std::optional<bool>> enableModuleArgumentNSNullConversionIOS_;
std::atomic<std::optional<bool>> enableMutationObserverByDefault_;
std::atomic<std::optional<bool>> enableNativeCSSParsing_;
@@ -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<<e7e8b2bcaffdb7504a92afd0e61f07c4>>
* @generated SignedSource<<f6ec4d10a7330c120b77504ead7bf865>>
*/
/**
@@ -167,10 +167,6 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
return true;
}
bool enableMainQueueCoordinatorOnIOS() override {
return false;
}
bool enableModuleArgumentNSNullConversionIOS() override {
return 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<<50d5c4ac14b1abc6065af8dc82945f93>>
* @generated SignedSource<<b653dee4b92adb7177a7cd354b5e3573>>
*/
/**
@@ -360,15 +360,6 @@ class ReactNativeFeatureFlagsDynamicProvider : public ReactNativeFeatureFlagsDef
return ReactNativeFeatureFlagsDefaults::enableLayoutAnimationsOnIOS();
}
bool enableMainQueueCoordinatorOnIOS() override {
auto value = values_["enableMainQueueCoordinatorOnIOS"];
if (!value.isNull()) {
return value.getBool();
}
return ReactNativeFeatureFlagsDefaults::enableMainQueueCoordinatorOnIOS();
}
bool enableModuleArgumentNSNullConversionIOS() override {
auto value = values_["enableModuleArgumentNSNullConversionIOS"];
if (!value.isNull()) {
@@ -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<<5ba9185aeb77b3bb3bfd258fb20b7e13>>
* @generated SignedSource<<8a9430ba71722a75779e2b5fb6564f0e>>
*/
/**
@@ -60,7 +60,6 @@ class ReactNativeFeatureFlagsProvider {
virtual bool enableKeyEvents() = 0;
virtual bool enableLayoutAnimationsOnAndroid() = 0;
virtual bool enableLayoutAnimationsOnIOS() = 0;
virtual bool enableMainQueueCoordinatorOnIOS() = 0;
virtual bool enableModuleArgumentNSNullConversionIOS() = 0;
virtual bool enableMutationObserverByDefault() = 0;
virtual bool enableNativeCSSParsing() = 0;
@@ -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<<8621fa2c2c8a2d88b54a3c3767510de3>>
* @generated SignedSource<<cc30c8296ef786dcaecb0895ccabda7c>>
*/
/**
@@ -219,11 +219,6 @@ bool NativeReactNativeFeatureFlags::enableLayoutAnimationsOnIOS(
return ReactNativeFeatureFlags::enableLayoutAnimationsOnIOS();
}
bool NativeReactNativeFeatureFlags::enableMainQueueCoordinatorOnIOS(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::enableMainQueueCoordinatorOnIOS();
}
bool NativeReactNativeFeatureFlags::enableModuleArgumentNSNullConversionIOS(
jsi::Runtime& /*runtime*/) {
return ReactNativeFeatureFlags::enableModuleArgumentNSNullConversionIOS();
@@ -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<<734b2f736b310fdc9ca51eda8509a6fb>>
* @generated SignedSource<<9a21979a5eeb2f9daf8c061610199596>>
*/
/**
@@ -106,8 +106,6 @@ class NativeReactNativeFeatureFlags
bool enableLayoutAnimationsOnIOS(jsi::Runtime& runtime);
bool enableMainQueueCoordinatorOnIOS(jsi::Runtime& runtime);
bool enableModuleArgumentNSNullConversionIOS(jsi::Runtime& runtime);
bool enableMutationObserverByDefault(jsi::Runtime& runtime);
@@ -957,17 +957,6 @@ TEST_P(RuntimeSchedulerTest, basicSameThreadExecution) {
// in `executeSynchronouslyOnSameThread_CAN_DEADLOCK`. The off-main `driver`
// thread drives the stub queue ("JS thread") so the main thread can wake up.
TEST_P(RuntimeSchedulerTest, basicUIThreadExecution) {
class CoordinatorFeatureFlags : public RuntimeSchedulerTestFeatureFlags {
public:
using RuntimeSchedulerTestFeatureFlags::RuntimeSchedulerTestFeatureFlags;
bool enableMainQueueCoordinatorOnIOS() override {
return true;
}
};
ReactNativeFeatureFlags::dangerouslyReset();
ReactNativeFeatureFlags::override(
std::make_unique<CoordinatorFeatureFlags>(GetParam()));
bool didRunSynchronousTask = false;
std::thread driver([this]() {
@@ -11,48 +11,17 @@
#import <ReactCommon/RuntimeExecutor.h>
#import <ReactCommon/RuntimeExecutorSyncUIThreadUtils.h>
#import <hermes/hermes.h>
#import <react/featureflags/ReactNativeFeatureFlags.h>
#import <react/featureflags/ReactNativeFeatureFlagsDefaults.h>
#import <atomic>
#import <chrono>
#import <thread>
using namespace facebook::react;
namespace {
class MainQueueCoordinatorOverride : public ReactNativeFeatureFlagsDefaults {
public:
explicit MainQueueCoordinatorOverride(bool enabled) : enabled_(enabled) {}
bool enableMainQueueCoordinatorOnIOS() override
{
return enabled_;
}
private:
bool enabled_;
};
} // namespace
@interface MainQueueCoordinatorTests : XCTestCase
@end
@implementation MainQueueCoordinatorTests
- (void)setUp
{
[super setUp];
ReactNativeFeatureFlags::dangerouslyReset();
}
- (void)tearDown
{
ReactNativeFeatureFlags::dangerouslyReset();
[super tearDown];
}
#pragma mark - RCTUnsafeExecuteOnMainQueueSync
- (void)_assertRCTUnsafeExecuteOnMainQueueSyncRunsBlockOnMainFromBackgroundThread
- (void)testRCTUnsafeExecuteOnMainQueueSync_runsBlockOnMainFromBG
{
XCTestExpectation *done = [self expectationWithDescription:@"BG-thread call completed"];
__block BOOL ranOnMain = NO;
@@ -71,25 +40,8 @@ class MainQueueCoordinatorOverride : public ReactNativeFeatureFlagsDefaults {
XCTAssertTrue(returnedToBG, @"BG thread must resume after sync call returns");
}
- (void)testRCTUnsafeExecuteOnMainQueueSync_flagOff_runsBlockOnMainFromBG
- (void)testExecuteSynchronouslyOnSameThread_pumpsUITasksWhileWaitingForJS
{
// Default off — exercises the dispatch_sync(main) branch.
[self _assertRCTUnsafeExecuteOnMainQueueSyncRunsBlockOnMainFromBackgroundThread];
}
- (void)testRCTUnsafeExecuteOnMainQueueSync_flagOn_runsBlockOnMainFromBG
{
ReactNativeFeatureFlags::override(std::make_unique<MainQueueCoordinatorOverride>(true));
// Coordinator branch — `unsafeExecuteOnMainThreadSync` posts a UI task and waits.
[self _assertRCTUnsafeExecuteOnMainQueueSyncRunsBlockOnMainFromBackgroundThread];
}
#pragma mark - executeSynchronouslyOnSameThread_CAN_DEADLOCK
- (void)testExecuteSynchronouslyOnSameThread_flagOn_pumpsUITasksWhileWaitingForJS
{
ReactNativeFeatureFlags::override(std::make_unique<MainQueueCoordinatorOverride>(true));
// A real runtime — needed only for the reference type. We never call into it.
auto runtime = facebook::hermes::makeHermesRuntime();
@@ -104,9 +56,9 @@ class MainQueueCoordinatorOverride : public ReactNativeFeatureFlagsDefaults {
}).detach();
};
// Both threads only ever write on main, so plain ints are race-free. Held in
// a struct so we can capture a pointer from an ObjC block and a reference
// from a C++ lambda without `__block` (which doesn't compose with lambdas).
// Both writes happen on main, so plain ints are race-free. Held in a struct
// so we can capture a pointer from an ObjC block and a reference from a C++
// lambda without `__block` (which doesn't compose with lambdas).
struct State {
int sequence = 0;
int uiTaskOrder = 0;
@@ -9,9 +9,7 @@
#import <ReactCommon/RuntimeExecutorSyncUIThreadUtils.h>
#import <react/debug/react_native_assert.h>
#import <react/featureflags/ReactNativeFeatureFlags.h>
#import <react/utils/OnScopeExit.h>
#import <algorithm>
#import <functional>
#import <future>
#import <mutex>
@@ -111,8 +109,8 @@ void runUITask(UITask &uiTask)
}
/**
* This method is resilient to multiple javascript threads.
* This can happen when multiple react instances interleave.
* Coordinator-style implementation that is resilient to multiple javascript
* threads. This can happen when multiple react instances interleave.
*
* The extension from 1 js thread to n: All js threads race to
* get a ticket to post a ui task. The first one to get the ticket
@@ -122,10 +120,13 @@ void runUITask(UITask &uiTask)
*
* For simplicity, we will just use this algorithm for all bg threads.
* Not just the js thread.
*
* Requires the caller to be on the main thread, because the wait loop pumps
* UI tasks that are dispatched to the main queue.
*/
void saferExecuteSynchronouslyOnSameThread_CAN_DEADLOCK(
void coordinatedExecuteSynchronouslyOnSameThread_CAN_DEADLOCK(
const RuntimeExecutor &runtimeExecutor,
std::function<void(jsi::Runtime &runtime)> &&runtimeWork)
std::function<void(jsi::Runtime &)> &&runtimeWork)
{
react_native_assert([[NSThread currentThread] isMainThread] && !g_isRunningUITask);
@@ -159,52 +160,34 @@ void saferExecuteSynchronouslyOnSameThread_CAN_DEADLOCK(
runtimeWork(*runtime);
}
/*
/**
* Schedules `runtimeWork` to be executed on the same thread using the
* `RuntimeExecutor`, and blocks on its completion.
*
* Example:
* - [UI thread] Schedule `runtimeCaptureBlock` on js thread
* - [UI thread] Wait for runtime capture: await(runtime)
* - [JS thread] Capture runtime for ui thread: resolve(runtime, &rt);
* - [JS thread] Wait until runtimeWork done: await(runtimeWorkDone)
* - [UI thread] Call runtimeWork: runtimeWork(*runtimePrt);
* - [UI thread] Signal runtimeWork done: resolve(runtimeWorkDone)
* - [UI thread] Wait until runtime capture block finished:
* await(runtimeCaptureBlockDone);
* - [JS thread] Signal runtime capture block is finished:
* resolve(runtimeCaptureBlockDone);
* `RuntimeExecutor`, and blocks on its completion. Used when the caller is
* not on the main thread (the coordinator implementation requires main).
*/
void legacyExecuteSynchronouslyOnSameThread_CAN_DEADLOCK(
void simpleExecuteSynchronouslyOnSameThread_CAN_DEADLOCK(
const RuntimeExecutor &runtimeExecutor,
std::function<void(jsi::Runtime &)> &&runtimeWork)
{
std::promise<jsi::Runtime *> runtime;
std::promise<void> runtimeCaptureBlockDone;
std::promise<void> runtimeWorkDone;
auto callingThread = std::this_thread::get_id();
auto runtimeCaptureBlock = [&](jsi::Runtime &rt) {
runtimeExecutor([&](jsi::Runtime &rt) {
runtime.set_value(&rt);
auto runtimeThread = std::this_thread::get_id();
if (callingThread != runtimeThread) {
// Block `runtimeThread` on execution of `runtimeWork` on `callingThread`.
if (callingThread != std::this_thread::get_id()) {
// Block the runtime thread on execution of `runtimeWork` on the calling thread.
runtimeWorkDone.get_future().wait();
}
// TODO(T225331233): This is likely unnecessary. Remove it.
runtimeCaptureBlockDone.set_value();
};
runtimeExecutor(std::move(runtimeCaptureBlock));
});
jsi::Runtime *runtimePtr = runtime.get_future().get();
runtimeWork(*runtimePtr);
runtimeWorkDone.set_value();
// TODO(T225331233): This is likely unnecessary. Remove it.
runtimeCaptureBlockDone.get_future().wait();
OnScopeExit onScopeExit([&]() { runtimeWorkDone.set_value(); });
// Calls into runtime scheduler, which takes care of error handling
runtimeWork(*runtimePtr);
}
} // namespace
@@ -213,10 +196,10 @@ void executeSynchronouslyOnSameThread_CAN_DEADLOCK(
const RuntimeExecutor &runtimeExecutor,
std::function<void(jsi::Runtime &)> &&runtimeWork)
{
if (ReactNativeFeatureFlags::enableMainQueueCoordinatorOnIOS()) {
saferExecuteSynchronouslyOnSameThread_CAN_DEADLOCK(runtimeExecutor, std::move(runtimeWork));
if ([[NSThread currentThread] isMainThread] && !g_isRunningUITask) {
coordinatedExecuteSynchronouslyOnSameThread_CAN_DEADLOCK(runtimeExecutor, std::move(runtimeWork));
} else {
legacyExecuteSynchronouslyOnSameThread_CAN_DEADLOCK(runtimeExecutor, std::move(runtimeWork));
simpleExecuteSynchronouslyOnSameThread_CAN_DEADLOCK(runtimeExecutor, std::move(runtimeWork));
}
}
@@ -422,17 +422,6 @@ const definitions: FeatureFlagDefinitions = {
},
ossReleaseStage: 'none',
},
enableMainQueueCoordinatorOnIOS: {
defaultValue: false,
metadata: {
dateAdded: '2025-05-17',
description:
'Make RCTUnsafeExecuteOnMainQueueSync less likely to deadlock, when used in conjuction with sync rendering/events.',
expectedReleaseValue: true,
purpose: 'experimentation',
},
ossReleaseStage: 'none',
},
enableModuleArgumentNSNullConversionIOS: {
defaultValue: false,
metadata: {
@@ -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<<943b7be8ca8b83a74af1da421ee15759>>
* @generated SignedSource<<7f48f734cd7a098d04cb147980ef364a>>
* @flow strict
* @noformat
*/
@@ -81,7 +81,6 @@ export type ReactNativeFeatureFlags = $ReadOnly<{
enableKeyEvents: Getter<boolean>,
enableLayoutAnimationsOnAndroid: Getter<boolean>,
enableLayoutAnimationsOnIOS: Getter<boolean>,
enableMainQueueCoordinatorOnIOS: Getter<boolean>,
enableModuleArgumentNSNullConversionIOS: Getter<boolean>,
enableMutationObserverByDefault: Getter<boolean>,
enableNativeCSSParsing: Getter<boolean>,
@@ -335,10 +334,6 @@ export const enableLayoutAnimationsOnAndroid: Getter<boolean> = createNativeFlag
* When enabled, LayoutAnimations API will animate state changes on iOS.
*/
export const enableLayoutAnimationsOnIOS: Getter<boolean> = createNativeFlagGetter('enableLayoutAnimationsOnIOS', true);
/**
* Make RCTUnsafeExecuteOnMainQueueSync less likely to deadlock, when used in conjuction with sync rendering/events.
*/
export const enableMainQueueCoordinatorOnIOS: Getter<boolean> = createNativeFlagGetter('enableMainQueueCoordinatorOnIOS', false);
/**
* Enable NSNull conversion when handling module arguments on iOS
*/
@@ -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<<5a13b31ebbcc04ed6e2aa6e60dc4c1f4>>
* @generated SignedSource<<869507719729d76403ed47be393cc120>>
* @flow strict
* @noformat
*/
@@ -60,7 +60,6 @@ export interface Spec extends TurboModule {
+enableKeyEvents?: () => boolean;
+enableLayoutAnimationsOnAndroid?: () => boolean;
+enableLayoutAnimationsOnIOS?: () => boolean;
+enableMainQueueCoordinatorOnIOS?: () => boolean;
+enableModuleArgumentNSNullConversionIOS?: () => boolean;
+enableMutationObserverByDefault?: () => boolean;
+enableNativeCSSParsing?: () => boolean;