From a885efe02dc25e23647e028fa005261207c8a581 Mon Sep 17 00:00:00 2001 From: Tadeu Zagallo Date: Wed, 17 Jun 2015 14:03:50 -0700 Subject: [PATCH] [ReactNative] Add more markers and fix FPS graph Summary: @public Add marker to show JavaScript download duration + flow arrows to show the origin of the UI blocks being flushed. Also fixed the condition on `RCTPerfStats`, UI and JS graphs were being created at startup time, now they're just created on the first time they're shown. Test Plan: The markers: {F22577660} To check the FPS graph, enable it on the DevMenu, and it should appear initially empty, instead of previously filled as before. --- React/Base/RCTBridge.m | 7 ++++--- React/Base/RCTPerfStats.m | 4 ++-- React/Modules/RCTUIManager.m | 2 ++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index 8dce4584b..bbf28e25d 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -951,8 +951,10 @@ RCT_INNER_BRIDGE_ONLY(_invokeAndProcessModule:(__unused NSString *)module }); } else { + RCTProfileBeginEvent(); RCTJavaScriptLoader *loader = [[RCTJavaScriptLoader alloc] initWithBridge:self]; [loader loadBundleAtURL:bundleURL onComplete:^(NSError *error, NSString *script) { + RCTProfileEndEvent(@"JavaScript dowload", @"init,download", @[]); _loading = NO; if (!self.isValid) { @@ -1119,12 +1121,11 @@ RCT_INNER_BRIDGE_ONLY(_invokeAndProcessModule:(__unused NSString *)module { RCTAssert(onComplete != nil, @"onComplete block passed in should be non-nil"); - RCTProfileBeginEvent(); - + RCTProfileBeginFlowEvent(); [_javaScriptExecutor executeApplicationScript:script sourceURL:url onComplete:^(NSError *scriptLoadError) { + RCTProfileEndFlowEvent(); RCTAssertJSThread(); - RCTProfileEndEvent(@"ApplicationScript", @"js_call,init", scriptLoadError); if (scriptLoadError) { onComplete(scriptLoadError); return; diff --git a/React/Base/RCTPerfStats.m b/React/Base/RCTPerfStats.m index 2e5ec8d14..39f72928f 100644 --- a/React/Base/RCTPerfStats.m +++ b/React/Base/RCTPerfStats.m @@ -41,7 +41,7 @@ RCT_EXPORT_MODULE() - (RCTFPSGraph *)jsGraph { - if (!_jsGraph) { + if (!_jsGraph && _container) { UIColor *jsColor = [UIColor colorWithRed:0 green:1 blue:0 alpha:1]; _jsGraph = [[RCTFPSGraph alloc] initWithFrame:CGRectMake(2, 2, 124, 34) graphPosition:RCTFPSGraphPositionRight @@ -54,7 +54,7 @@ RCT_EXPORT_MODULE() - (RCTFPSGraph *)uiGraph { - if (!_uiGraph) { + if (!_uiGraph && _container) { UIColor *uiColor = [UIColor colorWithRed:0 green:1 blue:1 alpha:1]; _uiGraph = [[RCTFPSGraph alloc] initWithFrame:CGRectMake(2, 2, 124, 34) graphPosition:RCTFPSGraphPositionLeft diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index 0ffbaf0c3..ff1691b8a 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -979,7 +979,9 @@ RCT_EXPORT_METHOD(findSubviewIn:(NSNumber *)reactTag atPoint:(CGPoint)point call [_pendingUIBlocksLock unlock]; // Execute the previously queued UI blocks + RCTProfileBeginFlowEvent(); dispatch_async(dispatch_get_main_queue(), ^{ + RCTProfileEndFlowEvent(); RCTProfileBeginEvent(); for (dispatch_block_t block in previousPendingUIBlocks) { block();