mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Destroy React Native instance after catching a fatal js error
Summary: As title, destroy React Native instance after catching a fatal js error to avoid incoming calls into JS. Changelog: [Android][Changed] - Rename NativeModuleCallExceptionHandler to JSExceptionHandler for broader usage Reviewed By: fkgozali Differential Revision: D37379340 fbshipit-source-id: 465a30bc824a264b45df3e8b0b24edd61c4b571d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ca8481bd7d
commit
b6f7689d70
@@ -93,7 +93,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
|
||||
private final NativeModuleRegistry mNativeModuleRegistry;
|
||||
private final JSIModuleRegistry mJSIModuleRegistry = new JSIModuleRegistry();
|
||||
private final NativeModuleCallExceptionHandler mNativeModuleCallExceptionHandler;
|
||||
private final JSExceptionHandler mJSExceptionHandler;
|
||||
private final MessageQueueThread mNativeModulesQueueThread;
|
||||
private boolean mInitialized = false;
|
||||
private volatile boolean mAcceptCalls = false;
|
||||
@@ -120,7 +120,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
final JavaScriptExecutor jsExecutor,
|
||||
final NativeModuleRegistry nativeModuleRegistry,
|
||||
final JSBundleLoader jsBundleLoader,
|
||||
NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler) {
|
||||
JSExceptionHandler jSExceptionHandler) {
|
||||
FLog.d(ReactConstants.TAG, "Initializing React Xplat Bridge.");
|
||||
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createCatalystInstanceImpl");
|
||||
|
||||
@@ -141,7 +141,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
mNativeModuleRegistry = nativeModuleRegistry;
|
||||
mJSModuleRegistry = new JavaScriptModuleRegistry();
|
||||
mJSBundleLoader = jsBundleLoader;
|
||||
mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
|
||||
mJSExceptionHandler = jSExceptionHandler;
|
||||
mNativeModulesQueueThread = mReactQueueConfiguration.getNativeModulesQueueThread();
|
||||
mTraceListener = new JSProfilerTraceListener(this);
|
||||
Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||
@@ -626,7 +626,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
}
|
||||
|
||||
private void onNativeException(Exception e) {
|
||||
mNativeModuleCallExceptionHandler.handleException(e);
|
||||
mJSExceptionHandler.handleException(e);
|
||||
mReactQueueConfiguration
|
||||
.getUIQueueThread()
|
||||
.runOnQueue(
|
||||
@@ -682,7 +682,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
private @Nullable JSBundleLoader mJSBundleLoader;
|
||||
private @Nullable NativeModuleRegistry mRegistry;
|
||||
private @Nullable JavaScriptExecutor mJSExecutor;
|
||||
private @Nullable NativeModuleCallExceptionHandler mNativeModuleCallExceptionHandler;
|
||||
private @Nullable JSExceptionHandler mJSExceptionHandler;
|
||||
|
||||
public Builder setReactQueueConfigurationSpec(
|
||||
ReactQueueConfigurationSpec ReactQueueConfigurationSpec) {
|
||||
@@ -705,8 +705,8 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setNativeModuleCallExceptionHandler(NativeModuleCallExceptionHandler handler) {
|
||||
mNativeModuleCallExceptionHandler = handler;
|
||||
public Builder setJSExceptionHandler(JSExceptionHandler handler) {
|
||||
mJSExceptionHandler = handler;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -716,7 +716,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
Assertions.assertNotNull(mJSExecutor),
|
||||
Assertions.assertNotNull(mRegistry),
|
||||
Assertions.assertNotNull(mJSBundleLoader),
|
||||
Assertions.assertNotNull(mNativeModuleCallExceptionHandler));
|
||||
Assertions.assertNotNull(mJSExceptionHandler));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user