react-native-webview: [iOS] JS confirm causes a native crash

Bug description:

Out of the blue, using confirm("test") in a webview will raise the following native exception:

2020-08-21 12:36:59.614662-0300 zinspector3[4620:1558927] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Completion handler passed to -[RNCWebView webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:] was not called'
*** First throw call stack:
(0x189435654 0x189157bcc 0x18932ba58 0x190ac0674 0x190b3a24c 0x190bb8ec8 0x189023a4c 0x102972b30 0x189023a4c 0x18cb11afc 0x18cb0fca8 0x18917404c 0x189173f44 0x1982c844c 0x1982f5d7c 0x1893b3ad8 0x1893b3a30 0x1893b31b8 0x1893ae1e8 0x1893adba8 0x19351d344 0x18d4e93e4 0x1029706e8 0x1892358f0)
libc++abi.dylib: terminating with uncaught exception of type NSException

I have downgraded to 10.4.0 and the issue does not happen, I suspect the following PRs may have introduced the bug since it happens with 10.4.1 and 10.4.2, up until 10.7.0: https://github.com/react-native-community/react-native-webview/pull/1567

To Reproduce:

confirm("Hi") in any webview.

Expected behavior:

No crash

Screenshots/Videos:

Environment:

  • OS: iOS
  • OS version: any version > 10
  • react-native version: 0.62.2
  • react-native-webview version: 10.4.1 to 10.7.0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (15 by maintainers)

Most upvoted comments

@jxm2004 I have just reproduced your alert crash if the && check is not used, so I see what you’re talking about.

I have also tried using RCTPresentedViewController() and removed all the redundant recursive calls and the crash is gone, and also my own issue with the modal is gone… I don’t know what else could be tried to make sure this change is appropriate, but would definitely make the code much more readable.

🎉 This issue has been resolved in version 10.8.1 🎉

The release is available on:

Your semantic-release bot 📦🚀