Skip to content

Commit

Permalink
add perf marker that fires first time content is added to root view
Browse files Browse the repository at this point in the history
Reviewed By: javache

Differential Revision: D5582838

fbshipit-source-id: f90376ab11b4d44c002759829e4b2bbb4bbeeb56
  • Loading branch information
bnham authored and facebook-github-bot committed Aug 8, 2017
1 parent cc4de7a commit d013ba3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
27 changes: 23 additions & 4 deletions ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,12 +23,13 @@
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;
Expand All @@ -45,8 +46,7 @@
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
Expand Down Expand Up @@ -81,6 +81,7 @@ public interface ReactRootViewEventListener {
private @Nullable ReactRootViewEventListener mRootViewEventListener;
private int mRootViewTag;
private boolean mIsAttachedToInstance;
private boolean mContentAppeared;
private final JSTouchDispatcher mJSTouchDispatcher = new JSTouchDispatcher(this);

public ReactRootView(Context context) {
Expand Down Expand Up @@ -190,6 +191,24 @@ protected void onDetachedFromWindow() {
}
}

@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)}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,5 @@ public enum ReactMarkerConstants {
PRE_RUN_JS_BUNDLE_START,
ATTACH_MEASURED_ROOT_VIEWS_START,
ATTACH_MEASURED_ROOT_VIEWS_END,
CONTENT_APPEARED,
}

0 comments on commit d013ba3

Please sign in to comment.