From 735be8b24d01db119a422a293eb0775f083f3400 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Fri, 17 Aug 2018 23:05:23 -0700 Subject: [PATCH] RN: Support Cached Bundles in Systrace Summary: When running Systrace, we currently only surface the JavaScript bundle that is pre-packaged in the binary. This changes `ReactInstanceManager` so that we prefer a cached bundle if one exists. This allows running Systrace with local changes (as long as you load them into the client before running Systrace). Differential Revision: D9389704 fbshipit-source-id: 031321b2e07539efc7f47a7c6947ab7b82dc7dfc --- .../facebook/react/ReactInstanceManager.java | 55 ++++++++++--------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index 57462676b42..1783102518e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -350,9 +350,7 @@ public class ReactInstanceManager { .logMessage(ReactDebugOverlayTags.RN_CORE, "RNCore: recreateReactContextInBackground"); UiThreadUtil.assertOnUiThread(); - if (mUseDeveloperSupport - && mJSMainModulePath != null - && !Systrace.isTracing(TRACE_TAG_REACT_APPS | TRACE_TAG_REACT_JS_VM_CALLS)) { + if (mUseDeveloperSupport && mJSMainModulePath != null) { final DeveloperSettings devSettings = mDevSupportManager.getDevSettings(); // If remote JS debugging is enabled, load from dev server. @@ -361,30 +359,35 @@ public class ReactInstanceManager { // If there is a up-to-date bundle downloaded from server, // with remote JS debugging disabled, always use that. onJSBundleLoadedFromServer(null); - } else if (mBundleLoader == null) { - mDevSupportManager.handleReloadJS(); - } else { - mDevSupportManager.isPackagerRunning( - new PackagerStatusCallback() { - @Override - public void onPackagerStatusFetched(final boolean packagerIsRunning) { - UiThreadUtil.runOnUiThread( - new Runnable() { - @Override - public void run() { - if (packagerIsRunning) { - mDevSupportManager.handleReloadJS(); - } else { - // If dev server is down, disable the remote JS debugging. - devSettings.setRemoteJSDebugEnabled(false); - recreateReactContextInBackgroundFromBundleLoader(); - } - } - }); - } - }); + return; + } + + if (!Systrace.isTracing(TRACE_TAG_REACT_APPS | TRACE_TAG_REACT_JS_VM_CALLS)) { + if (mBundleLoader == null) { + mDevSupportManager.handleReloadJS(); + } else { + mDevSupportManager.isPackagerRunning( + new PackagerStatusCallback() { + @Override + public void onPackagerStatusFetched(final boolean packagerIsRunning) { + UiThreadUtil.runOnUiThread( + new Runnable() { + @Override + public void run() { + if (packagerIsRunning) { + mDevSupportManager.handleReloadJS(); + } else { + // If dev server is down, disable the remote JS debugging. + devSettings.setRemoteJSDebugEnabled(false); + recreateReactContextInBackgroundFromBundleLoader(); + } + } + }); + } + }); + } + return; } - return; } recreateReactContextInBackgroundFromBundleLoader();