From 8876eaaea0a4321e5e92aba11d101be6525f62c5 Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Tue, 24 May 2016 12:02:31 -0700 Subject: [PATCH] Set up Systrace during initialization Summary: When we're profiling, we want to load Systrace immediately and profile all the startup and initial render code. The code here used to load Systrace during startup only if `__DEV__` but would always start profiling once Systrace was otherwise required. That seems pretty hard to reason about, so I'm switching to always requiring Systrace during the startup path and enabling profiling if appropriate. In actual production that'll always be false, of course. Reviewed By: javache Differential Revision: D3338216 fbshipit-source-id: f173e82f34e110d83e7ff04f11af9b302a54b859 --- .../Initialization/InitializeJavaScriptAppEngine.js | 6 ++++++ Libraries/Utilities/Systrace.js | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js b/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js index bcdc88829..372030698 100644 --- a/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js +++ b/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js @@ -40,6 +40,11 @@ function setUpProcess() { } } +function setUpProfile() { + const Systrace = require('Systrace'); + Systrace.setEnabled(global.__RCTProfileIsProfiling || false); +} + function setUpConsole() { // ExceptionsManager transitively requires Promise so we install it after const ExceptionsManager = require('ExceptionsManager'); @@ -229,6 +234,7 @@ function getPropertyDescriptor(object, name) { } setUpProcess(); +setUpProfile(); setUpConsole(); setUpTimers(); setUpAlert(); diff --git a/Libraries/Utilities/Systrace.js b/Libraries/Utilities/Systrace.js index 8dc207e1e..bdd2c5992 100644 --- a/Libraries/Utilities/Systrace.js +++ b/Libraries/Utilities/Systrace.js @@ -194,8 +194,6 @@ const Systrace = { }, }; -Systrace.setEnabled(global.__RCTProfileIsProfiling || false); - if (__DEV__) { // This is needed, because require callis in polyfills are not processed as // other files. Therefore, calls to `require('moduleId')` are not replaced