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
This commit is contained in:
Tim Yung
2018-08-17 23:05:23 -07:00
committed by Facebook Github Bot
parent b9c28c236b
commit 735be8b24d

View File

@@ -350,9 +350,7 @@ public class ReactInstanceManager {
.logMessage(ReactDebugOverlayTags.RN_CORE, "RNCore: recreateReactContextInBackground"); .logMessage(ReactDebugOverlayTags.RN_CORE, "RNCore: recreateReactContextInBackground");
UiThreadUtil.assertOnUiThread(); UiThreadUtil.assertOnUiThread();
if (mUseDeveloperSupport if (mUseDeveloperSupport && mJSMainModulePath != null) {
&& mJSMainModulePath != null
&& !Systrace.isTracing(TRACE_TAG_REACT_APPS | TRACE_TAG_REACT_JS_VM_CALLS)) {
final DeveloperSettings devSettings = mDevSupportManager.getDevSettings(); final DeveloperSettings devSettings = mDevSupportManager.getDevSettings();
// If remote JS debugging is enabled, load from dev server. // 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, // If there is a up-to-date bundle downloaded from server,
// with remote JS debugging disabled, always use that. // with remote JS debugging disabled, always use that.
onJSBundleLoadedFromServer(null); onJSBundleLoadedFromServer(null);
} else if (mBundleLoader == null) { return;
mDevSupportManager.handleReloadJS(); }
} else {
mDevSupportManager.isPackagerRunning( if (!Systrace.isTracing(TRACE_TAG_REACT_APPS | TRACE_TAG_REACT_JS_VM_CALLS)) {
new PackagerStatusCallback() { if (mBundleLoader == null) {
@Override mDevSupportManager.handleReloadJS();
public void onPackagerStatusFetched(final boolean packagerIsRunning) { } else {
UiThreadUtil.runOnUiThread( mDevSupportManager.isPackagerRunning(
new Runnable() { new PackagerStatusCallback() {
@Override @Override
public void run() { public void onPackagerStatusFetched(final boolean packagerIsRunning) {
if (packagerIsRunning) { UiThreadUtil.runOnUiThread(
mDevSupportManager.handleReloadJS(); new Runnable() {
} else { @Override
// If dev server is down, disable the remote JS debugging. public void run() {
devSettings.setRemoteJSDebugEnabled(false); if (packagerIsRunning) {
recreateReactContextInBackgroundFromBundleLoader(); mDevSupportManager.handleReloadJS();
} } else {
} // If dev server is down, disable the remote JS debugging.
}); devSettings.setRemoteJSDebugEnabled(false);
} recreateReactContextInBackgroundFromBundleLoader();
}); }
}
});
}
});
}
return;
} }
return;
} }
recreateReactContextInBackgroundFromBundleLoader(); recreateReactContextInBackgroundFromBundleLoader();