add perf marker that fires first time content is added to root view

Reviewed By: javache

Differential Revision: D5582838

fbshipit-source-id: f90376ab11b4d44c002759829e4b2bbb4bbeeb56
This commit is contained in:
Ben Nham 2017-08-08 10:43:13 -07:00 committed by Facebook Github Bot
parent cc4de7abc4
commit d013ba3915
2 changed files with 24 additions and 4 deletions

View File

@ -9,7 +9,7 @@
package com.facebook.react; package com.facebook.react;
import javax.annotation.Nullable; import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
import android.content.Context; import android.content.Context;
import android.graphics.Rect; import android.graphics.Rect;
@ -23,12 +23,13 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.view.WindowManager; import android.view.WindowManager;
import com.facebook.common.logging.FLog; import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions; import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.CatalystInstance; import com.facebook.react.bridge.CatalystInstance;
import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactMarker;
import com.facebook.react.bridge.ReactMarkerConstants;
import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap; import com.facebook.react.bridge.WritableNativeMap;
@ -45,8 +46,7 @@ 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 com.facebook.systrace.Systrace;
import javax.annotation.Nullable;
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
@ -81,6 +81,7 @@ public class ReactRootView extends SizeMonitoringFrameLayout implements RootView
private @Nullable ReactRootViewEventListener mRootViewEventListener; private @Nullable ReactRootViewEventListener mRootViewEventListener;
private int mRootViewTag; private int mRootViewTag;
private boolean mIsAttachedToInstance; private boolean mIsAttachedToInstance;
private boolean mContentAppeared;
private final JSTouchDispatcher mJSTouchDispatcher = new JSTouchDispatcher(this); private final JSTouchDispatcher mJSTouchDispatcher = new JSTouchDispatcher(this);
public ReactRootView(Context context) { public ReactRootView(Context context) {
@ -190,6 +191,24 @@ public class ReactRootView extends SizeMonitoringFrameLayout implements RootView
} }
} }
@Override
public void onViewAdded(View child) {
super.onViewAdded(child);
if (!mContentAppeared) {
mContentAppeared = true;
ReactMarker.logMarker(
ReactMarkerConstants.CONTENT_APPEARED, getJSModuleName(), getRootViewTag());
}
}
@Override
public void removeAllViewsInLayout() {
super.removeAllViewsInLayout();
mContentAppeared = false;
}
/** /**
* {@see #startReactApplication(ReactInstanceManager, String, android.os.Bundle)} * {@see #startReactApplication(ReactInstanceManager, String, android.os.Bundle)}
*/ */

View File

@ -66,4 +66,5 @@ public enum ReactMarkerConstants {
PRE_RUN_JS_BUNDLE_START, PRE_RUN_JS_BUNDLE_START,
ATTACH_MEASURED_ROOT_VIEWS_START, ATTACH_MEASURED_ROOT_VIEWS_START,
ATTACH_MEASURED_ROOT_VIEWS_END, ATTACH_MEASURED_ROOT_VIEWS_END,
CONTENT_APPEARED,
} }