Skip to content

Commit

Permalink
[ReactAndroid] Guard against uncaught exceptions when creating LogBox…
Browse files Browse the repository at this point in the history
… window

If a native module fails to initialize and throws an exception, the Catalyst instance
may be destroyed, but LogBox will still try to initialize itself (race condition).

Test plan:
- throw an exception in one of unimodules' `onCreate`
- see the whole app crash
  • Loading branch information
sjchmiela committed May 19, 2020
1 parent 1699660 commit 8666ac5
Showing 1 changed file with 8 additions and 2 deletions.
Expand Up @@ -38,8 +38,14 @@ public LogBoxModule(ReactApplicationContext reactContext, DevSupportManager devS
@Override
public void run() {
if (mReactRootView == null) {
mReactRootView = mDevSupportManager.createRootView("LogBox");
if (mReactRootView == null) {
try {
mReactRootView = mDevSupportManager.createRootView("LogBox");
if (mReactRootView == null) {
FLog.e(
ReactConstants.TAG,
"Unable to launch logbox because react was unable to create the root view");
}
} catch (RuntimeException e) {
FLog.e(
ReactConstants.TAG,
"Unable to launch logbox because react was unable to create the root view");
Expand Down

0 comments on commit 8666ac5

Please sign in to comment.