measure delay of calling into UI thread when setting up ReactContext

Reviewed By: yungsters

Differential Revision: D4736627

fbshipit-source-id: 6d425ef0ad7bbd54296a619009136c929cb16030
This commit is contained in:
Aaron Chiu 2017-03-25 09:32:45 -07:00 committed by Facebook Github Bot
parent 848593c0f0
commit e2204c5ccb
2 changed files with 9 additions and 2 deletions

View File

@ -78,6 +78,8 @@ import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_CATALYST_INS
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_REACT_CONTEXT_START;
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_VIEW_MANAGERS_END;
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_VIEW_MANAGERS_START;
import static com.facebook.react.bridge.ReactMarkerConstants.PRE_SETUP_REACT_CONTEXT_END;
import static com.facebook.react.bridge.ReactMarkerConstants.PRE_SETUP_REACT_CONTEXT_START;
import static com.facebook.react.bridge.ReactMarkerConstants.PROCESS_PACKAGES_END;
import static com.facebook.react.bridge.ReactMarkerConstants.PROCESS_PACKAGES_START;
import static com.facebook.react.bridge.ReactMarkerConstants.SETUP_REACT_CONTEXT_END;
@ -217,7 +219,10 @@ public class ReactInstanceManager {
Assertions.assertCondition(params != null && params.length > 0 && params[0] != null);
try {
JavaScriptExecutor jsExecutor = params[0].getJsExecutorFactory().create();
return Result.of(createReactContext(jsExecutor, params[0].getJsBundleLoader()));
ReactApplicationContext reactApplicationContext =
createReactContext(jsExecutor, params[0].getJsBundleLoader());
ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_START);
return Result.of(reactApplicationContext);
} catch (Exception e) {
// Pass exception to onPostExecute() so it can be handled on the main thread
return Result.of(e);
@ -777,6 +782,7 @@ public class ReactInstanceManager {
}
private void setupReactContext(ReactApplicationContext reactContext) {
ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_END);
ReactMarker.logMarker(SETUP_REACT_CONTEXT_START);
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "setupReactContext");
UiThreadUtil.assertOnUiThread();

View File

@ -68,5 +68,6 @@ public class ReactMarkerConstants {
public static final String ON_HOST_PAUSE_END = "ON_HOST_PAUSE_END";
public static final String CONVERT_CONSTANTS_START = "CONVERT_CONSTANTS_START";
public static final String CONVERT_CONSTANTS_END = "CONVERT_CONSTANTS_END";
public static final String PRE_REACT_CONTEXT_END = "PRE_REACT_CONTEXT_END";
public static final String PRE_SETUP_REACT_CONTEXT_START = "PRE_SETUP_REACT_CONTEXT_START";
public static final String PRE_SETUP_REACT_CONTEXT_END = "PRE_SETUP_REACT_CONTEXT_END";
}