From 3d4889b5cf2c97bdef55912ba9bb8ac5eb9c2976 Mon Sep 17 00:00:00 2001 From: Felix Oghina Date: Tue, 15 Dec 2015 12:16:19 -0800 Subject: [PATCH] return packager URL instead of proxy URL when debugging Summary: JS relies on the URL returned by SourceCodeModule to load packager assets. Because we currently return localhost when debugging (because that's the URL Chrome uses), assets don't load when debugging. This makes it so SourceCodeModule still returns the package URL relative to the emulator / device even when debugging. public Reviewed By: astreet Differential Revision: D2759710 fb-gh-sync-id: bab6a88ef044b8b4d971381e3b23c59fa9aa2ed0 --- .../com/facebook/react/ReactInstanceManagerImpl.java | 3 ++- .../java/com/facebook/react/bridge/JSBundleLoader.java | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerImpl.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerImpl.java index e0ce3c97e..7fd366809 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerImpl.java @@ -507,7 +507,8 @@ import com.facebook.systrace.Systrace; recreateReactContextInBackground( new ProxyJavaScriptExecutor(jsExecutor), JSBundleLoader.createRemoteDebuggerBundleLoader( - mDevSupportManager.getJSBundleURLForRemoteDebugging())); + mDevSupportManager.getJSBundleURLForRemoteDebugging(), + mDevSupportManager.getSourceUrl())); } private void onJSBundleLoadedFromServer() { diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoader.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoader.java index c784cd007..90d97e17e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoader.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JSBundleLoader.java @@ -68,18 +68,22 @@ public abstract class JSBundleLoader { /** * This loader is used when proxy debugging is enabled. In that case there is no point in fetching * the bundle from device as remote executor will have to do it anyway. + * + * @param proxySourceURL the URL to load the JS bundle from in Chrome + * @param realSourceURL the URL to report as the source URL, e.g. for asset loading */ public static JSBundleLoader createRemoteDebuggerBundleLoader( - final String sourceURL) { + final String proxySourceURL, + final String realSourceURL) { return new JSBundleLoader() { @Override public void loadScript(ReactBridge bridge) { - bridge.loadScriptFromFile(null, sourceURL); + bridge.loadScriptFromFile(null, proxySourceURL); } @Override public String getSourceUrl() { - return sourceURL; + return realSourceURL; } }; }