|
65 | 65 | import com.facebook.react.bridge.ProxyJavaScriptExecutor;
|
66 | 66 | import com.facebook.react.bridge.ReactApplicationContext;
|
67 | 67 | import com.facebook.react.bridge.ReactContext;
|
| 68 | +import com.facebook.react.bridge.ReactCxxErrorHandler; |
68 | 69 | import com.facebook.react.bridge.ReactMarker;
|
69 | 70 | import com.facebook.react.bridge.ReactMarkerConstants;
|
70 | 71 | import com.facebook.react.bridge.ReactNoCrashSoftException;
|
|
107 | 108 | import com.facebook.soloader.SoLoader;
|
108 | 109 | import com.facebook.systrace.Systrace;
|
109 | 110 | import com.facebook.systrace.SystraceMessage;
|
| 111 | +import java.lang.reflect.Method; |
110 | 112 | import java.util.ArrayList;
|
111 | 113 | import java.util.Collection;
|
112 | 114 | import java.util.Collections;
|
@@ -291,6 +293,8 @@ public void invokeDefaultOnBackPressed() {
|
291 | 293 | if (mUseDeveloperSupport) {
|
292 | 294 | mDevSupportManager.startInspector();
|
293 | 295 | }
|
| 296 | + |
| 297 | + registerCxxErrorHandlerFunc(); |
294 | 298 | }
|
295 | 299 |
|
296 | 300 | private ReactInstanceDevHelper createDevHelperInterface() {
|
@@ -364,6 +368,22 @@ public List<ReactPackage> getPackages() {
|
364 | 368 | return new ArrayList<>(mPackages);
|
365 | 369 | }
|
366 | 370 |
|
| 371 | + public void handleCxxError(Exception e) { |
| 372 | + mDevSupportManager.handleException(e); |
| 373 | + } |
| 374 | + |
| 375 | + public void registerCxxErrorHandlerFunc() { |
| 376 | + Class[] parameterTypes = new Class[1]; |
| 377 | + parameterTypes[0] = Exception.class; |
| 378 | + Method handleCxxErrorFunc = null; |
| 379 | + try { |
| 380 | + handleCxxErrorFunc = ReactInstanceManager.class.getMethod("handleCxxError", parameterTypes); |
| 381 | + } catch (NoSuchMethodException e) { |
| 382 | + FLog.e("ReactInstanceHolder", "Failed to set cxx error hanlder function", e); |
| 383 | + } |
| 384 | + ReactCxxErrorHandler.setHandleErrorFunc(this, handleCxxErrorFunc); |
| 385 | + } |
| 386 | + |
367 | 387 | static void initializeSoLoaderIfNecessary(Context applicationContext) {
|
368 | 388 | // Call SoLoader.initialize here, this is required for apps that does not use exopackage and
|
369 | 389 | // does not use SoLoader for loading other native code except from the one used by React Native
|
|
0 commit comments