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 b427ca018030ce..3edb86d24deea5 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 @@ -206,6 +206,9 @@ @implementation RCTTurboModuleManager { RCTBridgeProxy *_bridgeProxy; RCTBridgeModuleDecorator *_bridgeModuleDecorator; + + BOOL _enableSharedModuleQueue; + dispatch_queue_t _sharedModuleQueue; } - (instancetype)initWithBridge:(RCTBridge *)bridge @@ -221,6 +224,7 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge _bridgeProxy = bridgeProxy; _bridgeModuleDecorator = bridgeModuleDecorator; _invalidating = false; + _enableSharedModuleQueue = NO; if (RCTTurboModuleInteropEnabled()) { NSMutableDictionary> *legacyInitializedModules = [NSMutableDictionary new]; @@ -685,8 +689,12 @@ - (BOOL)_shouldCreateObjCModule:(Class)moduleClass * following if condition's block. */ if (!methodQueue) { - NSString *methodQueueName = [NSString stringWithFormat:@"com.facebook.react.%sQueue", moduleName]; - methodQueue = dispatch_queue_create(methodQueueName.UTF8String, DISPATCH_QUEUE_SERIAL); + if (_enableSharedModuleQueue) { + methodQueue = [self _sharedModuleQueue]; + } else { + NSString *methodQueueName = [NSString stringWithFormat:@"com.facebook.react.%sQueue", moduleName]; + methodQueue = dispatch_queue_create(methodQueueName.UTF8String, DISPATCH_QUEUE_SERIAL); + } if (moduleHasMethodQueueGetter) { /** @@ -1067,4 +1075,12 @@ - (void)_invalidateModules _legacyModuleCache.clear(); } +- (dispatch_queue_t)_sharedModuleQueue +{ + if (!_sharedModuleQueue) { + _sharedModuleQueue = dispatch_queue_create("com.meta.react.turbomodulemanager.queue", DISPATCH_QUEUE_SERIAL); + } + return _sharedModuleQueue; +} + @end