diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index 08385326d..bf0b9b5c5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -29,23 +29,23 @@ import com.facebook.infer.annotation.Assertions; import com.facebook.infer.annotation.ThreadConfined; import com.facebook.infer.annotation.ThreadSafe; import com.facebook.react.bridge.CatalystInstance; +import com.facebook.react.bridge.CatalystInstanceImpl; +import com.facebook.react.bridge.JSBundleLoader; +import com.facebook.react.bridge.JSCJavaScriptExecutor; import com.facebook.react.bridge.JavaJSExecutor; +import com.facebook.react.bridge.JavaScriptExecutor; import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.JavaScriptModuleRegistry; import com.facebook.react.bridge.NativeModuleCallExceptionHandler; +import com.facebook.react.bridge.NativeModuleRegistry; import com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener; +import com.facebook.react.bridge.ProxyJavaScriptExecutor; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactMarker; import com.facebook.react.bridge.ReactMarkerConstants; -import com.facebook.react.bridge.queue.ReactQueueConfigurationSpec; -import com.facebook.react.bridge.CatalystInstanceImpl; -import com.facebook.react.bridge.JSBundleLoader; -import com.facebook.react.bridge.JSCJavaScriptExecutor; -import com.facebook.react.bridge.JavaScriptExecutor; -import com.facebook.react.bridge.NativeModuleRegistry; -import com.facebook.react.bridge.ProxyJavaScriptExecutor; import com.facebook.react.bridge.UiThreadUtil; +import com.facebook.react.bridge.queue.ReactQueueConfigurationSpec; import com.facebook.react.common.LifecycleState; import com.facebook.react.common.ReactConstants; import com.facebook.react.common.annotations.VisibleForTesting; @@ -695,12 +695,6 @@ public class ReactInstanceManager { @ThreadConfined(UI) private void onReloadWithJSDebugger(JavaJSExecutor.Factory jsExecutorFactory) { - synchronized (mAttachedRootViews) { - for (ReactRootView reactRootView : mAttachedRootViews) { - reactRootView.removeAllViews(); - reactRootView.setId(View.NO_ID); - } - } recreateReactContextInBackground( new ProxyJavaScriptExecutor.Factory(jsExecutorFactory), JSBundleLoader.createRemoteDebuggerBundleLoader( @@ -710,12 +704,6 @@ public class ReactInstanceManager { @ThreadConfined(UI) private void onJSBundleLoadedFromServer() { - synchronized (mAttachedRootViews) { - for (ReactRootView reactRootView : mAttachedRootViews) { - reactRootView.removeAllViews(); - reactRootView.setId(View.NO_ID); - } - } recreateReactContextInBackground( new JSCJavaScriptExecutor.Factory(mJSCConfig.getConfigMap()), JSBundleLoader.createCachedBundleFromNetworkLoader( @@ -900,11 +888,14 @@ public class ReactInstanceManager { if (mLifecycleState == LifecycleState.RESUMED) { reactContext.onHostPause(); } + synchronized (mAttachedRootViews) { for (ReactRootView rootView : mAttachedRootViews) { - detachViewFromInstance(rootView, reactContext.getCatalystInstance()); + rootView.removeAllViews(); + rootView.setId(View.NO_ID); } } + reactContext.destroy(); mDevSupportManager.onReactInstanceDestroyed(reactContext); mMemoryPressureRouter.removeMemoryPressureListener(reactContext.getCatalystInstance()); diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java index a5a53b314..23dc3ed7a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java @@ -9,6 +9,9 @@ package com.facebook.react.uimanager; +import javax.annotation.Nullable; +import javax.annotation.concurrent.NotThreadSafe; + import android.content.res.Resources; import android.util.Log; import android.util.SparseArray; @@ -37,9 +40,6 @@ import com.facebook.react.uimanager.layoutanimation.LayoutAnimationListener; import com.facebook.systrace.Systrace; import com.facebook.systrace.SystraceMessage; -import javax.annotation.Nullable; -import javax.annotation.concurrent.NotThreadSafe; - /** * Delegate of {@link UIManagerModule} that owns the native view hierarchy and mapping between * native view names used in JS and corresponding instances of {@link ViewManager}. The diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java index 724a246ff..cf6ceac30 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIViewOperationQueue.java @@ -21,10 +21,10 @@ import com.facebook.react.animation.AnimationRegistry; import com.facebook.react.bridge.Callback; import com.facebook.react.bridge.GuardedRunnable; import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.SoftAssertions; import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; +import com.facebook.react.bridge.SoftAssertions; import com.facebook.react.bridge.UiThreadUtil; import com.facebook.react.common.ReactConstants; import com.facebook.react.modules.core.ReactChoreographer;