mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Show RedBox for C++ errors
Summary: This diff is hooking up cxx error with redbox. Before this diff, cxx errors were only shown in log and there was no visible user feedback. Changelog: [Android] [Added] - Show Redbox for C++ errors. Reviewed By: JoshuaGross Differential Revision: D30421355 fbshipit-source-id: ad473337ba301feb08ba31ee8d82ebaa771ecaeb
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4a9621647c
commit
d6c879edba
@@ -65,6 +65,7 @@ import com.facebook.react.bridge.NotThreadSafeBridgeIdleDebugListener;
|
||||
import com.facebook.react.bridge.ProxyJavaScriptExecutor;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.ReactCxxErrorHandler;
|
||||
import com.facebook.react.bridge.ReactMarker;
|
||||
import com.facebook.react.bridge.ReactMarkerConstants;
|
||||
import com.facebook.react.bridge.ReactNoCrashSoftException;
|
||||
@@ -107,6 +108,7 @@ import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
import com.facebook.systrace.Systrace;
|
||||
import com.facebook.systrace.SystraceMessage;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -291,6 +293,8 @@ public class ReactInstanceManager {
|
||||
if (mUseDeveloperSupport) {
|
||||
mDevSupportManager.startInspector();
|
||||
}
|
||||
|
||||
registerCxxErrorHandlerFunc();
|
||||
}
|
||||
|
||||
private ReactInstanceDevHelper createDevHelperInterface() {
|
||||
@@ -364,6 +368,22 @@ public class ReactInstanceManager {
|
||||
return new ArrayList<>(mPackages);
|
||||
}
|
||||
|
||||
public void handleCxxError(Exception e) {
|
||||
mDevSupportManager.handleException(e);
|
||||
}
|
||||
|
||||
public void registerCxxErrorHandlerFunc() {
|
||||
Class[] parameterTypes = new Class[1];
|
||||
parameterTypes[0] = Exception.class;
|
||||
Method handleCxxErrorFunc = null;
|
||||
try {
|
||||
handleCxxErrorFunc = ReactInstanceManager.class.getMethod("handleCxxError", parameterTypes);
|
||||
} catch (NoSuchMethodException e) {
|
||||
FLog.e("ReactInstanceHolder", "Failed to set cxx error hanlder function", e);
|
||||
}
|
||||
ReactCxxErrorHandler.setHandleErrorFunc(this, handleCxxErrorFunc);
|
||||
}
|
||||
|
||||
static void initializeSoLoaderIfNecessary(Context applicationContext) {
|
||||
// Call SoLoader.initialize here, this is required for apps that does not use exopackage and
|
||||
// does not use SoLoader for loading other native code except from the one used by React Native
|
||||
|
||||
Reference in New Issue
Block a user