add more systraces

Reviewed By: alexeylang

Differential Revision: D4998351

fbshipit-source-id: a5c3ad829400b23aec49a2b919ab3fc7fc20c07b
This commit is contained in:
Aaron Chiu 2017-05-04 13:34:51 -07:00 committed by Facebook Github Bot
parent bc4de008d3
commit 857be044cc
3 changed files with 40 additions and 25 deletions

View File

@ -18,11 +18,9 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import android.app.Activity; import android.app.Activity;
import android.app.Application;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle;
import android.os.Process; import android.os.Process;
import android.view.View; import android.view.View;
@ -40,13 +38,10 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactMarker; import com.facebook.react.bridge.ReactMarker;
import com.facebook.react.bridge.ReactMarkerConstants; import com.facebook.react.bridge.ReactMarkerConstants;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.bridge.queue.ReactQueueConfigurationSpec; import com.facebook.react.bridge.queue.ReactQueueConfigurationSpec;
import com.facebook.react.common.LifecycleState; import com.facebook.react.common.LifecycleState;
import com.facebook.react.common.ReactConstants; import com.facebook.react.common.ReactConstants;
import com.facebook.react.common.annotations.VisibleForTesting; import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.cxxbridge.Arguments;
import com.facebook.react.cxxbridge.CatalystInstanceImpl; import com.facebook.react.cxxbridge.CatalystInstanceImpl;
import com.facebook.react.cxxbridge.JSBundleLoader; import com.facebook.react.cxxbridge.JSBundleLoader;
import com.facebook.react.cxxbridge.JSCJavaScriptExecutor; import com.facebook.react.cxxbridge.JSCJavaScriptExecutor;
@ -839,12 +834,20 @@ public class ReactInstanceManager {
} }
UIManagerModule uiManagerModule = catalystInstance.getNativeModule(UIManagerModule.class); UIManagerModule uiManagerModule = catalystInstance.getNativeModule(UIManagerModule.class);
int rootTag = uiManagerModule.addMeasuredRootView(rootView); final int rootTag = uiManagerModule.addMeasuredRootView(rootView);
rootView.setRootViewTag(rootTag); rootView.setRootViewTag(rootTag);
rootView.runApplication(); rootView.runApplication();
Systrace.beginAsyncSection(
TRACE_TAG_REACT_JAVA_BRIDGE,
"pre_rootView.onAttachedToReactInstance",
rootTag);
UiThreadUtil.runOnUiThread(new Runnable() { UiThreadUtil.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
Systrace.endAsyncSection(
TRACE_TAG_REACT_JAVA_BRIDGE,
"pre_rootView.onAttachedToReactInstance",
rootTag);
rootView.onAttachedToReactInstance(); rootView.onAttachedToReactInstance();
} }
}); });

View File

@ -42,6 +42,9 @@ import com.facebook.react.uimanager.RootView;
import com.facebook.react.uimanager.SizeMonitoringFrameLayout; import com.facebook.react.uimanager.SizeMonitoringFrameLayout;
import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.systrace.Systrace;
import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
/** /**
* Default root view for catalyst apps. Provides the ability to listen for size changes so that a UI * Default root view for catalyst apps. Provides the ability to listen for size changes so that a UI
@ -267,26 +270,31 @@ public class ReactRootView extends SizeMonitoringFrameLayout implements RootView
* same rootTag, which will re-render the application from the root. * same rootTag, which will re-render the application from the root.
*/ */
/* package */ void runApplication() { /* package */ void runApplication() {
if (mReactInstanceManager == null || !mIsAttachedToInstance) { Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactRootView.runApplication");
return; try {
if (mReactInstanceManager == null || !mIsAttachedToInstance) {
return;
}
ReactContext reactContext = mReactInstanceManager.getCurrentReactContext();
if (reactContext == null) {
return;
}
CatalystInstance catalystInstance = reactContext.getCatalystInstance();
WritableNativeMap appParams = new WritableNativeMap();
appParams.putDouble("rootTag", getRootViewTag());
@Nullable Bundle appProperties = getAppProperties();
if (appProperties != null) {
appParams.putMap("initialProps", Arguments.fromBundle(appProperties));
}
String jsAppModuleName = getJSModuleName();
catalystInstance.getJSModule(AppRegistry.class).runApplication(jsAppModuleName, appParams);
} finally {
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
} }
ReactContext reactContext = mReactInstanceManager.getCurrentReactContext();
if (reactContext == null) {
return;
}
CatalystInstance catalystInstance = reactContext.getCatalystInstance();
WritableNativeMap appParams = new WritableNativeMap();
appParams.putDouble("rootTag", getRootViewTag());
@Nullable Bundle appProperties = getAppProperties();
if (appProperties != null) {
appParams.putMap("initialProps", Arguments.fromBundle(appProperties));
}
String jsAppModuleName = getJSModuleName();
catalystInstance.getJSModule(AppRegistry.class).runApplication(jsAppModuleName, appParams);
} }
/** /**

View File

@ -184,6 +184,9 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
* NB: this method is horribly not-thread-safe. * NB: this method is horribly not-thread-safe.
*/ */
public int addMeasuredRootView(final SizeMonitoringFrameLayout rootView) { public int addMeasuredRootView(final SizeMonitoringFrameLayout rootView) {
Systrace.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
"UIManagerModule.addMeasuredRootView");
final int tag = mNextRootViewTag; final int tag = mNextRootViewTag;
mNextRootViewTag += ROOT_VIEW_TAG_INCREMENT; mNextRootViewTag += ROOT_VIEW_TAG_INCREMENT;
@ -220,6 +223,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
} }
}); });
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
return tag; return tag;
} }