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; }