Fix double React perflogger creation

Reviewed By: mmmulani

Differential Revision: D3599003

fbshipit-source-id: 25090309c92127b403d1df6a8b7c18ad5a088b5e
This commit is contained in:
Pieter De Baets 2016-07-22 09:50:48 -07:00 committed by Facebook Github Bot 2
parent 09fff496c9
commit 82c8129627
5 changed files with 20 additions and 17 deletions

View File

@ -57,6 +57,7 @@ RCT_EXTERN NSArray<Class> *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<Class> *RCTGetModuleClasses(void);
launchOptions:bridge.launchOptions]) {
_parentBridge = bridge;
_performanceLogger = [RCTPerformanceLogger new];
[_performanceLogger markStartForTag:RCTPLBridgeStartup];
[_performanceLogger markStartForTag:RCTPLTTI];
/**
* Set Initial State
*/

View File

@ -10,14 +10,9 @@
#import "RCTBridge.h"
@class RCTModuleData;
@class RCTPerformanceLogger;
@protocol RCTJavaScriptExecutor;
@interface RCTBridge ()
{
@public
RCTPerformanceLogger *_performanceLogger;
}
// Private designated initializer
- (instancetype)initWithDelegate:(id<RCTBridgeDelegate>)delegate
@ -134,9 +129,9 @@
@interface RCTBatchedBridge : RCTBridge <RCTInvalidating>
@property (nonatomic, weak) RCTBridge *parentBridge;
@property (nonatomic, weak) id<RCTJavaScriptExecutor> javaScriptExecutor;
@property (nonatomic, assign) BOOL moduleSetupComplete;
@property (nonatomic, weak, readonly) RCTBridge *parentBridge;
@property (nonatomic, weak, readonly) id<RCTJavaScriptExecutor> javaScriptExecutor;
@property (nonatomic, assign, readonly) BOOL moduleSetupComplete;
- (instancetype)initWithParentBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER;

View File

@ -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<Class> *)moduleClasses
{
return self.batchedBridge.moduleClasses;

View File

@ -85,7 +85,7 @@ typedef NS_ENUM(NSUInteger, RCTPLTag) {
- (NSArray<NSNumber *> *)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;

View File

@ -14,7 +14,7 @@
#import <objc/runtime.h>
#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;