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:
Lulu Wu
2022-06-28 15:24:13 -07:00
committed by Facebook GitHub Bot
parent ca8481bd7d
commit b6f7689d70
19 changed files with 76 additions and 85 deletions
@@ -31,7 +31,7 @@ import androidx.annotation.UiThread;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.R;
import com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler;
import com.facebook.react.bridge.DefaultJSExceptionHandler;
import com.facebook.react.bridge.JSBundleLoader;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactMarker;
@@ -94,7 +94,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
private final @Nullable String mJSAppBundleName;
private final File mJSBundleDownloadedFile;
private final File mJSSplitBundlesDir;
private final DefaultNativeModuleCallExceptionHandler mDefaultNativeModuleCallExceptionHandler;
private final DefaultJSExceptionHandler mDefaultJSExceptionHandler;
private final DevLoadingViewController mDevLoadingViewController;
private @Nullable SurfaceDelegate mRedBoxSurfaceDelegate;
@@ -201,7 +201,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
final String splitBundlesDir = subclassTag.toLowerCase(Locale.ROOT) + "_dev_js_split_bundles";
mJSSplitBundlesDir = mApplicationContext.getDir(splitBundlesDir, Context.MODE_PRIVATE);
mDefaultNativeModuleCallExceptionHandler = new DefaultNativeModuleCallExceptionHandler();
mDefaultJSExceptionHandler = new DefaultJSExceptionHandler();
setDevSupportEnabled(enableOnCreate);
@@ -217,7 +217,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
if (mIsDevSupportEnabled) {
logJSException(e);
} else {
mDefaultNativeModuleCallExceptionHandler.handleException(e);
mDefaultJSExceptionHandler.handleException(e);
}
}
@@ -11,7 +11,7 @@ import android.app.Activity;
import android.util.Pair;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler;
import com.facebook.react.bridge.DefaultJSExceptionHandler;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.common.SurfaceDelegate;
@@ -33,10 +33,10 @@ import java.io.File;
*/
public class DisabledDevSupportManager implements DevSupportManager {
private final DefaultNativeModuleCallExceptionHandler mDefaultNativeModuleCallExceptionHandler;
private final DefaultJSExceptionHandler mDefaultJSExceptionHandler;
public DisabledDevSupportManager() {
mDefaultNativeModuleCallExceptionHandler = new DefaultNativeModuleCallExceptionHandler();
mDefaultJSExceptionHandler = new DefaultJSExceptionHandler();
}
@Override
@@ -192,7 +192,7 @@ public class DisabledDevSupportManager implements DevSupportManager {
@Override
public void handleException(Exception e) {
mDefaultNativeModuleCallExceptionHandler.handleException(e);
mDefaultJSExceptionHandler.handleException(e);
}
@Override
@@ -11,7 +11,7 @@ import android.app.Activity;
import android.util.Pair;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.NativeModuleCallExceptionHandler;
import com.facebook.react.bridge.JSExceptionHandler;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.common.SurfaceDelegate;
@@ -23,7 +23,7 @@ import java.io.File;
* implementation {@link BridgeDevSupportManager}. In production mode, use the dummy implementation
* {@link DisabledDevSupportManager}.
*/
public interface DevSupportManager extends NativeModuleCallExceptionHandler {
public interface DevSupportManager extends JSExceptionHandler {
void showNewJavaError(String message, Throwable e);