Skip to content
Permalink
Browse files

Fix crash when reloading with Perf Monitor enabled

Reviewed By: mdvacca

Differential Revision: D7678392

fbshipit-source-id: 5fcf3bda545896f48543a95d4885c6492fac961e
  • Loading branch information...
ayc1 authored and facebook-github-bot committed Apr 19, 2018
1 parent b92b38a commit 4fcd9970bd2dfb24890bc87e9c82e16dab71ec09
Showing with 25 additions and 19 deletions.
  1. +25 −19 ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugOverlayController.java
@@ -21,6 +21,7 @@

import com.facebook.common.logging.FLog;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.common.ReactConstants;

import javax.annotation.Nullable;
@@ -94,25 +95,30 @@ public DebugOverlayController(ReactContext reactContext) {
mWindowManager = (WindowManager) reactContext.getSystemService(Context.WINDOW_SERVICE);
}

public void setFpsDebugViewVisible(boolean fpsDebugViewVisible) {
if (fpsDebugViewVisible && mFPSDebugViewContainer == null) {
if (!permissionCheck(mReactContext)) {
FLog.d(ReactConstants.TAG, "Wait for overlay permission to be set");
return;
}
mFPSDebugViewContainer = new FpsView(mReactContext);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowOverlayCompat.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
public void setFpsDebugViewVisible(final boolean fpsDebugViewVisible) {
UiThreadUtil.runOnUiThread(new Runnable() {
@Override
public void run() {
if (fpsDebugViewVisible && mFPSDebugViewContainer == null) {
if (!permissionCheck(mReactContext)) {
FLog.d(ReactConstants.TAG, "Wait for overlay permission to be set");
return;
}
mFPSDebugViewContainer = new FpsView(mReactContext);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowOverlayCompat.TYPE_SYSTEM_OVERLAY,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
PixelFormat.TRANSLUCENT);
mWindowManager.addView(mFPSDebugViewContainer, params);
} else if (!fpsDebugViewVisible && mFPSDebugViewContainer != null) {
mFPSDebugViewContainer.removeAllViews();
mWindowManager.removeView(mFPSDebugViewContainer);
mFPSDebugViewContainer = null;
}
PixelFormat.TRANSLUCENT);
mWindowManager.addView(mFPSDebugViewContainer, params);
} else if (!fpsDebugViewVisible && mFPSDebugViewContainer != null) {
mFPSDebugViewContainer.removeAllViews();
mWindowManager.removeView(mFPSDebugViewContainer);
mFPSDebugViewContainer = null;
}
}
});
}
}

0 comments on commit 4fcd997

Please sign in to comment.
You can’t perform that action at this time.