Skip to content

Commit

Permalink
[PlayStation][wincairo] fix assertion with SingleWebProcess mode
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=263185

Reviewed by Chris Dumez.

The WebPageProxy::continueNavigationInNewProcess() function attempts to
create a new WebProcess to continue processing a response from a
particular websites.
If the application sets usesSingleWebProcess = true, the
WebPageProxy will attempt to reuse an existing process, but
unfortunately there is an assert that is not supposed to do that,
so the application with debug build will crash.

The NetworkResourceLoader in NetworkProcess decides whether to create
a new WebProcess.
So this patch makes two changes:
1. add SingleWebProcess flag to NetworkProcessPreferencesForWebProcess
2. use StayInGroup(do not create a new WebProcess) if SingleWebProcess

Incidentally, besides some ASSERTs, the connection with the automation
target was also not very well considered for SingleWebProcess mode.
For example, WebPageProxy::resetStateAfterProcessTermination() calls
disconnect() to target, but no one reconnects afterwards.
This raises a WebDriver Exception even if it is a release build.
This patch will solve this as well.

Canonical link: https://commits.webkit.org/278467@main
  • Loading branch information
haruhisa-shin authored and donny-dont committed May 7, 2024
1 parent 79f1358 commit 5d53332
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class NetworkConnectionToWebProcess
NetworkProcess& networkProcess() { return m_networkProcess.get(); }

bool isWebTransportEnabled() const { return m_preferencesForWebProcess.isWebTransportEnabled; }
bool usesSingleWebProcess() const { return m_preferencesForWebProcess.usesSingleWebProcess; }

void didCleanupResourceLoader(NetworkResourceLoader&);
void transferKeptAliveLoad(NetworkResourceLoader&);
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ void NetworkResourceLoader::didReceiveResponse(ResourceResponse&& receivedRespon

void NetworkResourceLoader::sendDidReceiveResponsePotentiallyInNewBrowsingContextGroup(const WebCore::ResourceResponse& response, PrivateRelayed privateRelayed, bool needsContinueDidReceiveResponseMessage)
{
auto browsingContextGroupSwitchDecision = toBrowsingContextGroupSwitchDecision(m_currentCoopEnforcementResult);
auto browsingContextGroupSwitchDecision = m_connection->usesSingleWebProcess()? BrowsingContextGroupSwitchDecision::StayInGroup: toBrowsingContextGroupSwitchDecision(m_currentCoopEnforcementResult);
if (browsingContextGroupSwitchDecision == BrowsingContextGroupSwitchDecision::StayInGroup) {
send(Messages::WebResourceLoader::DidReceiveResponse { response, privateRelayed, needsContinueDidReceiveResponseMessage, computeResponseMetrics(response) });
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace WebKit {

struct NetworkProcessPreferencesForWebProcess {
bool isWebTransportEnabled { false };
bool usesSingleWebProcess { false };

friend bool operator==(const NetworkProcessPreferencesForWebProcess&, const NetworkProcessPreferencesForWebProcess&) = default;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@

struct WebKit::NetworkProcessPreferencesForWebProcess {
bool isWebTransportEnabled;
bool usesSingleWebProcess;
};
1 change: 1 addition & 0 deletions Source/WebKit/UIProcess/API/APIPageConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ NetworkProcessPreferencesForWebProcess PageConfiguration::preferencesForNetworkP

return {
preferences->webTransportEnabled(),
processPool().usesSingleWebProcess(),
};
}

Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/UIProcess/WebProcessPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,8 @@ class WebProcessPool final
RefPtr<WebProcessProxy> webProcessForCapabilityGranter(const ExtensionCapabilityGranter&, const String& environmentIdentifier) final;
#endif

bool usesSingleWebProcess() const { return m_configuration->usesSingleWebProcess(); }

bool operator==(const WebProcessPool& other) const { return (this == &other); }

private:
Expand Down Expand Up @@ -603,8 +605,6 @@ class WebProcessPool final
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
bool didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, UniqueRef<IPC::Encoder>&) override;

bool usesSingleWebProcess() const { return m_configuration->usesSingleWebProcess(); }

#if PLATFORM(COCOA)
void addCFNotificationObserver(CFNotificationCallback, CFStringRef name, CFNotificationCenterRef = CFNotificationCenterGetDarwinNotifyCenter());
void removeCFNotificationObserver(CFStringRef name, CFNotificationCenterRef = CFNotificationCenterGetDarwinNotifyCenter());
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/UIProcess/WebProcessProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ void WebProcessProxy::initializePreferencesForNetworkProcess(const WebPreference
ASSERT(!m_preferencesForNetworkProcess);
m_preferencesForNetworkProcess = NetworkProcessPreferencesForWebProcess {
preferences.getBoolValueForKey(WebPreferencesKey::webTransportEnabledKey()),
processPool().usesSingleWebProcess(),
};
}

Expand Down

0 comments on commit 5d53332

Please sign in to comment.