Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/react-native/React/Base/RCTBridgeProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ NS_ASSUME_NONNULL_BEGIN
@class RCTBundleManager;
@class RCTCallableJSModules;
@class RCTModuleRegistry;
@class RCTPerformanceLogger;
@class RCTViewRegistry;

@interface RCTBridgeProxy : NSProxy

- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;

/**
* The performance logger for this React instance. In bridgeless mode it is
* injected by RCTInstance so that consumers reading `[bridge performanceLogger]`
* on `RCTJavaScriptDidLoadNotification` keep working; previously it returned nil.
*/
@property (nonatomic, strong, nullable) RCTPerformanceLogger *performanceLogger;

- (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry
moduleRegistry:(RCTModuleRegistry *)moduleRegistry
bundleManager:(RCTBundleManager *)bundleManager
Expand Down
8 changes: 2 additions & 6 deletions packages/react-native/React/Base/RCTBridgeProxy.mm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ @implementation RCTBridgeProxy {
void *_runtime;
}

@synthesize performanceLogger = _performanceLogger;

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-designated-initializers"
- (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry
Expand Down Expand Up @@ -213,12 +215,6 @@ - (BOOL)valid
return NO;
}

- (RCTPerformanceLogger *)performanceLogger
{
[self logWarning:@"This method is not supported. Returning nil." cmd:_cmd];
return nil;
}

- (void)reload
{
[self logError:@"Please use RCTReloadCommand instead. Nooping." cmd:_cmd];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ @implementation RCTInstance {
RCTPerformanceLogger *_performanceLogger;
RCTDisplayLink *_displayLink;
RCTTurboModuleManager *_turboModuleManager;
RCTBridgeProxy *_bridgeProxy;
std::mutex _invalidationMutex;
std::atomic<bool> _valid;
RCTJSThreadManager *_jsThreadManager;
Expand Down Expand Up @@ -351,6 +352,8 @@ - (void)_start
runtime:_reactInstance->getJavaScriptContext()
launchOptions:_launchOptions];
bridgeProxy.jsCallInvoker = jsCallInvoker;
bridgeProxy.performanceLogger = _performanceLogger;
_bridgeProxy = bridgeProxy;
[RCTBridge setCurrentBridge:(RCTBridge *)bridgeProxy];

// Set up TurboModules
Expand Down Expand Up @@ -606,8 +609,20 @@ - (void)_loadScriptFromSource:(RCTSource *)source
waitUntilModuleSetupComplete();
}
};
auto afterLoad = [](jsi::Runtime &_) {
__weak __typeof(self) weakSelf = self;
auto afterLoad = [weakSelf](jsi::Runtime &) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"RCTInstanceDidLoadBundle" object:nil];
__strong __typeof(weakSelf) strongSelf = weakSelf;
if (strongSelf) {
RCTBridgeProxy *bridgeProxy = strongSelf->_bridgeProxy;
// afterLoad runs on the JS thread; post on main like the legacy bridge so
// RCTJavaScriptDidLoadNotification observers aren't invoked off-main.
RCTExecuteOnMainQueue(^{
[[NSNotificationCenter defaultCenter] postNotificationName:RCTJavaScriptDidLoadNotification
object:strongSelf
userInfo:bridgeProxy ? @{@"bridge" : bridgeProxy} : @{}];
});
}
};
_reactInstance->loadScript(std::move(script), url, beforeLoad, afterLoad);
}
Expand Down
1 change: 1 addition & 0 deletions scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ interface RCTBridgeModuleDecorator : public NSObject {
}

interface RCTBridgeProxy : public NSProxy {
public @property (strong) RCTPerformanceLogger* performanceLogger;
public virtual NSMethodSignature* methodSignatureForSelector:(SEL sel);
public virtual id moduleForClass:(Class moduleClass);
public virtual id moduleForName:lazilyLoadIfNecessary:(NSString* moduleName, BOOL lazilyLoad);
Expand Down
1 change: 1 addition & 0 deletions scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ interface RCTBridgeModuleDecorator : public NSObject {
}

interface RCTBridgeProxy : public NSProxy {
public @property (strong) RCTPerformanceLogger* performanceLogger;
public virtual NSMethodSignature* methodSignatureForSelector:(SEL sel);
public virtual id moduleForClass:(Class moduleClass);
public virtual id moduleForName:lazilyLoadIfNecessary:(NSString* moduleName, BOOL lazilyLoad);
Expand Down
1 change: 1 addition & 0 deletions scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ interface RCTBridgeModuleDecorator : public NSObject {
}

interface RCTBridgeProxy : public NSProxy {
public @property (strong) RCTPerformanceLogger* performanceLogger;
public virtual NSMethodSignature* methodSignatureForSelector:(SEL sel);
public virtual id moduleForClass:(Class moduleClass);
public virtual id moduleForName:lazilyLoadIfNecessary:(NSString* moduleName, BOOL lazilyLoad);
Expand Down
Loading