From a1273bb593fd41651681cb5299561dcf7cada16c Mon Sep 17 00:00:00 2001 From: Oleksandr Melnykov Date: Mon, 22 Jul 2019 02:45:50 -0700 Subject: [PATCH] Do not load JS bundle from local cache if Metro is running Summary: Having a cached JS bundle being loaded instead of loading it from Metro can cause recent changes made with Fast Refresh not to be picked up after an app is killed and started again. This diff makes a change so that we always download the bundle from Metro if it's running and only if it's not running we check if there is a cached recent bundle. Reviewed By: gaearon, davidaurelio Differential Revision: D16380243 fbshipit-source-id: b2842f718e0c21a3f4ca5ebeb3c2bae1df87a6e1 --- .../com/facebook/react/ReactInstanceManager.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index 74ce6e58533..73ff8be37ce 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -369,15 +369,6 @@ public class ReactInstanceManager { if (mUseDeveloperSupport && mJSMainModulePath != null) { final DeveloperSettings devSettings = mDevSupportManager.getDevSettings(); - // If remote JS debugging is enabled, load from dev server. - if (mDevSupportManager.hasUpToDateJSBundleInCache() - && !devSettings.isRemoteJSDebugEnabled()) { - // If there is a up-to-date bundle downloaded from server, - // with remote JS debugging disabled, always use that. - onJSBundleLoadedFromServer(null); - return; - } - if (!Systrace.isTracing(TRACE_TAG_REACT_APPS | TRACE_TAG_REACT_JS_VM_CALLS)) { if (mBundleLoader == null) { mDevSupportManager.handleReloadJS(); @@ -392,6 +383,11 @@ public class ReactInstanceManager { public void run() { if (packagerIsRunning) { mDevSupportManager.handleReloadJS(); + } else if (mDevSupportManager.hasUpToDateJSBundleInCache() + && !devSettings.isRemoteJSDebugEnabled()) { + // If there is a up-to-date bundle downloaded from server, + // with remote JS debugging disabled, always use that. + onJSBundleLoadedFromServer(null); } else { // If dev server is down, disable the remote JS debugging. devSettings.setRemoteJSDebugEnabled(false);