From 06eff36e5b6492b7de84b39f0dd400ce969251d7 Mon Sep 17 00:00:00 2001 From: Phillip Pan Date: Fri, 20 Oct 2023 13:47:34 -0700 Subject: [PATCH] hook up gating to shared native module queue (#41043) Summary: Changelog: [Internal] in this change, we create an config pipeline to set `_enableSharedModuleQueue` in TMM Reviewed By: cipolleschi Differential Revision: D50398636 --- packages/react-native/React/Base/RCTBridge.h | 4 ++++ packages/react-native/React/Base/RCTBridge.mm | 12 ++++++++++++ .../ios/ReactCommon/RCTTurboModuleManager.mm | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/react-native/React/Base/RCTBridge.h b/packages/react-native/React/Base/RCTBridge.h index 68651edb771a6b..846e17fdb1104e 100644 --- a/packages/react-native/React/Base/RCTBridge.h +++ b/packages/react-native/React/Base/RCTBridge.h @@ -57,6 +57,10 @@ void RCTEnableTurboModuleInteropBridgeProxy(BOOL enabled); BOOL RCTTurboModuleSyncVoidMethodsEnabled(void); void RCTEnableTurboModuleSyncVoidMethods(BOOL enabled); +// Use a shared queue for executing module methods +BOOL RCTTurboModuleSharedQueueEnabled(void); +void RCTEnableTurboModuleSharedQueue(BOOL enabled); + typedef enum { kRCTBridgeProxyLoggingLevelNone, kRCTBridgeProxyLoggingLevelWarning, diff --git a/packages/react-native/React/Base/RCTBridge.mm b/packages/react-native/React/Base/RCTBridge.mm index d0598e621e22f2..a18b43861cbabd 100644 --- a/packages/react-native/React/Base/RCTBridge.mm +++ b/packages/react-native/React/Base/RCTBridge.mm @@ -150,6 +150,18 @@ void RCTEnableTurboModuleSyncVoidMethods(BOOL enabled) gTurboModuleEnableSyncVoidMethods = enabled; } +// Use a shared queue for executing module methods +static BOOL gTurboModuleEnableSharedQueue = NO; +BOOL RCTTurboModuleSharedQueueEnabled(void) +{ + return gTurboModuleEnableSharedQueue; +} + +void RCTEnableTurboModuleSharedQueue(BOOL enabled) +{ + gTurboModuleEnableSharedQueue = enabled; +} + @interface RCTBridge () @end diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm index 5feb7b578dce74..ad8fadd04b1ef4 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm +++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm @@ -224,7 +224,7 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge _bridgeProxy = bridgeProxy; _bridgeModuleDecorator = bridgeModuleDecorator; _invalidating = false; - _enableSharedModuleQueue = NO; + _enableSharedModuleQueue = RCTTurboModuleSharedQueueEnabled(); if (_enableSharedModuleQueue) { _sharedModuleQueue = dispatch_queue_create("com.meta.react.turbomodulemanager.queue", DISPATCH_QUEUE_SERIAL);