Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2a91836e951396786de2ad74935db4ac1e43ac34
      
https://github.com/WebKit/WebKit/commit/2a91836e951396786de2ad74935db4ac1e43ac34
  Author: Sihui Liu <[email protected]>
  Date:   2026-05-21 (Thu, 21 May 2026)

  Changed paths:
    M LayoutTests/platform/ios-site-isolation/TestExpectations
    M LayoutTests/platform/mac-site-isolation/TestExpectations
    M Source/WebKit/UIProcess/ProvisionalPageProxy.cpp
    M Source/WebKit/UIProcess/RemotePageProxy.cpp
    M Source/WebKit/UIProcess/SuspendedPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebProcessProxy.cpp
    M Source/WebKit/UIProcess/WebProcessProxy.h
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/WebPage.messages.in
    M Source/WebKit/WebProcess/glib/WebProcessGLib.cpp
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebViewEvaluateJavaScript.mm

  Log Message:
  -----------
  [Site Isolation] 
imported/w3c/web-platform-tests/fetch/api/redirect/redirect-keepalive.any.html 
fails
https://bugs.webkit.org/show_bug.cgi?id=313863
rdar://176599181

Reviewed by Ryosuke Niwa.

When closing a page (e.g., window.close()), the UI process sends WebPage::Close 
to the web process, which triggers page
teardown including firing unload events. JavaScript in unload handlers may 
initiate keepalive fetch requests (e.g.,
analytics beacons).

Previously, the shutdownPreventingScope was released immediately after sending 
Close message, allowing the web process
to terminate before it processed the message. This means unload events never 
fired and keepalive fetches were never
sent. This patch fixes the issue by making Close an async reply message so the 
shutdownPreventingScope is held until the
web process confirms it has processed Close and completed teardown.

With this change, some tests start to hit an assertion in 
AuxiliaryProcessProxy::shutDownProcess(). The cause is web
process is killed (some test manually kill web process to simulate crash case) 
after UI process sends WebPage::Close
message and before web process handles the message. In this case, 
WebProcess::shutDown() is reentrant with the chain:
WebProcessProxy::processDidTerminateOrFailedToLaunch => 
WebProcessProxy::shutDown() =>
AuxiliaryProcessProxy::shutDownProcess() => Connection::invalidate() => 
Connection::cancelAsyncReplyHandlers() =>
RefCounter<ShutdownPreventingScopeType>::m_valueDidChange => 
WebProcessProxy::maybeShutDown() =>
WebProcessProxy::shutDown(). To fix the reentrancy issue, adding a new flag 
WebProcessProxy::m_isShuttingDown.

* LayoutTests/platform/ios-site-isolation/TestExpectations:
* LayoutTests/platform/mac-site-isolation/TestExpectations:
* Source/WebKit/UIProcess/ProvisionalPageProxy.cpp:
(WebKit::ProvisionalPageProxy::~ProvisionalPageProxy):
* Source/WebKit/UIProcess/RemotePageProxy.cpp:
(WebKit::RemotePageProxy::disconnect):
* Source/WebKit/UIProcess/SuspendedPageProxy.cpp:
(WebKit::SuspendedPageProxy::close):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::close):
(WebKit::WebPageProxy::commitProvisionalPage):
* Source/WebKit/UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::shutDown):
(WebKit::WebProcessProxy::maybeShutDown):
* Source/WebKit/UIProcess/WebProcessProxy.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::close):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:
* Source/WebKit/WebProcess/glib/WebProcessGLib.cpp:
(WebKit::WebProcess::stopRunLoop):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebViewEvaluateJavaScript.mm:
(TEST(WKWebView, EvaluateJavaScriptBlockCrash)): Update 
EvaluateJavaScriptBlockCrash test expectation: the process now
lives long enough for pending evaluateJavaScript to complete successfully 
instead of being cancelled with an error.

Canonical link: https://commits.webkit.org/313673@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to