From 682887587ba354e7c9ee3e9afbf27c05f33dfd31 Mon Sep 17 00:00:00 2001 From: Phillip Pan Date: Mon, 31 Jul 2023 06:06:06 -0700 Subject: [PATCH] cleanup turbomodule eager init (#38540) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38540 Changelog: [Internal] this is never set to yes, clean it up we need to decide if this is actually part of our feature set Reviewed By: cipolleschi Differential Revision: D47620233 fbshipit-source-id: 6f530015da0645d721bef7ff7c5d512113273b1a --- .../Libraries/AppDelegate/RCTAppSetupUtils.mm | 16 +++++++------- .../React/Base/RCTBridge+Private.h | 3 --- packages/react-native/React/Base/RCTBridge.h | 10 --------- packages/react-native/React/Base/RCTBridge.mm | 11 ---------- .../React/CxxBridge/RCTCxxBridge.mm | 21 ------------------- .../ios/ReactCommon/RCTTurboModuleManager.mm | 11 ---------- 6 files changed, 7 insertions(+), 65 deletions(-) diff --git a/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm b/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm index a416e90b907..f5c51079420 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm +++ b/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm @@ -111,15 +111,13 @@ std::unique_ptr RCTAppSetupDefaultJsExecutor [bridge setRCTTurboModuleRegistry:turboModuleManager]; #if RCT_DEV - if (!RCTTurboModuleEagerInitEnabled()) { - /** - * Instantiating DevMenu has the side-effect of registering - * shortcuts for CMD + d, CMD + i, and CMD + n via RCTDevMenu. - * Therefore, when TurboModules are enabled, we must manually create this - * NativeModule. - */ - [turboModuleManager moduleForName:"RCTDevMenu"]; - } + /** + * Instantiating DevMenu has the side-effect of registering + * shortcuts for CMD + d, CMD + i, and CMD + n via RCTDevMenu. + * Therefore, when TurboModules are enabled, we must manually create this + * NativeModule. + */ + [turboModuleManager moduleForName:"RCTDevMenu"]; #endif #if RCT_USE_HERMES diff --git a/packages/react-native/React/Base/RCTBridge+Private.h b/packages/react-native/React/Base/RCTBridge+Private.h index 4664278d812..fc4639dec0a 100644 --- a/packages/react-native/React/Base/RCTBridge+Private.h +++ b/packages/react-native/React/Base/RCTBridge+Private.h @@ -70,9 +70,6 @@ RCT_EXTERN void RCTRegisterModule(Class); */ @property (nonatomic, strong, readonly) RCTModuleRegistry *moduleRegistry; -@property (nonatomic, copy, readwrite) NSArray *eagerInitModuleNames_DO_NOT_USE; -@property (nonatomic, copy, readwrite) NSArray *eagerInitMainQueueModuleNames_DO_NOT_USE; - @end @interface RCTBridge (RCTCxxBridge) diff --git a/packages/react-native/React/Base/RCTBridge.h b/packages/react-native/React/Base/RCTBridge.h index fc0991763f1..37dc4be6218 100644 --- a/packages/react-native/React/Base/RCTBridge.h +++ b/packages/react-native/React/Base/RCTBridge.h @@ -31,12 +31,6 @@ */ typedef NSArray> * (^RCTBridgeModuleListProvider)(void); -/** - * These blocks are used to report whether an additional bundle - * fails or succeeds loading. - */ -typedef void (^RCTLoadAndExecuteErrorBlock)(NSError *error); - /** * This function returns the module name for a given class. */ @@ -49,10 +43,6 @@ RCT_EXTERN NSString *RCTBridgeModuleNameForClass(Class bridgeModuleClass); RCT_EXTERN BOOL RCTTurboModuleEnabled(void); RCT_EXTERN void RCTEnableTurboModule(BOOL enabled); -// Turn on TurboModule eager initialization -RCT_EXTERN BOOL RCTTurboModuleEagerInitEnabled(void); -RCT_EXTERN void RCTEnableTurboModuleEagerInit(BOOL enabled); - // Turn on TurboModule interop RCT_EXTERN BOOL RCTTurboModuleInteropEnabled(void); RCT_EXTERN void RCTEnableTurboModuleInterop(BOOL enabled); diff --git a/packages/react-native/React/Base/RCTBridge.mm b/packages/react-native/React/Base/RCTBridge.mm index 564cca6942a..b7d3e85ba11 100644 --- a/packages/react-native/React/Base/RCTBridge.mm +++ b/packages/react-native/React/Base/RCTBridge.mm @@ -97,17 +97,6 @@ void RCTEnableTurboModule(BOOL enabled) turboModuleEnabled = enabled; } -static BOOL turboModuleEagerInitEnabled = NO; -BOOL RCTTurboModuleEagerInitEnabled(void) -{ - return turboModuleEagerInitEnabled; -} - -void RCTEnableTurboModuleEagerInit(BOOL enabled) -{ - turboModuleEagerInitEnabled = enabled; -} - static BOOL turboModuleInteropEnabled = NO; BOOL RCTTurboModuleInteropEnabled(void) { diff --git a/packages/react-native/React/CxxBridge/RCTCxxBridge.mm b/packages/react-native/React/CxxBridge/RCTCxxBridge.mm index fc77456265d..48644afca6c 100644 --- a/packages/react-native/React/CxxBridge/RCTCxxBridge.mm +++ b/packages/react-native/React/CxxBridge/RCTCxxBridge.mm @@ -432,27 +432,6 @@ struct RCTInstanceCallback : public InstanceCallback { })); } - /** - * id jsExecutorFactory may create and assign an id object to - * RCTCxxBridge If id is assigned by this time, eagerly initialize all TurboModules - */ - if (_turboModuleRegistry && RCTTurboModuleEagerInitEnabled()) { - for (NSString *moduleName in [_parentBridge eagerInitModuleNames_DO_NOT_USE]) { - [_turboModuleRegistry moduleForName:[moduleName UTF8String]]; - } - - for (NSString *moduleName in [_parentBridge eagerInitMainQueueModuleNames_DO_NOT_USE]) { - if (RCTIsMainQueue()) { - [_turboModuleRegistry moduleForName:[moduleName UTF8String]]; - } else { - id turboModuleRegistry = _turboModuleRegistry; - dispatch_group_async(prepareBridge, dispatch_get_main_queue(), ^{ - [turboModuleRegistry moduleForName:[moduleName UTF8String]]; - }); - } - } - } - // Dispatch the instance initialization as soon as the initial module metadata has // been collected (see initModules) dispatch_group_enter(prepareBridge); 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 021e445c0c8..2de7da87ff8 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 @@ -558,17 +558,6 @@ static Class getFallbackClassFromName(const char *name) }; if ([self _requiresMainQueueSetup:moduleClass]) { - /** - * When TurboModule eager initialization is enabled, there shouldn't be any TurboModule initializations on the - * main queue. - * TODO(T69449176) Roll out TurboModule eager initialization, and remove this check. - */ - if (RCTTurboModuleEagerInitEnabled() && !RCTIsMainQueue()) { - RCTLogWarn( - @"TurboModule \"%@\" requires synchronous dispatch onto the main queue to be initialized. This may lead to deadlock.", - moduleClass); - } - RCTUnsafeExecuteOnMainQueueSync(work); } else { work();