Permalink
Browse files

Fix double React perflogger creation

Reviewed By: mmmulani

Differential Revision: D3599003

fbshipit-source-id: 25090309c92127b403d1df6a8b7c18ad5a088b5e
  • Loading branch information...
1 parent 09fff49 commit 82c8129627aa857040a4a39aef49cf03869e6ed3 @javache javache committed with Facebook Github Bot 2 Jul 22, 2016
@@ -57,6 +57,7 @@ @implementation RCTBatchedBridge
@synthesize flowIDMapLock = _flowIDMapLock;
@synthesize loading = _loading;
@synthesize valid = _valid;
+@synthesize performanceLogger = _performanceLogger;
- (instancetype)initWithParentBridge:(RCTBridge *)bridge
{
@@ -68,6 +69,10 @@ - (instancetype)initWithParentBridge:(RCTBridge *)bridge
launchOptions:bridge.launchOptions]) {
_parentBridge = bridge;
+ _performanceLogger = [RCTPerformanceLogger new];
+ [_performanceLogger markStartForTag:RCTPLBridgeStartup];
+ [_performanceLogger markStartForTag:RCTPLTTI];
+
/**
* Set Initial State
*/
@@ -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;
@@ -132,15 +132,13 @@ - (instancetype)initWithDelegate:(id<RCTBridgeDelegate>)delegate
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 @@ - (void)bindKeys
#endif
}
+- (RCTPerformanceLogger *)performanceLogger
+{
+ return self.batchedBridge.performanceLogger;
+}
+
- (NSArray<Class> *)moduleClasses
{
return self.batchedBridge.moduleClasses;
@@ -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;
@@ -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 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
object:self];
if (!_bridge.loading) {
- [self bundleFinishedLoading:_bridge.batchedBridge];
+ [self bundleFinishedLoading:_bridge];
}
[self showLoadingView];
@@ -259,7 +259,7 @@ - (void)setAppProperties:(NSDictionary *)appProperties
_appProperties = [appProperties copy];
if (_contentView && _bridge.valid && !_bridge.loading) {
- [self runApplication:_bridge.batchedBridge];
+ [self runApplication:_bridge];
}
}
@@ -340,7 +340,7 @@ - (instancetype)initWithFrame:(CGRect)frame
- (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;

0 comments on commit 82c8129

Please sign in to comment.