From b69041f086ac6dc0f79ea9fd6188556968f2c9d2 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Mon, 15 Jun 2020 18:41:22 -0700 Subject: [PATCH] Feature-flag gate stopSurface on root view unmount Summary: Gate stopSurface behind a feature flag. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D22054480 fbshipit-source-id: 3ea48ab46aeb3532fc7a3dd83659d7c32891ec06 --- .../src/main/java/com/facebook/react/ReactRootView.java | 4 +++- .../java/com/facebook/react/config/ReactFeatureFlags.java | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index 2aee3b7b493..43d91482f1a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -39,6 +39,7 @@ import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableNativeMap; import com.facebook.react.common.annotations.VisibleForTesting; +import com.facebook.react.config.ReactFeatureFlags; import com.facebook.react.modules.appregistry.AppRegistry; import com.facebook.react.modules.core.DeviceEventManagerModule; import com.facebook.react.modules.deviceinfo.DeviceInfoModule; @@ -437,13 +438,14 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot { // to be committed via the Scheduler, which will cause mounting instructions // to be queued up and synchronously executed to delete and remove // all the views in the hierarchy. - if (mReactInstanceManager != null) { + if (mReactInstanceManager != null && ReactFeatureFlags.enableStopSurfaceOnRootViewUnmount) { final ReactContext reactApplicationContext = mReactInstanceManager.getCurrentReactContext(); if (reactApplicationContext != null && getUIManagerType() == FABRIC) { @Nullable UIManager uiManager = UIManagerHelper.getUIManager(reactApplicationContext, getUIManagerType()); if (uiManager != null) { + FLog.e(TAG, "stopSurface for surfaceId: " + this.getId()); uiManager.stopSurface(this.getId()); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index 26025c3b4aa..3cda1544d14 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -89,4 +89,7 @@ public class ReactFeatureFlags { /** Feature flag to have FabricUIManager teardown stop all active surfaces. */ public static boolean enableFabricStopAllSurfacesOnTeardown = false; + + /** Feature flag to use stopSurface when ReactRootView is unmounted. */ + public static boolean enableStopSurfaceOnRootViewUnmount = false; }