diff --git a/React/Base/RCTBatchedBridge.m b/React/Base/RCTBatchedBridge.m index e9e1f608da..e3d9ea0d3e 100644 --- a/React/Base/RCTBatchedBridge.m +++ b/React/Base/RCTBatchedBridge.m @@ -57,6 +57,7 @@ RCT_EXTERN NSArray *RCTGetModuleClasses(void); @synthesize flowIDMapLock = _flowIDMapLock; @synthesize loading = _loading; @synthesize valid = _valid; +@synthesize performanceLogger = _performanceLogger; - (instancetype)initWithParentBridge:(RCTBridge *)bridge { @@ -68,6 +69,10 @@ RCT_EXTERN NSArray *RCTGetModuleClasses(void); launchOptions:bridge.launchOptions]) { _parentBridge = bridge; + _performanceLogger = [RCTPerformanceLogger new]; + [_performanceLogger markStartForTag:RCTPLBridgeStartup]; + [_performanceLogger markStartForTag:RCTPLTTI]; + /** * Set Initial State */ diff --git a/React/Base/RCTBridge+Private.h b/React/Base/RCTBridge+Private.h index e7693685b7..f69e2beec5 100644 --- a/React/Base/RCTBridge+Private.h +++ b/React/Base/RCTBridge+Private.h @@ -10,14 +10,9 @@ #import "RCTBridge.h" @class RCTModuleData; -@class RCTPerformanceLogger; @protocol RCTJavaScriptExecutor; @interface RCTBridge () -{ -@public - RCTPerformanceLogger *_performanceLogger; -} // Private designated initializer - (instancetype)initWithDelegate:(id)delegate @@ -134,9 +129,9 @@ @interface RCTBatchedBridge : RCTBridge -@property (nonatomic, weak) RCTBridge *parentBridge; -@property (nonatomic, weak) id javaScriptExecutor; -@property (nonatomic, assign) BOOL moduleSetupComplete; +@property (nonatomic, weak, readonly) RCTBridge *parentBridge; +@property (nonatomic, weak, readonly) id javaScriptExecutor; +@property (nonatomic, assign, readonly) BOOL moduleSetupComplete; - (instancetype)initWithParentBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER; diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index 030ca38259..f515a87315 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -132,15 +132,13 @@ static RCTBridge *RCTCurrentBridgeInstance = nil; launchOptions:(NSDictionary *)launchOptions { if (self = [super init]) { - _performanceLogger = [RCTPerformanceLogger new]; - [_performanceLogger markStartForTag:RCTPLBridgeStartup]; - [_performanceLogger markStartForTag:RCTPLTTI]; - _delegate = delegate; _bundleURL = bundleURL; _moduleProvider = block; _launchOptions = [launchOptions copy]; + [self setUp]; + RCTExecuteOnMainQueue(^{ [self bindKeys]; }); } return self; @@ -182,6 +180,11 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) #endif } +- (RCTPerformanceLogger *)performanceLogger +{ + return self.batchedBridge.performanceLogger; +} + - (NSArray *)moduleClasses { return self.batchedBridge.moduleClasses; diff --git a/React/Base/RCTPerformanceLogger.h b/React/Base/RCTPerformanceLogger.h index 9477a0ec67..ab37e1d54e 100644 --- a/React/Base/RCTPerformanceLogger.h +++ b/React/Base/RCTPerformanceLogger.h @@ -85,7 +85,7 @@ typedef NS_ENUM(NSUInteger, RCTPLTag) { - (NSArray *)valuesForTags; /** - * Returns a duration (stop_time - start_time) for given RCTPLTag. + * Returns a duration in ms (stop_time - start_time) for given RCTPLTag. */ - (int64_t)durationForTag:(RCTPLTag)tag; diff --git a/React/Base/RCTRootView.m b/React/Base/RCTRootView.m index 20fc643a1a..fe0b3ed2de 100644 --- a/React/Base/RCTRootView.m +++ b/React/Base/RCTRootView.m @@ -14,7 +14,7 @@ #import #import "RCTAssert.h" -#import "RCTBridge+Private.h" +#import "RCTBridge.h" #import "RCTEventDispatcher.h" #import "RCTKeyCommands.h" #import "RCTLog.h" @@ -92,7 +92,7 @@ NSString *const RCTContentDidAppearNotification = @"RCTContentDidAppearNotificat object:self]; if (!_bridge.loading) { - [self bundleFinishedLoading:_bridge.batchedBridge]; + [self bundleFinishedLoading:_bridge]; } [self showLoadingView]; @@ -259,7 +259,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) _appProperties = [appProperties copy]; if (_contentView && _bridge.valid && !_bridge.loading) { - [self runApplication:_bridge.batchedBridge]; + [self runApplication:_bridge]; } } @@ -340,7 +340,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder:(nonnull NSCoder *)aDecoder) - (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex { [super insertReactSubview:subview atIndex:atIndex]; - [_bridge->_performanceLogger markStopForTag:RCTPLTTI]; + [_bridge.performanceLogger markStopForTag:RCTPLTTI]; dispatch_async(dispatch_get_main_queue(), ^{ if (!self->_contentHasAppeared) { self->_contentHasAppeared = YES;