diff --git a/packages/react-native/React/Base/RCTBridgeProxy.h b/packages/react-native/React/Base/RCTBridgeProxy.h index f8639c418e0..79c75c3b491 100644 --- a/packages/react-native/React/Base/RCTBridgeProxy.h +++ b/packages/react-native/React/Base/RCTBridgeProxy.h @@ -20,7 +20,8 @@ bundleManager:(RCTBundleManager *)bundleManager callableJSModules:(RCTCallableJSModules *)callableJSModules dispatchToJSThread:(void (^)(dispatch_block_t))dispatchToJSThread - registerSegmentWithId:(void (^)(NSNumber *, NSString *))registerSegmentWithId NS_DESIGNATED_INITIALIZER; + registerSegmentWithId:(void (^)(NSNumber *, NSString *))registerSegmentWithId + runtime:(void *)runtime NS_DESIGNATED_INITIALIZER; - (NSMethodSignature *)methodSignatureForSelector:(SEL)sel; - (void)forwardInvocation:(NSInvocation *)invocation; diff --git a/packages/react-native/React/Base/RCTBridgeProxy.mm b/packages/react-native/React/Base/RCTBridgeProxy.mm index e4ece263b12..af6b7afb687 100644 --- a/packages/react-native/React/Base/RCTBridgeProxy.mm +++ b/packages/react-native/React/Base/RCTBridgeProxy.mm @@ -28,6 +28,7 @@ using namespace facebook; RCTCallableJSModules *_callableJSModules; void (^_dispatchToJSThread)(dispatch_block_t); void (^_registerSegmentWithId)(NSNumber *, NSString *); + void *_runtime; } - (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry @@ -36,15 +37,17 @@ using namespace facebook; callableJSModules:(RCTCallableJSModules *)callableJSModules dispatchToJSThread:(void (^)(dispatch_block_t))dispatchToJSThread registerSegmentWithId:(void (^)(NSNumber *, NSString *))registerSegmentWithId + runtime:(void *)runtime { self = [super self]; if (self) { - self->_uiManagerProxy = [[RCTUIManagerProxy alloc] initWithViewRegistry:viewRegistry]; - self->_moduleRegistry = moduleRegistry; - self->_bundleManager = bundleManager; - self->_callableJSModules = callableJSModules; - self->_dispatchToJSThread = dispatchToJSThread; - self->_registerSegmentWithId = registerSegmentWithId; + _uiManagerProxy = [[RCTUIManagerProxy alloc] initWithViewRegistry:viewRegistry]; + _moduleRegistry = moduleRegistry; + _bundleManager = bundleManager; + _callableJSModules = callableJSModules; + _dispatchToJSThread = dispatchToJSThread; + _registerSegmentWithId = registerSegmentWithId; + _runtime = runtime; } return self; } @@ -75,10 +78,10 @@ using namespace facebook; * Used By: * - RCTBlobCollector */ -- (jsi::Runtime *)runtime +- (void *)runtime { - [self logWarning:@"This method is unsupported. Returning nullptr." cmd:_cmd]; - return nullptr; + [self logWarning:@"Please migrate to C++ TurboModule or RuntimeExecutor." cmd:_cmd]; + return _runtime; } /** @@ -162,7 +165,7 @@ using namespace facebook; - (void)registerSegmentWithId:(NSUInteger)segmentId path:(NSString *)path { - self->_registerSegmentWithId(@(segmentId), path); + _registerSegmentWithId(@(segmentId), path); } - (id)delegate diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm index 5bcec41c63d..a123105a672 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm @@ -263,7 +263,8 @@ void RCTInstanceSetRuntimeDiagnosticFlags(NSString *flags) if (strongSelf && strongSelf->_valid) { [strongSelf registerSegmentWithId:segmentId path:path]; } - }]; + } + runtime:_reactInstance->getJavaScriptContext()]; [RCTBridge setCurrentBridge:(RCTBridge *)bridgeProxy]; // Set up TurboModules