Skip to content
Permalink
Browse files
WebDriver: Automation session terminates during navigation process swap
https://bugs.webkit.org/show_bug.cgi?id=245011
rdar://90824741

Reviewed by Devin Rousso and Brent Fulgham.

WebPageProxy::commitProvisionalPage is crashing during some WebDriver sessions due to having a `nullptr` for
`m_provisionalPage` after calling `WebPageProxy::resetStateAfterProcessTermination`. This was occuring because we were
indiscriminately terminating the WebDriver session at that point, but we should not do so when resetting state for a
navigation process swap, as the automation session is very much expected to continue to exist. The reason we end up
without a `m_provisionalPage` is because terminating the automation session cleans up (e.g. closes) the windows under
automation, which in turn is cleaning up the `m_provisionalPage`, since it will no longer exist once the window is gone.

This resolves numerous test crashes in WPT, including encoding/encodeInto.any.serviceworker.html, as well as fixing
issues navigating to `youtube.com` and `twitter.com`.

* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::resetStateAfterProcessTermination):

Canonical link: https://commits.webkit.org/254386@main
  • Loading branch information
patrickangle committed Sep 12, 2022
1 parent a068fb6 commit d65e9089f3a1e059ca3373052d58221df04b0209
Showing 1 changed file with 8 additions and 7 deletions.
@@ -8112,15 +8112,16 @@ void WebPageProxy::resetStateAfterProcessTermination(ProcessTerminationReason re
pageClient().removeAllPDFHUDs();
#endif

// For bringup of process swapping, NavigationSwap termination will not go out to clients.
// If it does *during* process swapping, and the client triggers a reload, that causes bizarre WebKit re-entry.
// FIXME: This might have to change
if (reason != ProcessTerminationReason::NavigationSwap)
if (reason != ProcessTerminationReason::NavigationSwap) {
// For bringup of process swapping, NavigationSwap termination will not go out to clients.
// If it does *during* process swapping, and the client triggers a reload, that causes bizarre WebKit re-entry.
// FIXME: This might have to change
navigationState().clearAllNavigations();

if (m_controlledByAutomation) {
if (auto* automationSession = process().processPool().automationSession())
automationSession->terminate();
if (m_controlledByAutomation) {
if (auto* automationSession = process().processPool().automationSession())
automationSession->terminate();
}
}
}

0 comments on commit d65e908

Please sign in to comment.