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
This commit is contained in:
Phillip Pan
2023-07-31 06:06:06 -07:00
committed by Facebook GitHub Bot
parent de7c0655f0
commit 682887587b
6 changed files with 7 additions and 65 deletions
@@ -111,15 +111,13 @@ std::unique_ptr<facebook::react::JSExecutorFactory> 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
@@ -70,9 +70,6 @@ RCT_EXTERN void RCTRegisterModule(Class);
*/
@property (nonatomic, strong, readonly) RCTModuleRegistry *moduleRegistry;
@property (nonatomic, copy, readwrite) NSArray<NSString *> *eagerInitModuleNames_DO_NOT_USE;
@property (nonatomic, copy, readwrite) NSArray<NSString *> *eagerInitMainQueueModuleNames_DO_NOT_USE;
@end
@interface RCTBridge (RCTCxxBridge)
@@ -31,12 +31,6 @@
*/
typedef NSArray<id<RCTBridgeModule>> * (^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);
@@ -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)
{
@@ -432,27 +432,6 @@ struct RCTInstanceCallback : public InstanceCallback {
}));
}
/**
* id<RCTCxxBridgeDelegate> jsExecutorFactory may create and assign an id<RCTTurboModuleRegistry> object to
* RCTCxxBridge If id<RCTTurboModuleRegistry> 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<RCTTurboModuleRegistry> 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);
@@ -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();