-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up site isolation process selection logic #25067
Clean up site isolation process selection logic #25067
Conversation
EWS run on previous version of this PR (hash f1d853f) |
f1d853f
to
8b58dd9
Compare
EWS run on previous version of this PR (hash 8b58dd9) |
8b58dd9
to
9f5ad9e
Compare
EWS run on previous version of this PR (hash 9f5ad9e) |
9f5ad9e
to
75d9771
Compare
EWS run on previous version of this PR (hash 75d9771) |
75d9771
to
7a074a3
Compare
EWS run on previous version of this PR (hash 7a074a3) |
7a074a3
to
5b02650
Compare
EWS run on previous version of this PR (hash 5b02650) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
m_processMap.set(domain, process); | ||
for (auto& page : m_pages) { | ||
if (domain == WebCore::RegistrableDomain(URL(page.currentURL()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the correct URL to compare to here? Instead of using the committed URL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think this is correct.
m_remotePages.removeIf([&] (auto& pair) { | ||
auto& set = pair.value; | ||
set.removeIf([&] (auto& remotePage) { | ||
return remotePage->process().coreProcessIdentifier() == process.process().coreProcessIdentifier(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just compare WebProcessProxy
? It doesn't seem like we need to compare pids? Here and everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't comparing pids, it's comparing coreProcessIdentifier which is unique even if the pid is reused. I think it's better than comparing pointers to see if the identity of the process is the same.
m_webPageID = existingRemotePageProxy->pageID(); | ||
m_mainFrame = existingRemotePageProxy->page()->mainFrame(); | ||
m_messageReceiverRegistration.stopReceivingMessages(); | ||
m_messageReceiverRegistration.transferMessageReceivingFrom(existingRemotePageProxy->messageReceiverRegistration(), *this); | ||
LocalFrameCreationParameters localFrameCreationParameters { | ||
std::nullopt | ||
}; | ||
m_process->send(Messages::WebPage::TransitionFrameToLocal(localFrameCreationParameters, m_page->mainFrame()->frameID()), m_webPageID); | ||
process().send(Messages::WebPage::TransitionFrameToLocal(localFrameCreationParameters, m_page->mainFrame()->frameID()), m_webPageID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protectedProcess()
m_process->send(Messages::WebProcess::CreateWebPage(m_webPageID, m_page->creationParametersForProvisionalPage(m_process, *m_drawingArea, WTFMove(websitePolicies), WTFMove(mainFrameIdentifier))), 0); | ||
m_process->addVisitedLinkStoreUser(m_page->visitedLinkStore(), m_page->identifier()); | ||
process().send(Messages::WebProcess::CreateWebPage(m_webPageID, m_page->creationParametersForProvisionalPage(process(), *m_drawingArea, WTFMove(websitePolicies), WTFMove(mainFrameIdentifier))), 0); | ||
process().addVisitedLinkStoreUser(m_page->visitedLinkStore(), m_page->identifier()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protectedProcess()
if (m_page && m_page->drawingArea()) | ||
if (!m_page) | ||
return; | ||
if (m_page->drawingArea()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could if (auto* drawingArea = m_page->drawingArea())
@@ -4359,8 +4350,10 @@ void WebPageProxy::receivedNavigationActionPolicyDecision(WebProcessProxy& proce | |||
|
|||
Ref pageClientProtector = pageClient(); | |||
|
|||
const bool navigationChangesFrameProcess = processNavigatingTo.ptr() != processNavigatingFrom.ptr(); | |||
const bool loadContinuingInNonInitiatingProcess = processInitiatingNavigation.ptr() != processNavigatingTo.ptr(); | |||
Ref processNavigatingFrom { frame->provisionalFrame() ? frame->provisionalFrame()->process() : frame->isMainFrame() && m_provisionalPage ? m_provisionalPage->process() : frame->process() }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line seems like it could benefit from parenthesis, or maybe another line.
@@ -4395,7 +4388,7 @@ void WebPageProxy::receivedNavigationActionPolicyDecision(WebProcessProxy& proce | |||
// FIXME: Add more parameters as appropriate. <rdar://116200985> | |||
LoadParameters loadParameters; | |||
loadParameters.request = navigation->currentRequest(); | |||
loadParameters.shouldTreatAsContinuingLoad = WebCore::ShouldTreatAsContinuingLoad::YesAfterNavigationPolicyDecision; | |||
loadParameters.shouldTreatAsContinuingLoad = navigation->currentRequestIsRedirect() ? WebCore::ShouldTreatAsContinuingLoad::YesAfterProvisionalLoadStarted : WebCore::ShouldTreatAsContinuingLoad::YesAfterNavigationPolicyDecision; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loadParameters.shouldTreatAsContinuingLoad = navigation->currentRequestIsRedirect() ? WebCore::ShouldTreatAsContinuingLoad::YesAfterProvisionalLoadStarted : WebCore::ShouldTreatAsContinuingLoad::YesAfterNavigationPolicyDecision; | |
loadParameters.shouldTreatAsContinuingLoad = navigation->currentRequestIsRedirect() ? ShouldTreatAsContinuingLoad::YesAfterProvisionalLoadStarted : ShouldTreatAsContinuingLoad::YesAfterNavigationPolicyDecision; |
aggregator->addFrameTree(WTFMove(data)); | ||
}); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all can be replaced with forEachWebContentProcess()
Ref { *remotePageProxy }->sendWithAsyncReply(Messages::DrawingArea::DispatchAfterEnsuringDrawing(), [aggregator] { }, drawingAreaIdentifier); | ||
m_browsingContextGroup->forEachRemotePage(*this, [&] (auto& remotePageProxy) { | ||
remotePageProxy.sendWithAsyncReply(Messages::DrawingArea::DispatchAfterEnsuringDrawing(), [aggregator] { }, drawingAreaIdentifier); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the above line can be replaced with forEachWebContentProcess()
.
@@ -37,7 +37,6 @@ | |||
namespace WebCore { | |||
class SecurityOriginData; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
5b02650
to
8bca334
Compare
EWS run on current version of this PR (hash 8bca334) |
https://bugs.webkit.org/show_bug.cgi?id=270045 rdar://116202371 Reviewed by Charlie Wolfe. This pulls the process selection and RemotePageProxy management logic from various places into BrowsingContextGroup. I introduce a new abstraction, FrameProcess, that represents a frame's use of a particular process. The WebFrameProxy retains a reference to a FrameProcess instead of a RemotePageProxy. When a FrameProcess is created or destroyed, the BrowsingContextGroup updates the containers of RemotePageProxy objects. This change allows us to keep track of opened pages using structures that are more elegant and robust to handle all possible combinations of window.open and iframe creation or destruction. Two small changes are observable in site isolation API tests, but they are both progressions because of processes and frames being managed more correctly in some cases. * Source/WebKit/NetworkProcess/NetworkProcess.cpp: (WebKit::NetworkProcess::allowsFirstPartyForCookies): * Source/WebKit/Shared/AuxiliaryProcess.cpp: (WebKit::AuxiliaryProcess::allowsFirstPartyForCookies): * Source/WebKit/Sources.txt: * Source/WebKit/UIProcess/AuxiliaryProcessProxy.h: * Source/WebKit/UIProcess/BrowsingContextGroup.cpp: (WebKit::BrowsingContextGroup::ensureProcessForDomain): (WebKit::BrowsingContextGroup::processForDomain): (WebKit::BrowsingContextGroup::addFrameProcess): (WebKit::BrowsingContextGroup::removeFrameProcess): (WebKit::BrowsingContextGroup::addPage): (WebKit::BrowsingContextGroup::removePage): (WebKit::BrowsingContextGroup::forEachRemotePage): (WebKit::BrowsingContextGroup::remotePageInProcess): (WebKit::BrowsingContextGroup::takeRemotePageInProcessForProvisionalPage): (WebKit::BrowsingContextGroup::transitionPageToRemotePage): (WebKit::BrowsingContextGroup::addProcessForDomain): Deleted. * Source/WebKit/UIProcess/BrowsingContextGroup.h: * Source/WebKit/UIProcess/FrameProcess.cpp: Renamed from Source/WebKit/UIProcess/RemotePageProxyState.h. (WebKit::FrameProcess::FrameProcess): (WebKit::FrameProcess::~FrameProcess): * Source/WebKit/UIProcess/FrameProcess.h: Copied from Source/WebKit/UIProcess/BrowsingContextGroup.h. (WebKit::FrameProcess::domain const): (WebKit::FrameProcess::process const): (WebKit::FrameProcess::process): (WebKit::FrameProcess::create): * Source/WebKit/UIProcess/ProvisionalFrameProxy.cpp: (WebKit::ProvisionalFrameProxy::ProvisionalFrameProxy): (WebKit::ProvisionalFrameProxy::takeFrameProcess): (WebKit::ProvisionalFrameProxy::process const): (WebKit::ProvisionalFrameProxy::takeRemotePageProxy): Deleted. * Source/WebKit/UIProcess/ProvisionalFrameProxy.h: (WebKit::ProvisionalFrameProxy::process const): Deleted. * Source/WebKit/UIProcess/ProvisionalPageProxy.cpp: (WebKit::ProvisionalPageProxy::ProvisionalPageProxy): (WebKit::ProvisionalPageProxy::~ProvisionalPageProxy): (WebKit::ProvisionalPageProxy::process): (WebKit::ProvisionalPageProxy::setNavigation): (WebKit::ProvisionalPageProxy::cancel): (WebKit::ProvisionalPageProxy::initializeWebPage): (WebKit::ProvisionalPageProxy::loadData): (WebKit::ProvisionalPageProxy::loadRequest): (WebKit::ProvisionalPageProxy::goToBackForwardItem): (WebKit::ProvisionalPageProxy::didCreateMainFrame): (WebKit::ProvisionalPageProxy::didPerformClientRedirect): (WebKit::ProvisionalPageProxy::didStartProvisionalLoadForFrame): (WebKit::ProvisionalPageProxy::didFailProvisionalLoadForFrame): (WebKit::ProvisionalPageProxy::didCommitLoadForFrame): (WebKit::ProvisionalPageProxy::didNavigateWithNavigationData): (WebKit::ProvisionalPageProxy::didChangeProvisionalURLForFrame): (WebKit::ProvisionalPageProxy::decidePolicyForNavigationActionAsync): (WebKit::ProvisionalPageProxy::decidePolicyForResponse): (WebKit::ProvisionalPageProxy::didPerformServerRedirect): (WebKit::ProvisionalPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame): (WebKit::ProvisionalPageProxy::startURLSchemeTask): (WebKit::ProvisionalPageProxy::decidePolicyForNavigationActionSync): (WebKit::ProvisionalPageProxy::logDiagnosticMessageFromWebProcess): (WebKit::ProvisionalPageProxy::logDiagnosticMessageWithEnhancedPrivacyFromWebProcess): (WebKit::ProvisionalPageProxy::logDiagnosticMessageWithValueDictionaryFromWebProcess): (WebKit::ProvisionalPageProxy::backForwardAddItem): (WebKit::ProvisionalPageProxy::didDestroyNavigation): (WebKit::ProvisionalPageProxy::contentFilterDidBlockLoadForFrame): (WebKit::ProvisionalPageProxy::messageSenderConnection const): (WebKit::ProvisionalPageProxy::sendMessage): (WebKit::ProvisionalPageProxy::sendMessageWithAsyncReply): * Source/WebKit/UIProcess/ProvisionalPageProxy.h: (WebKit::ProvisionalPageProxy::browsingContextGroup): (WebKit::ProvisionalPageProxy::takeRemotePageProxyState): Deleted. (WebKit::ProvisionalPageProxy::process): Deleted. * Source/WebKit/UIProcess/RemotePageProxy.cpp: (WebKit::RemotePageProxy::RemotePageProxy): (WebKit::RemotePageProxy::injectPageIntoNewProcess): (WebKit::RemotePageProxy::~RemotePageProxy): * Source/WebKit/UIProcess/RemotePageProxy.h: (WebKit::RemotePageProxy::create): Deleted. * Source/WebKit/UIProcess/SuspendedPageProxy.cpp: (WebKit::SuspendedPageProxy::SuspendedPageProxy): (WebKit::SuspendedPageProxy::sendToAllProcesses): * Source/WebKit/UIProcess/SuspendedPageProxy.h: * Source/WebKit/UIProcess/WebFrameProxy.cpp: (WebKit::WebFrameProxy::WebFrameProxy): (WebKit::WebFrameProxy::process const): (WebKit::WebFrameProxy::processID const): (WebKit::WebFrameProxy::didCreateSubframe): (WebKit::WebFrameProxy::prepareForProvisionalNavigationInProcess): (WebKit::WebFrameProxy::commitProvisionalFrame): (WebKit::WebFrameProxy::setProcess): (WebKit::WebFrameProxy::webPageIDInCurrentProcess): (WebKit::WebFrameProxy::rootFrame): (WebKit::WebFrameProxy::remotePageProxy const): Deleted. * Source/WebKit/UIProcess/WebFrameProxy.h: (WebKit::WebFrameProxy::create): (WebKit::WebFrameProxy::process const): Deleted. (WebKit::WebFrameProxy::setProcess): Deleted. * Source/WebKit/UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::suspendCurrentPageIfPossible): (WebKit::WebPageProxy::swapToProvisionalPage): (WebKit::WebPageProxy::close): (WebKit::WebPageProxy::loadRequestWithNavigationShared): (WebKit::WebPageProxy::loadFile): (WebKit::WebPageProxy::receivedNavigationActionPolicyDecision): (WebKit::WebPageProxy::continueNavigationInNewProcess): (WebKit::WebPageProxy::getAllFrameTrees): (WebKit::WebPageProxy::forceRepaint): (WebKit::WebPageProxy::didCreateMainFrame): (WebKit::WebPageProxy::updateRemoteFrameSize): (WebKit::WebPageProxy::forEachWebContentProcess): (WebKit::WebPageProxy::decidePolicyForNavigationAction): (WebKit::WebPageProxy::callAfterNextPresentationUpdate): (WebKit::WebPageProxy::processForRegistrableDomain): (WebKit::WebPageProxy::webPageIDInProcessForDomain const): (WebKit::WebPageProxy::sendToWebPage): (WebKit::WebPageProxy::addRemotePageProxy): Deleted. (WebKit::WebPageProxy::removeRemotePageProxy): Deleted. (WebKit::WebPageProxy::remotePageProxyForRegistrableDomain const): Deleted. (WebKit::WebPageProxy::setRemotePageProxyInOpenerProcess): Deleted. (WebKit::WebPageProxy::takeRemotePageProxyInOpenerProcessIfDomainEquals): Deleted. (WebKit::WebPageProxy::removeOpenedRemotePageProxy): Deleted. (WebKit::WebPageProxy::takeOpenedRemotePageProxyIfDomainEquals): Deleted. (WebKit::WebPageProxy::addOpenedRemotePageProxy): Deleted. * Source/WebKit/UIProcess/WebPageProxy.h: * Source/WebKit/UIProcess/WebPageProxyInternals.h: * Source/WebKit/UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::processForNavigation): * Source/WebKit/UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::addVisitedLinkStoreUser): * Source/WebKit/WebKit.xcodeproj/project.pbxproj: * Source/WebKit/WebProcess/WebPage/WebFrame.cpp: (WebKit::WebFrame::WebFrame): * Source/WebKit/WebProcess/WebPage/WebPage.cpp: (WebKit::m_unifiedTextReplacementController): (WebKit::WebPage::~WebPage): * Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm: (TestWebKitAPI::indentation): (TestWebKitAPI::printTree): (TestWebKitAPI::checkFrameTreesInProcesses): (TestWebKitAPI::findFramePID): (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/275551@main
8bca334
to
4993196
Compare
Committed 275551@main (4993196): https://commits.webkit.org/275551@main Reviewed commits have been landed. Closing PR #25067 and removing active labels. |
4993196
8bca334