diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.h b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.h index fa98b221b9b5..b7f4789ba0e4 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.h +++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.h @@ -65,15 +65,6 @@ @interface RCTTurboModuleManager : NSObject -- (instancetype)initWithBridge:(RCTBridge *)bridge - delegate:(id)delegate - jsInvoker:(std::shared_ptr)jsInvoker; - -- (instancetype)initWithBridgeProxy:(RCTBridgeProxy *)bridgeProxy - bridgeModuleDecorator:(RCTBridgeModuleDecorator *)bridgeModuleDecorator - delegate:(id)delegate - jsInvoker:(std::shared_ptr)jsInvoker; - - (instancetype)initWithBridgeProxy:(RCTBridgeProxy *)bridgeProxy bridgeModuleDecorator:(RCTBridgeModuleDecorator *)bridgeModuleDecorator delegate:(id)delegate 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 4b3ee5b616e5..41baf828d4ac 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 @@ -25,8 +25,6 @@ #import #import #import -#import -#import #import #import #import @@ -189,7 +187,6 @@ Class getFallbackClassFromName(const char *name) @implementation RCTTurboModuleManager { std::shared_ptr _jsInvoker; __weak id _delegate; - __weak RCTBridge *_bridge; /** * TODO(T48018690): @@ -221,17 +218,15 @@ @implementation RCTTurboModuleManager { dispatch_queue_t _sharedModuleQueue; } -- (instancetype)initWithBridge:(RCTBridge *)bridge - bridgeProxy:(RCTBridgeProxy *)bridgeProxy - bridgeModuleDecorator:(RCTBridgeModuleDecorator *)bridgeModuleDecorator - delegate:(id)delegate - jsInvoker:(std::shared_ptr)jsInvoker - devMenuConfigurationDecorator:(RCTDevMenuConfigurationDecorator *)devMenuConfigurationDecorator +- (instancetype)initWithBridgeProxy:(RCTBridgeProxy *)bridgeProxy + bridgeModuleDecorator:(RCTBridgeModuleDecorator *)bridgeModuleDecorator + delegate:(id)delegate + jsInvoker:(std::shared_ptr)jsInvoker + devMenuConfigurationDecorator:(RCTDevMenuConfigurationDecorator *)devMenuConfigurationDecorator { if (self = [super init]) { _jsInvoker = std::move(jsInvoker); _delegate = delegate; - _bridge = bridge; _bridgeProxy = bridgeProxy; _bridgeModuleDecorator = bridgeModuleDecorator; _invalidating = false; @@ -261,58 +256,10 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge _legacyEagerlyRegisteredModuleClasses = legacyEagerlyRegisteredModuleClasses; } #endif // RCT_REMOVE_LEGACY_MODULE_INTEROP - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(bridgeWillInvalidateModules:) - name:RCTBridgeWillInvalidateModulesNotification - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(bridgeDidInvalidateModules:) - name:RCTBridgeDidInvalidateModulesNotification - object:nil]; } return self; } -- (instancetype)initWithBridge:(RCTBridge *)bridge - delegate:(id)delegate - jsInvoker:(std::shared_ptr)jsInvoker -{ - return [self initWithBridge:bridge - bridgeProxy:nil - bridgeModuleDecorator:[bridge bridgeModuleDecorator] - delegate:delegate - jsInvoker:jsInvoker - devMenuConfigurationDecorator:nil]; -} - -- (instancetype)initWithBridgeProxy:(RCTBridgeProxy *)bridgeProxy - bridgeModuleDecorator:(RCTBridgeModuleDecorator *)bridgeModuleDecorator - delegate:(id)delegate - jsInvoker:(std::shared_ptr)jsInvoker -{ - return [self initWithBridge:nil - bridgeProxy:bridgeProxy - bridgeModuleDecorator:bridgeModuleDecorator - delegate:delegate - jsInvoker:jsInvoker - devMenuConfigurationDecorator:nil]; -} - -- (instancetype)initWithBridgeProxy:(RCTBridgeProxy *)bridgeProxy - bridgeModuleDecorator:(RCTBridgeModuleDecorator *)bridgeModuleDecorator - delegate:(id)delegate - jsInvoker:(std::shared_ptr)jsInvoker - devMenuConfigurationDecorator:(RCTDevMenuConfigurationDecorator *)devMenuConfigurationDecorator -{ - return [self initWithBridge:nil - bridgeProxy:bridgeProxy - bridgeModuleDecorator:bridgeModuleDecorator - delegate:delegate - jsInvoker:jsInvoker - devMenuConfigurationDecorator:devMenuConfigurationDecorator]; -} - /** * Given a name for a TurboModule, return a C++ object which is the instance * of that TurboModule C++ class. This class wraps the TurboModule's ObjC instance. @@ -378,14 +325,6 @@ - (instancetype)initWithBridgeProxy:(RCTBridgeProxy *)bridgeProxy * Step 2c: Create and native CallInvoker from the TurboModule's method queue. */ nativeMethodCallInvoker = std::make_shared(methodQueue); - - /** - * Have RCTCxxBridge decorate native CallInvoker, so that it's aware of TurboModule async method calls. - * This helps the bridge fire onBatchComplete as readily as it should. - */ - if ([_bridge respondsToSelector:@selector(decorateNativeMethodCallInvoker:)]) { - nativeMethodCallInvoker = [_bridge decorateNativeMethodCallInvoker:nativeMethodCallInvoker]; - } } /** @@ -681,7 +620,7 @@ - (BOOL)_shouldCreateObjCModule:(Class)moduleClass * this method exists to know if we can safely set the bridge to the * NativeModule. */ - if ([module respondsToSelector:@selector(bridge)] && (_bridge || _bridgeProxy)) { + if ([module respondsToSelector:@selector(bridge)] && _bridgeProxy) { /** * Just because a NativeModule has the `bridge` method, it doesn't mean * that it has synthesized the bridge in its implementation. Therefore, @@ -698,11 +637,7 @@ - (BOOL)_shouldCreateObjCModule:(Class)moduleClass * generated, so we have have to rely on the KVC API of ObjC to set * the bridge property of these NativeModules. */ - if (_bridge) { - [(id)module setValue:_bridge forKey:@"bridge"]; - } else if (_bridgeProxy) { - [(id)module setValue:_bridgeProxy forKey:@"bridge"]; - } + [(id)module setValue:_bridgeProxy forKey:@"bridge"]; } @catch (NSException *) { RCTLogError( @"%@ has no setter or ivar for its bridge, which is not " @@ -789,33 +724,15 @@ - (BOOL)_shouldCreateObjCModule:(Class)moduleClass */ objc_setAssociatedObject(module, &kAssociatedMethodQueueKey, methodQueue, OBJC_ASSOCIATION_RETAIN); - /** - * NativeModules that implement the RCTFrameUpdateObserver protocol - * require registration with RCTDisplayLink. - * - * TODO(T55504345): Investigate whether we can improve this after TM - * rollout. - */ - if (_bridge) { - RCTModuleData *data = [[RCTModuleData alloc] initWithModuleInstance:(id)module - bridge:_bridge - moduleRegistry:_bridge.moduleRegistry - viewRegistry_DEPRECATED:nil - bundleManager:nil - callableJSModules:nil]; - [_bridge registerModuleForFrameUpdates:(id)module withModuleData:data]; - } - /** * Broadcast that this NativeModule was created. * * TODO(T41180176): Investigate whether we can delete this after TM * rollout. */ - [[NSNotificationCenter defaultCenter] - postNotificationName:RCTDidInitializeModuleNotification - object:_bridge - userInfo:@{@"module" : module, @"bridge" : RCTNullIfNil([_bridge parentBridge])}]; + [[NSNotificationCenter defaultCenter] postNotificationName:RCTDidInitializeModuleNotification + object:nil + userInfo:@{@"module" : module, @"bridge" : [NSNull null]}]; TurboModulePerfLogger::moduleCreateSetUpEnd(moduleName, moduleId); @@ -932,10 +849,6 @@ - (void)installJSBindings:(facebook::jsi::Runtime &)runtime auto moduleName = name.c_str(); TurboModulePerfLogger::moduleJSRequireBeginningStart(moduleName); - auto moduleWasNotInitialized = ![self moduleIsInitialized:moduleName]; - if (moduleWasNotInitialized) { - [self->_bridge.performanceLogger markStartForTag:RCTPLTurboModuleSetup]; - } /** * By default, all TurboModules are long-lived. @@ -944,10 +857,6 @@ - (void)installJSBindings:(facebook::jsi::Runtime &)runtime */ auto turboModule = [self provideTurboModule:moduleName runtime:&runtime]; - if (moduleWasNotInitialized && [self moduleIsInitialized:moduleName]) { - [self->_bridge.performanceLogger markStopForTag:RCTPLTurboModuleSetup]; - } - if (turboModule) { TurboModulePerfLogger::moduleJSRequireEndingEnd(moduleName); } else { @@ -1020,26 +929,6 @@ - (BOOL)moduleIsInitialized:(const char *)moduleName #pragma mark Invalidation logic -- (void)bridgeWillInvalidateModules:(NSNotification *)notification -{ - RCTBridge *bridge = notification.userInfo[@"bridge"]; - if (bridge != _bridge) { - return; - } - - [self _enterInvalidatingState]; -} - -- (void)bridgeDidInvalidateModules:(NSNotification *)notification -{ - RCTBridge *bridge = notification.userInfo[@"bridge"]; - if (bridge != _bridge) { - return; - } - - [self _invalidateModules]; -} - - (void)invalidate { [self _enterInvalidatingState]; @@ -1098,15 +987,10 @@ - (void)_invalidateModules dispatch_group_leave(moduleInvalidationGroup); }; - if (_bridge) { - [_bridge dispatchBlock:invalidateModule queue:methodQueue]; + if (methodQueue == RCTJSThread) { + invalidateModule(); } else { - // Bridgeless mode - if (methodQueue == RCTJSThread) { - invalidateModule(); - } else { - dispatch_async(methodQueue, invalidateModule); - } + dispatch_async(methodQueue, invalidateModule); } } diff --git a/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api index b21cc7537e32..3d69952ee8e7 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api @@ -1999,8 +1999,6 @@ interface RCTTransformAnimatedNode : public RCTAnimatedNode { } interface RCTTurboModuleManager : public NSObject { - public virtual instancetype initWithBridge:delegate:jsInvoker:(RCTBridge* bridge, id delegate, std::shared_ptr jsInvoker); - public virtual instancetype initWithBridgeProxy:bridgeModuleDecorator:delegate:jsInvoker:(RCTBridgeProxy* bridgeProxy, RCTBridgeModuleDecorator* bridgeModuleDecorator, id delegate, std::shared_ptr jsInvoker); public virtual instancetype initWithBridgeProxy:bridgeModuleDecorator:delegate:jsInvoker:devMenuConfigurationDecorator:(RCTBridgeProxy* bridgeProxy, RCTBridgeModuleDecorator* bridgeModuleDecorator, id delegate, std::shared_ptr jsInvoker, RCTDevMenuConfigurationDecorator* devMenuConfigurationDecorator); public virtual void installJSBindings:(facebook::jsi::Runtime& runtime); public virtual void invalidate(); diff --git a/scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api index ba855d75db55..15f5fc7ddc19 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api @@ -1987,8 +1987,6 @@ interface RCTTransformAnimatedNode : public RCTAnimatedNode { } interface RCTTurboModuleManager : public NSObject { - public virtual instancetype initWithBridge:delegate:jsInvoker:(RCTBridge* bridge, id delegate, std::shared_ptr jsInvoker); - public virtual instancetype initWithBridgeProxy:bridgeModuleDecorator:delegate:jsInvoker:(RCTBridgeProxy* bridgeProxy, RCTBridgeModuleDecorator* bridgeModuleDecorator, id delegate, std::shared_ptr jsInvoker); public virtual instancetype initWithBridgeProxy:bridgeModuleDecorator:delegate:jsInvoker:devMenuConfigurationDecorator:(RCTBridgeProxy* bridgeProxy, RCTBridgeModuleDecorator* bridgeModuleDecorator, id delegate, std::shared_ptr jsInvoker, RCTDevMenuConfigurationDecorator* devMenuConfigurationDecorator); public virtual void installJSBindings:(facebook::jsi::Runtime& runtime); public virtual void invalidate(); diff --git a/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api index c479d823c10a..0b2305d264f4 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api @@ -1999,8 +1999,6 @@ interface RCTTransformAnimatedNode : public RCTAnimatedNode { } interface RCTTurboModuleManager : public NSObject { - public virtual instancetype initWithBridge:delegate:jsInvoker:(RCTBridge* bridge, id delegate, std::shared_ptr jsInvoker); - public virtual instancetype initWithBridgeProxy:bridgeModuleDecorator:delegate:jsInvoker:(RCTBridgeProxy* bridgeProxy, RCTBridgeModuleDecorator* bridgeModuleDecorator, id delegate, std::shared_ptr jsInvoker); public virtual instancetype initWithBridgeProxy:bridgeModuleDecorator:delegate:jsInvoker:devMenuConfigurationDecorator:(RCTBridgeProxy* bridgeProxy, RCTBridgeModuleDecorator* bridgeModuleDecorator, id delegate, std::shared_ptr jsInvoker, RCTDevMenuConfigurationDecorator* devMenuConfigurationDecorator); public virtual void installJSBindings:(facebook::jsi::Runtime& runtime); public virtual void invalidate();