From 091878a61ab124b1838492257e1d328516acd8a1 Mon Sep 17 00:00:00 2001 From: Ben Nham Date: Tue, 15 Aug 2017 10:45:23 -0700 Subject: [PATCH] fix content appeared logging Reviewed By: AaaChiuuu Differential Revision: D5630723 fbshipit-source-id: 3791537afdb7ca4992c2562577466c2ef5baafce --- .../com/facebook/react/ReactRootView.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index 0822f86baf9..1aea191d14b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -81,7 +81,7 @@ public class ReactRootView extends SizeMonitoringFrameLayout implements RootView private @Nullable ReactRootViewEventListener mRootViewEventListener; private int mRootViewTag = ReactRootViewTagGenerator.getNextRootViewTag(); private boolean mIsAttachedToInstance; - private boolean mContentAppeared; + private boolean mShouldLogContentAppeared; private final JSTouchDispatcher mJSTouchDispatcher = new JSTouchDispatcher(this); public ReactRootView(Context context) { @@ -195,20 +195,15 @@ public class ReactRootView extends SizeMonitoringFrameLayout implements RootView public void onViewAdded(View child) { super.onViewAdded(child); - if (!mContentAppeared) { - mContentAppeared = true; - ReactMarker.logMarker( - ReactMarkerConstants.CONTENT_APPEARED, getJSModuleName(), getRootViewTag()); + if (mShouldLogContentAppeared) { + mShouldLogContentAppeared = false; + + if (mJSModuleName != null) { + ReactMarker.logMarker(ReactMarkerConstants.CONTENT_APPEARED, mJSModuleName, mRootViewTag); + } } } - @Override - public void removeAllViewsInLayout() { - super.removeAllViewsInLayout(); - - mContentAppeared = false; - } - /** * {@see #startReactApplication(ReactInstanceManager, String, android.os.Bundle)} */ @@ -240,6 +235,7 @@ public class ReactRootView extends SizeMonitoringFrameLayout implements RootView mReactInstanceManager = reactInstanceManager; mJSModuleName = moduleName; mAppProperties = initialProperties; + mShouldLogContentAppeared = true; if (!mReactInstanceManager.hasStartedCreatingInitialContext()) { mReactInstanceManager.createReactContextInBackground(); @@ -263,6 +259,7 @@ public class ReactRootView extends SizeMonitoringFrameLayout implements RootView mIsAttachedToInstance = false; mRootViewTag = ReactRootViewTagGenerator.getNextRootViewTag(); } + mShouldLogContentAppeared = true; } public void onAttachedToReactInstance() {