From 26d9417f2b95df6dff8d85bfde84de21501bdc3f Mon Sep 17 00:00:00 2001 From: Alexey Lang Date: Wed, 16 Mar 2016 09:46:55 -0700 Subject: [PATCH] Track native modules which use the main thread for initialization or gathering constants Reviewed By: majak Differential Revision: D3054146 fb-gh-sync-id: fd4f4c0dff3144d22357ea798d3131aee578d509 shipit-source-id: fd4f4c0dff3144d22357ea798d3131aee578d509 --- React/Base/RCTBatchedBridge.m | 4 ++++ React/Base/RCTPerformanceLogger.h | 1 + React/Base/RCTPerformanceLogger.m | 2 ++ 3 files changed, 7 insertions(+) diff --git a/React/Base/RCTBatchedBridge.m b/React/Base/RCTBatchedBridge.m index c85011c55..4e292de64 100644 --- a/React/Base/RCTBatchedBridge.m +++ b/React/Base/RCTBatchedBridge.m @@ -364,6 +364,7 @@ RCT_EXTERN NSArray *RCTGetModuleClasses(void); // Set up modules that require main thread init or constants export RCTPerformanceLoggerSet(RCTPLNativeModuleMainThread, 0); + NSUInteger modulesOnMainThreadCount = 0; for (RCTModuleData *moduleData in _moduleDataByID) { __weak RCTBatchedBridge *weakSelf = self; if (moduleData.requiresMainThreadSetup) { @@ -380,6 +381,7 @@ RCT_EXTERN NSArray *RCTGetModuleClasses(void); RCTPerformanceLoggerAppendEnd(RCTPLNativeModuleMainThread); } }); + modulesOnMainThreadCount++; } else if (moduleData.hasConstantsToExport) { // Constants must be exported on the main thread, but module setup can // be done on any queue @@ -391,10 +393,12 @@ RCT_EXTERN NSArray *RCTGetModuleClasses(void); RCTPerformanceLoggerAppendEnd(RCTPLNativeModuleMainThread); } }); + modulesOnMainThreadCount++; } } RCTPerformanceLoggerEnd(RCTPLNativeModuleInit); + RCTPerformanceLoggerSet(RCTPLNativeModuleMainThreadUsesCount, modulesOnMainThreadCount); } - (void)setUpExecutor diff --git a/React/Base/RCTPerformanceLogger.h b/React/Base/RCTPerformanceLogger.h index c8978071c..c50e9f9cf 100644 --- a/React/Base/RCTPerformanceLogger.h +++ b/React/Base/RCTPerformanceLogger.h @@ -18,6 +18,7 @@ typedef NS_ENUM(NSUInteger, RCTPLTag) { RCTPLNativeModuleMainThread, RCTPLNativeModulePrepareConfig, RCTPLNativeModuleInjectConfig, + RCTPLNativeModuleMainThreadUsesCount, RCTPLJSCExecutorSetup, RCTPLTTI, RCTPLBundleSize, diff --git a/React/Base/RCTPerformanceLogger.m b/React/Base/RCTPerformanceLogger.m index 7bca4a728..9fc9647c8 100644 --- a/React/Base/RCTPerformanceLogger.m +++ b/React/Base/RCTPerformanceLogger.m @@ -78,6 +78,8 @@ NSArray *RCTPerformanceLoggerOutput(void) @(RCTPLData[RCTPLNativeModulePrepareConfig][1]), @(RCTPLData[RCTPLNativeModuleInjectConfig][0]), @(RCTPLData[RCTPLNativeModuleInjectConfig][1]), + @(RCTPLData[RCTPLNativeModuleMainThreadUsesCount][0]), + @(RCTPLData[RCTPLNativeModuleMainThreadUsesCount][1]), @(RCTPLData[RCTPLJSCExecutorSetup][0]), @(RCTPLData[RCTPLJSCExecutorSetup][1]), @(RCTPLData[RCTPLTTI][0]),