Skip to content

Commit 65d3167

Browse files
mhorowitzfacebook-github-bot
authored andcommitted
If JSC fails to load when starting RN, expose that error to the caller
Summary: See the comments for more info. Changelog: [Android] [Changed] - Improve exception message when JSC loading fails Reviewed By: tmikov Differential Revision: D19917034 fbshipit-source-id: d846f542c31e9c94edcee240c2935d77d48d1f2a
1 parent ef021ea commit 65d3167

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java

+27-1
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,34 @@ private JavaScriptExecutorFactory getDefaultJSExecutorFactory(
297297
SoLoader.loadLibrary("jscexecutor");
298298
return new JSCExecutorFactory(appName, deviceName);
299299
} catch (UnsatisfiedLinkError jscE) {
300+
// https://github.com/facebook/hermes/issues/78 shows that
301+
// people who aren't trying to use Hermes are having issues.
302+
// https://github.com/facebook/react-native/issues/25923#issuecomment-554295179
303+
// includes the actual JSC error in at least one case.
304+
//
305+
// So, if "__cxa_bad_typeid" shows up in the jscE exception
306+
// message, then we will assume that's the failure and just
307+
// throw now.
308+
309+
if (jscE.getMessage().contains("__cxa_bad_typeid")) {
310+
throw jscE;
311+
}
312+
300313
// Otherwise use Hermes
301-
return new HermesExecutorFactory();
314+
try {
315+
return new HermesExecutorFactory();
316+
} catch (UnsatisfiedLinkError hermesE) {
317+
// If we get here, either this is a JSC build, and of course
318+
// Hermes failed (since it's not in the APK), or it's a Hermes
319+
// build, and Hermes had a problem.
320+
321+
// We suspect this is a JSC issue (it's the default), so we
322+
// will throw that exception, but we will print hermesE first,
323+
// since it could be a Hermes issue and we don't want to
324+
// swallow that.
325+
hermesE.printStackTrace();
326+
throw jscE;
327+
}
302328
}
303329
}
304330
}

0 commit comments

Comments
 (0)