Add ReactRootView perf markers

Summary:
Add three markers for ReactRootView perf logging: onMeasure, attachToReactInstanceManager, and updateLayoutSpecs.

It is suspected that one or all of these have regressed under Fabric in some cases.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D24909635

fbshipit-source-id: 6b6c0cc792c4b2d72f2360d6cffc02ef00e8a88b
This commit is contained in:
Joshua Gross
2020-11-12 15:52:41 -08:00
committed by Facebook GitHub Bot
parent 68126ed470
commit f1fbfebccb
2 changed files with 18 additions and 4 deletions
@@ -122,6 +122,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactRootView.onMeasure");
ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_ON_MEASURE_START);
try {
boolean measureSpecsUpdated =
widthMeasureSpec != mWidthMeasureSpec || heightMeasureSpec != mHeightMeasureSpec;
@@ -171,6 +172,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
mLastHeight = height;
} finally {
ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_ON_MEASURE_END);
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
}
@@ -437,7 +439,9 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
*/
private void updateRootLayoutSpecs(
boolean measureSpecsChanged, final int widthMeasureSpec, final int heightMeasureSpec) {
ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_UPDATE_LAYOUT_SPECS_START);
if (mReactInstanceManager == null) {
ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_UPDATE_LAYOUT_SPECS_END);
FLog.w(TAG, "Unable to update root layout specs for uninitialized ReactInstanceManager");
return;
}
@@ -466,6 +470,8 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
mLastOffsetY = offsetY;
}
}
ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_UPDATE_LAYOUT_SPECS_END);
}
/**
@@ -623,16 +629,18 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
private void attachToReactInstanceManager() {
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "attachToReactInstanceManager");
if (mIsAttachedToInstance) {
return;
}
ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_ATTACH_TO_REACT_INSTANCE_MANAGER_START);
try {
if (mIsAttachedToInstance) {
return;
}
mIsAttachedToInstance = true;
Assertions.assertNotNull(mReactInstanceManager).attachRootView(this);
getViewTreeObserver().addOnGlobalLayoutListener(getCustomGlobalLayoutListener());
} finally {
ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_ATTACH_TO_REACT_INSTANCE_MANAGER_END);
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
}
@@ -94,6 +94,12 @@ public enum ReactMarkerConstants {
JAVASCRIPT_EXECUTOR_FACTORY_INJECT_END,
LOAD_REACT_NATIVE_SO_FILE_START,
LOAD_REACT_NATIVE_SO_FILE_END,
ROOT_VIEW_ON_MEASURE_START,
ROOT_VIEW_ON_MEASURE_END,
ROOT_VIEW_ATTACH_TO_REACT_INSTANCE_MANAGER_START,
ROOT_VIEW_ATTACH_TO_REACT_INSTANCE_MANAGER_END,
ROOT_VIEW_UPDATE_LAYOUT_SPECS_START,
ROOT_VIEW_UPDATE_LAYOUT_SPECS_END,
// Fabric-specific constants below this line
LOAD_REACT_NATIVE_FABRIC_SO_FILE_START,
LOAD_REACT_NATIVE_FABRIC_SO_FILE_END,