RESOLVED FIXED251548
[iOS] Crashes when WebValidationBubbleViewController is presented twice
https://bugs.webkit.org/show_bug.cgi?id=251548
Summary [iOS] Crashes when WebValidationBubbleViewController is presented twice
Ali Juma
Reported 2023-02-01 13:54:50 PST
Created attachment 464804 [details] Sample project Chrome for iOS is getting a significant number of crash reports from an exception that is triggered when WebValidationBubbleViewController is presented while already being presented ("[Exception] Application tried to present modally a view controller <WebValidationBubbleViewController: 0x#> that is already being presented by <TabGridViewController: 0x#>"). Debugging, it turns out that the logic in ValidationBubble::show to guard against presenting the view controller when it's already presented has a race condition. After the call to [m_presentingViewController presentViewController:animated:completion:], m_popoverController doesn't immediately have a parentViewController or a presentingViewController, so there's a short period of time where a second call ValidationBubble::show won't early-out, but will instead try to present m_popoverController again, leading to the exception. See https://github.com/WebKit/WebKit/blob/main/Source/WebCore/platform/ios/ValidationBubbleIOS.mm#L190 In practice ValidationBubble::show can get called multiple times since WebPageProxy::setIsScrollingOrZooming will call m_validationBubble->show() when scrolling/zooming stops, so if this happens multiple times over the lifetime of the same m_validationBubble, we're in trouble. I've attached a sample project that reproduces this crash. Steps to reproduce: 1) After the page loads, tap once anywhere. This will cause a green box to slide down. 2) Tap again quickly (before the green box slides away) on the "Se connecter" button to trigger the WebValidationBubble. A couple potential fixes: 1) In ValidationBubble, add an m_isPresentingBubble bool that is set to true when ValidationBubble::show calls presentViewController and cleared in the completion handler, and early-out in ValidationBubble::show when m_isPresentingBubble is true 2) In WebPageProxy, add an m_waitingToShowValidationBubble bool that is set to true when m_validationBubble, and cleared after calling m_validationBubble->show().
Attachments
Sample project (52.80 KB, application/zip)
2023-02-01 13:54 PST, Ali Juma
no flags
Radar WebKit Bug Importer
Comment 1 2023-02-08 13:55:20 PST
Ali Juma
Comment 2 2023-02-09 11:48:26 PST
EWS
Comment 3 2023-02-09 14:28:20 PST
Committed 260085@main (01bfc814e829): <https://commits.webkit.org/260085@main> Reviewed commits have been landed. Closing PR #9880 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.