From d013ba39154ccd2af0a08019405411f8b27dc022 Mon Sep 17 00:00:00 2001 From: Ben Nham Date: Tue, 8 Aug 2017 10:43:13 -0700 Subject: [PATCH] add perf marker that fires first time content is added to root view Reviewed By: javache Differential Revision: D5582838 fbshipit-source-id: f90376ab11b4d44c002759829e4b2bbb4bbeeb56 --- .../com/facebook/react/ReactRootView.java | 27 ++++++++++++++++--- .../react/bridge/ReactMarkerConstants.java | 1 + 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index fb7601750..c2ca75781 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -9,7 +9,7 @@ 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.graphics.Rect; @@ -23,12 +23,13 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.WindowManager; - import com.facebook.common.logging.FLog; import com.facebook.infer.annotation.Assertions; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.CatalystInstance; 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.WritableMap; 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.events.EventDispatcher; import com.facebook.systrace.Systrace; - -import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; +import javax.annotation.Nullable; /** * 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 int mRootViewTag; private boolean mIsAttachedToInstance; + private boolean mContentAppeared; private final JSTouchDispatcher mJSTouchDispatcher = new JSTouchDispatcher(this); 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)} */ diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java index f2468f62e..e0e5a2695 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java @@ -66,4 +66,5 @@ public enum ReactMarkerConstants { PRE_RUN_JS_BUNDLE_START, ATTACH_MEASURED_ROOT_VIEWS_START, ATTACH_MEASURED_ROOT_VIEWS_END, + CONTENT_APPEARED, }