Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 8cef11213b35473894605d119a6a213127eb0c8d
      
https://github.com/WebKit/WebKit/commit/8cef11213b35473894605d119a6a213127eb0c8d
  Author: Ryosuke Niwa <[email protected]>
  Date:   2025-10-03 (Fri, 03 Oct 2025)

  Changed paths:
    M Source/WebKit/Shared/WebBackForwardListItem.cpp
    M Source/WebKit/Shared/WebBackForwardListItem.h
    M Source/WebKit/UIProcess/BrowsingContextGroup.cpp
    M Source/WebKit/UIProcess/BrowsingContextGroup.h
    M Source/WebKit/UIProcess/FrameProcess.cpp
    M Source/WebKit/UIProcess/FrameProcess.h
    M Source/WebKit/UIProcess/WebBackForwardList.cpp
    M Source/WebKit/UIProcess/WebFrameProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/WebProcessCache.cpp
    M Source/WebKit/UIProcess/WebProcessCache.h
    M Source/WebKit/UIProcess/WebProcessPool.cpp
    M Source/WebKit/UIProcess/WebProcessPool.h
    M Source/WebKit/UIProcess/WebProcessProxy.cpp
    M Source/WebKit/UIProcess/WebProcessProxy.h
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm

  Log Message:
  -----------
  Add the support for storing a shared process for site isolation in process 
cache
https://bugs.webkit.org/show_bug.cgi?id=299916

Reviewed by Ben Nham.

Made shared process for site isolation work with the Web process cache. 
WebProcessCache is extended to
maintain a separate map of shared processes per top-level domain in addition to 
the existing cache of
"main" processes. The size and the capacity of WebProcessCache now takes into 
account both types of the
process caches. In addition to being segregated by the top-level domain, when a 
given domain receives
an user interaction from the user, the existing shared process cache which had 
loaded the same domain
will no longer be eligible for the cache reuse.

This PR also fixes the bug that a wrong BrowsingContextGroup is used during a 
back/forward navigation.
Store the relevant BrowsingContextGroup in WebBackForwardListItem and use this 
BrowsingContextGroup
when back/forward navigating to the item.

In addition, this PR also fixes the bug in 
WebPageProxy::receivedNavigationActionPolicyDecision that
we were creating a new BrowsingContextGroup even when the result of redirect 
chain ended up navigating
back to the same site. We now avoid creating a new BrowsingContextGroup when 
main frame's site did not
change per navigation.

Test: TestWebKitAPI.SiteIsolation.SharedProcessBasicWebProcessCache
      
TestWebKitAPI.SiteIsolation.SharedProcessWebProcessCacheSharedProcessForSiteWithUserInteraction

Test: Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm
* Source/WebKit/Shared/WebBackForwardListItem.cpp:
(WebKit::WebBackForwardListItem::create): Optionally store BrowsingContextGroup.
(WebKit::WebBackForwardListItem::WebBackForwardListItem):
* Source/WebKit/Shared/WebBackForwardListItem.h:
(WebKit::WebBackForwardListItem::browsingContextGroup const):
* Source/WebKit/UIProcess/BrowsingContextGroup.cpp:
(WebKit::BrowsingContextGroup::sharedProcessForSite):
(WebKit::BrowsingContextGroup::ensureProcessForSite):
* Source/WebKit/UIProcess/BrowsingContextGroup.h:
* Source/WebKit/UIProcess/FrameProcess.cpp:
(WebKit::FrameProcess::FrameProcess):
* Source/WebKit/UIProcess/FrameProcess.h:
(WebKit::FrameProcess::sharedProcessMainFrameSite const):
(WebKit::FrameProcess::create):
* Source/WebKit/UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::backForwardAddItemShared):
* Source/WebKit/UIProcess/WebFrameProxy.cpp:
(WebKit::WebFrameProxy::prepareForProvisionalLoadInProcess):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::launchProcess):
(WebKit::WebPageProxy::initializeWebPage):
(WebKit::WebPageProxy::receivedNavigationActionPolicyDecision): Fixed a subtle 
bug that this code was
using a wrong BrowsingContextGroup to find the shared process when the 
navigation is supposed to swap
the BrowsingContextGroup.
(WebKit::WebPageProxy::continueNavigationInNewProcess):
(WebKit::WebPageProxy::triggerBrowsingContextGroupSwitchForNavigation):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebProcessCache.cpp: Improved the logging code in 
this file to use
SENSITIVE_LOG_STRING of PRIVATE_LOG_STRING since it logs the site name.
(WebKit::WebProcessCache::canCacheProcess const):
(WebKit::WebProcessCache::addProcess):
(WebKit::WebProcessCache::evictAtRandomIfNeeded): Extracted from addProcess. We 
try to evict a shared
process before trying to evict the "main" process since the main process needs 
to launch sooner.
(WebKit::WebProcessCache::takeProcess):
(WebKit::WebProcessCache::takeSharedProcess): Added.
* Source/WebKit/UIProcess/WebProcessCache.h:
* Source/WebKit/UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::processForSite): Added the logic to reuse a cached 
shared process.
(WebKit::WebProcessPool::createWebPage):
(WebKit::WebProcessPool::processForNavigation):
(WebKit::WebProcessPool::prepareProcessForNavigation):
(WebKit::WebProcessPool::processForNavigationInternal):
* Source/WebKit/UIProcess/WebProcessPool.h:
* Source/WebKit/UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::addSharedProcessDomain): Added.
(WebKit::WebProcessProxy::didStartUsingProcessForSiteIsolation):
* Source/WebKit/UIProcess/WebProcessProxy.h:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm:
(TestWebKitAPI::siteIsolatedViewWithSharedProcess):
(TestWebKitAPI::(SiteIsolation, SharedProcessBasicWebProcessCache)): Added
(TestWebKitAPI::(SiteIsolation, SharedProcessWithResourceLoadStatistics)):
(TestWebKitAPI::(SiteIsolation, SharedProcessAfterClick)):
(TestWebKitAPI::(SiteIsolation, SharedProcessAfterKeyDown)):
(TestWebKitAPI::(SiteIsolation, 
SharedProcessAfterUserInteractionInSharedProcesss)):
(TestWebKitAPI::(SiteIsolation, 
SharedProcessWebProcessCacheSharedProcessForSiteWithUserInteraction)):
Added.

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to