RedBoxDialogSurfaceDelegate crash fix (#47249)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47249

- It is likely that Dialog is being dismissed from an invalid state causing an exception
- apply similar changes from D63712422 which is to add try/catch around and ignore the exception as we are dismissing the dialog anyway

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D65066186

fbshipit-source-id: 03ebbc3fec3adf6100e36ea38b43f410d98a5297
This commit is contained in:
Alan Lee
2024-10-29 11:19:02 -07:00
committed by Facebook GitHub Bot
parent c19fd11ccf
commit 97622a5caa
@@ -144,7 +144,12 @@ class RedBoxDialogSurfaceDelegate implements SurfaceDelegate {
public void hide() {
// dismiss redbox if exists
if (mDialog != null) {
mDialog.dismiss();
try {
mDialog.dismiss();
} catch (IllegalArgumentException e) {
FLog.e(
ReactConstants.TAG, "RedBoxDialogSurfaceDelegate: error while dismissing dialog: ", e);
}
destroyContentView();
mDialog = null;
}