forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Removing JavaScript error handler supplied to ReactHostImpl.java which is just a stub and creating a default handler in ReactInstance.java. Changelog: [Internal] - Provide default error handler that can handle early JavaScript error **Motivation** When app bundle is being loading and before JavaScript side error handling logic is executed, error that occur in between may be lost or not reported. Native code does have various `try/catch` statements to catch errors but in Android the error handler callback is implemented to be passed in while instantiating `ReactHostImpl` where many cases, including OSS, are just stub implementation that does not do anything. __The goal of this diff is to add a default error handler that can be used by both OSS and intern.__ When the JavaScript side error handling is fully setup any JavaScript error is routed to LogBox. For early errors, we want to utilize the native RedBox to display errors. Longer term goal is to have a single native pipeline but this diff is just to cover the early JS errors until this is realized. **Implementation details** The code changes were taken from previously abandoned diff by RSNara (D55439412). - **Previous** - `ReactJsExceptionHandler` (often just a stub) is created in Java and passed into `ReactHostImpl`. - **Updated** - `DefaultReactJsExceptionHandler` defined in `ReactInstance.java` is instantiated and passed into JNI/C++ via `initHybrid()` call. - `ReactJsExceptionHandler.reportJsException()` method is removed from `FbReactExceptionManager` as we are not using the default implementation above. **Related questions** ThreadQueue in Java uses a separate error handler. Question is if there a good reason for having a separate error handler of if we can combine this into a single error handler. Also since ThreadQueues are implemented in Java, there is a question of supporting the error handling via native C++ would be feasible or desirable. **Testing** You use the following preview diff to `throw Error` before error handling code is run during JavaScript bundle setup. It also includes Android log to check the method was called. `jf get --version 229685487` Testing was done using `fb4a` and `rntester-android`. **Note on inconsistent exception message in `rntester-android`**. Currently the only the first exception is displayed in RedBox and rest are ignored. Depending on the timing, early js exception is reported or `SurfaceRegistryBinding::startSurface()` is shown. This seems to be more related to clean up when `ReactInstance.loadJSScript()` throws and is not covered in this diff. Differential Revision: D58385767
- Loading branch information
1 parent
8a15e0d
commit 039fb64
Showing
5 changed files
with
53 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters