From 7978f7a27be26958135b2f9e8d230716a197baf7 Mon Sep 17 00:00:00 2001 From: Aaron Chiu Date: Wed, 8 Mar 2017 03:18:50 -0800 Subject: [PATCH] enable Systracing is JS before JSBundle finishes loading Reviewed By: alexeylang Differential Revision: D4671771 fbshipit-source-id: 5cd12bf84f25d4c3b188cf32907415b5a695b360 --- .../java/com/facebook/react/ReactInstanceManager.java | 11 ++++++++--- .../src/main/java/com/facebook/systrace/Systrace.java | 8 +++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index b6a885013..32a4f92c9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -53,15 +53,15 @@ import com.facebook.react.cxxbridge.JavaScriptExecutor; import com.facebook.react.cxxbridge.NativeModuleRegistry; import com.facebook.react.cxxbridge.ProxyJavaScriptExecutor; import com.facebook.react.cxxbridge.UiThreadUtil; -import com.facebook.react.devsupport.interfaces.DevSupportManager; -import com.facebook.react.devsupport.interfaces.PackagerStatusCallback; import com.facebook.react.devsupport.DevSupportManagerFactory; import com.facebook.react.devsupport.ReactInstanceDevCommandsHandler; import com.facebook.react.devsupport.RedBoxHandler; +import com.facebook.react.devsupport.interfaces.DevSupportManager; +import com.facebook.react.devsupport.interfaces.PackagerStatusCallback; +import com.facebook.react.modules.appregistry.AppRegistry; import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; import com.facebook.react.modules.core.DeviceEventManagerModule; import com.facebook.react.modules.debug.interfaces.DeveloperSettings; -import com.facebook.react.modules.appregistry.AppRegistry; import com.facebook.react.uimanager.DisplayMetricsHolder; import com.facebook.react.uimanager.UIImplementationProvider; import com.facebook.react.uimanager.UIManagerModule; @@ -82,7 +82,9 @@ import static com.facebook.react.bridge.ReactMarkerConstants.PROCESS_PACKAGES_EN import static com.facebook.react.bridge.ReactMarkerConstants.PROCESS_PACKAGES_START; import static com.facebook.react.bridge.ReactMarkerConstants.SETUP_REACT_CONTEXT_END; import static com.facebook.react.bridge.ReactMarkerConstants.SETUP_REACT_CONTEXT_START; +import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_APPS; import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; +import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JSC_CALLS; /** * This class is managing instances of {@link CatalystInstance}. It exposes a way to configure @@ -931,6 +933,9 @@ public class ReactInstanceManager { if (mBridgeIdleDebugListener != null) { catalystInstance.addBridgeIdleDebugListener(mBridgeIdleDebugListener); } + if (Systrace.isTracing(TRACE_TAG_REACT_APPS | TRACE_TAG_REACT_JSC_CALLS)) { + catalystInstance.setGlobalVariable("__RCTProfileIsProfiling", "true"); + } reactContext.initializeWithInstance(catalystInstance); catalystInstance.runJSBundle(); diff --git a/ReactAndroid/src/main/java/com/facebook/systrace/Systrace.java b/ReactAndroid/src/main/java/com/facebook/systrace/Systrace.java index a3d7699ce..e3ae99e0d 100644 --- a/ReactAndroid/src/main/java/com/facebook/systrace/Systrace.java +++ b/ReactAndroid/src/main/java/com/facebook/systrace/Systrace.java @@ -19,9 +19,11 @@ import android.os.Trace; public class Systrace { public static final long TRACE_TAG_REACT_JAVA_BRIDGE = 0L; + public static final long TRACE_TAG_REACT_APPS = 0L; public static final long TRACE_TAG_REACT_FRESCO = 0L; public static final long TRACE_TAG_REACT_APPS = 0L; public static final long TRACE_TAG_REACT_VIEW = 0L; + public static final long TRACE_TAG_REACT_JSC_CALLS = 0L; public enum EventScope { THREAD('t'), @@ -88,18 +90,18 @@ public class Systrace { public static void startAsyncFlow( long tag, final String sectionName, - final int cookie){ + final int cookie) { } public static void stepAsyncFlow( long tag, final String sectionName, - final int cookie){ + final int cookie) { } public static void endAsyncFlow( long tag, final String sectionName, - final int cookie){ + final int cookie) { } }