Guard activity lifecycle events with redbox
Summary: Activity lifecycle events in native modules can cause exceptions: we should redbox them like we do all other application-logic triggered exceptions. Reviewed By: AaaChiuuu Differential Revision: D4537111 fbshipit-source-id: 71abf8696173a3d647e858c4ea316a169ad2d8ef
This commit is contained in:
parent
53a7d5822b
commit
b38f345d4c
|
@ -162,7 +162,11 @@ public class ReactContext extends ContextWrapper {
|
|||
runOnUiQueueThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
listener.onHostResume();
|
||||
try {
|
||||
listener.onHostResume();
|
||||
} catch (RuntimeException e) {
|
||||
handleException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
@ -205,9 +209,12 @@ public class ReactContext extends ContextWrapper {
|
|||
UiThreadUtil.assertOnUiThread();
|
||||
mLifecycleState = LifecycleState.RESUMED;
|
||||
mCurrentActivity = new WeakReference(activity);
|
||||
mLifecycleState = LifecycleState.RESUMED;
|
||||
for (LifecycleEventListener listener : mLifecycleEventListeners) {
|
||||
listener.onHostResume();
|
||||
try {
|
||||
listener.onHostResume();
|
||||
} catch (RuntimeException e) {
|
||||
handleException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,7 +222,11 @@ public class ReactContext extends ContextWrapper {
|
|||
UiThreadUtil.assertOnUiThread();
|
||||
mCurrentActivity = new WeakReference(activity);
|
||||
for (ActivityEventListener listener : mActivityEventListeners) {
|
||||
listener.onNewIntent(intent);
|
||||
try {
|
||||
listener.onNewIntent(intent);
|
||||
} catch (RuntimeException e) {
|
||||
handleException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -226,7 +237,11 @@ public class ReactContext extends ContextWrapper {
|
|||
UiThreadUtil.assertOnUiThread();
|
||||
mLifecycleState = LifecycleState.BEFORE_RESUME;
|
||||
for (LifecycleEventListener listener : mLifecycleEventListeners) {
|
||||
listener.onHostPause();
|
||||
try {
|
||||
listener.onHostPause();
|
||||
} catch (RuntimeException e) {
|
||||
handleException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,7 +252,11 @@ public class ReactContext extends ContextWrapper {
|
|||
UiThreadUtil.assertOnUiThread();
|
||||
mLifecycleState = LifecycleState.BEFORE_CREATE;
|
||||
for (LifecycleEventListener listener : mLifecycleEventListeners) {
|
||||
listener.onHostDestroy();
|
||||
try {
|
||||
listener.onHostDestroy();
|
||||
} catch (RuntimeException e) {
|
||||
handleException(e);
|
||||
}
|
||||
}
|
||||
mCurrentActivity = null;
|
||||
}
|
||||
|
@ -258,7 +277,11 @@ public class ReactContext extends ContextWrapper {
|
|||
*/
|
||||
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
|
||||
for (ActivityEventListener listener : mActivityEventListeners) {
|
||||
listener.onActivityResult(activity, requestCode, resultCode, data);
|
||||
try {
|
||||
listener.onActivityResult(activity, requestCode, resultCode, data);
|
||||
} catch (RuntimeException e) {
|
||||
handleException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue