mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix the redbox when running Metro with Venice enabled.
Summary: 1, Fix the redbox on Pokes route when running Metro with Venice enabled. 2, Fix CrashReactRoute stucking with the loading indicator issue. Changelog: [Internal] Reviewed By: ejanzer Differential Revision: D22477500 fbshipit-source-id: 65e908ac360e031e5f3562a21c09cb0d7ddaf7a0
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7485e93807
commit
9b8ffeee4c
+35
-7
@@ -70,6 +70,12 @@ import java.util.concurrent.TimeoutException;
|
||||
public abstract class DevSupportManagerBase
|
||||
implements DevSupportManager, PackagerCommandListener, DevInternalSettings.Listener {
|
||||
|
||||
public interface CallbackWithBundleLoader {
|
||||
void onSuccess(JSBundleLoader bundleLoader);
|
||||
|
||||
void onError(String url, Throwable cause);
|
||||
}
|
||||
|
||||
private static final int JAVA_ERROR_COOKIE = -1;
|
||||
private static final int JSEXCEPTION_ERROR_COOKIE = -1;
|
||||
private static final String JS_BUNDLE_FILE_NAME = "ReactNativeDevBundle.js";
|
||||
@@ -863,7 +869,29 @@ public abstract class DevSupportManagerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadSplitBundleFromServer(String bundlePath, final DevSplitBundleCallback callback) {
|
||||
public void loadSplitBundleFromServer(
|
||||
final String bundlePath, final DevSplitBundleCallback callback) {
|
||||
fetchSplitBundleAndCreateBundleLoader(
|
||||
bundlePath,
|
||||
new CallbackWithBundleLoader() {
|
||||
@Override
|
||||
public void onSuccess(JSBundleLoader bundleLoader) {
|
||||
bundleLoader.loadScript(mCurrentContext.getCatalystInstance());
|
||||
mCurrentContext
|
||||
.getJSModule(HMRClient.class)
|
||||
.registerBundle(mDevServerHelper.getDevServerSplitBundleURL(bundlePath));
|
||||
callback.onSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String url, Throwable cause) {
|
||||
callback.onError(url, cause);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void fetchSplitBundleAndCreateBundleLoader(
|
||||
String bundlePath, final CallbackWithBundleLoader callback) {
|
||||
final String bundleUrl = mDevServerHelper.getDevServerSplitBundleURL(bundlePath);
|
||||
// The bundle path may contain the '/' character, which is not allowed in file names.
|
||||
final File bundleFile =
|
||||
@@ -886,16 +914,16 @@ public abstract class DevSupportManagerBase
|
||||
});
|
||||
|
||||
@Nullable ReactContext context = mCurrentContext;
|
||||
if (context == null || !context.hasActiveCatalystInstance()) {
|
||||
if (context == null
|
||||
|| (!context.isBridgeless() && !context.hasActiveCatalystInstance())) {
|
||||
return;
|
||||
}
|
||||
|
||||
JSBundleLoader.createCachedSplitBundleFromNetworkLoader(
|
||||
bundleUrl, bundleFile.getAbsolutePath())
|
||||
.loadScript(context.getCatalystInstance());
|
||||
context.getJSModule(HMRClient.class).registerBundle(bundleUrl);
|
||||
JSBundleLoader bundleLoader =
|
||||
JSBundleLoader.createCachedSplitBundleFromNetworkLoader(
|
||||
bundleUrl, bundleFile.getAbsolutePath());
|
||||
|
||||
callback.onSuccess();
|
||||
callback.onSuccess(bundleLoader);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user