- Revision
- 272376
- Author
- achristen...@apple.com
- Date
- 2021-02-04 10:10:39 -0800 (Thu, 04 Feb 2021)
Log Message
REGRESSION(r267763) Network process launches earlier than before
https://bugs.webkit.org/show_bug.cgi?id=221384
<rdar://problem/73507706>
Patch by Alex Christensen <achristen...@apple.com> on 2021-02-04
Reviewed by Chris Dumez.
Source/WebKit:
Before r267763 we could have an app launch, allocate a WKWebView, and set _resourceLoadStatisticsEnabled
all without having a network process launch.
When setting _resourceLoadStatisticsEnabled, we don't need to launch a network process if we haven't already
because when we do, WebsiteDataStore::parameters will send the correct value. I added a test that verifies this doesn't
launch the network process if it hasn't already been launched.
We also don't need to update the process assertion or the process suspension state if there is no network process.
sendNetworkProcessXPCEndpointToWebProcess is also called when opening Safari on iOS and would be the next thing to
unnecessarily launch the network process during app initialization. I manually verified that if we add an early return
if there is no network process yet, we do send the XPC endpoint to the web process when the network process does launch
through the call site in sendNetworkProcessXPCEndpointToAllWebProcesses.
I verified on my phone that this is the minimal change needed for Safari on iOS to not launch the network process before
application:didFinishLaunchingWithOptions: is called as it did before r267763.
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::updateProcessSuppressionState):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::updateProcessAssertions):
* UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
(WebKit::WebsiteDataStore::sendNetworkProcessXPCEndpointToWebProcess):
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):
* UIProcess/WebsiteData/WebsiteDataStore.h:
(WebKit::WebsiteDataStore::networkProcessIfExists):
Tools:
* TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm:
(TEST):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (272375 => 272376)
--- trunk/Source/WebKit/ChangeLog 2021-02-04 18:01:36 UTC (rev 272375)
+++ trunk/Source/WebKit/ChangeLog 2021-02-04 18:10:39 UTC (rev 272376)
@@ -1,3 +1,39 @@
+2021-02-04 Alex Christensen <achristen...@apple.com>
+
+ REGRESSION(r267763) Network process launches earlier than before
+ https://bugs.webkit.org/show_bug.cgi?id=221384
+ <rdar://problem/73507706>
+
+ Reviewed by Chris Dumez.
+
+ Before r267763 we could have an app launch, allocate a WKWebView, and set _resourceLoadStatisticsEnabled
+ all without having a network process launch.
+
+ When setting _resourceLoadStatisticsEnabled, we don't need to launch a network process if we haven't already
+ because when we do, WebsiteDataStore::parameters will send the correct value. I added a test that verifies this doesn't
+ launch the network process if it hasn't already been launched.
+
+ We also don't need to update the process assertion or the process suspension state if there is no network process.
+
+ sendNetworkProcessXPCEndpointToWebProcess is also called when opening Safari on iOS and would be the next thing to
+ unnecessarily launch the network process during app initialization. I manually verified that if we add an early return
+ if there is no network process yet, we do send the XPC endpoint to the web process when the network process does launch
+ through the call site in sendNetworkProcessXPCEndpointToAllWebProcesses.
+
+ I verified on my phone that this is the minimal change needed for Safari on iOS to not launch the network process before
+ application:didFinishLaunchingWithOptions: is called as it did before r267763.
+
+ * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+ (WebKit::WebProcessPool::updateProcessSuppressionState):
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::updateProcessAssertions):
+ * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
+ (WebKit::WebsiteDataStore::sendNetworkProcessXPCEndpointToWebProcess):
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):
+ * UIProcess/WebsiteData/WebsiteDataStore.h:
+ (WebKit::WebsiteDataStore::networkProcessIfExists):
+
2021-02-04 Aditya Keerthi <akeer...@apple.com>
[macOS] Selecting a date on datetime-local inputs unexpectedly adds second and millisecond fields
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (272375 => 272376)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2021-02-04 18:01:36 UTC (rev 272375)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2021-02-04 18:10:39 UTC (rev 272376)
@@ -700,4 +700,9 @@
WebKit::WebsiteDataStore::makeNextNetworkProcessLaunchFailForTesting();
}
+- (BOOL)_networkProcessExists
+{
+ return !!_websiteDataStore->networkProcessIfExists();
+}
+
@end
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h (272375 => 272376)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2021-02-04 18:01:36 UTC (rev 272375)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2021-02-04 18:10:39 UTC (rev 272376)
@@ -96,6 +96,7 @@
- (void)_synthesizeAppIsBackground:(BOOL)background WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
- (pid_t)_networkProcessIdentifier WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+ (void)_makeNextNetworkProcessLaunchFailForTesting WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (BOOL)_networkProcessExists WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
@end
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (272375 => 272376)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2021-02-04 18:01:36 UTC (rev 272375)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2021-02-04 18:10:39 UTC (rev 272376)
@@ -141,7 +141,8 @@
void WebProcessPool::updateProcessSuppressionState()
{
WebsiteDataStore::forEachWebsiteDataStore([enabled = processSuppressionEnabled()] (WebsiteDataStore& dataStore) {
- dataStore.networkProcess().setProcessSuppressionEnabled(enabled);
+ if (auto* networkProcess = dataStore.networkProcessIfExists())
+ networkProcess->setProcessSuppressionEnabled(enabled);
});
#if ENABLE(NETSCAPE_PLUGIN_API)
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (272375 => 272376)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2021-02-04 18:01:36 UTC (rev 272375)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2021-02-04 18:10:39 UTC (rev 272376)
@@ -1718,7 +1718,8 @@
void WebProcessPool::updateProcessAssertions()
{
WebsiteDataStore::forEachWebsiteDataStore([] (WebsiteDataStore& dataStore) {
- dataStore.networkProcess().updateProcessAssertion();
+ if (auto* networkProcess = dataStore.networkProcessIfExists())
+ networkProcess->updateProcessAssertion();
});
#if ENABLE(GPU_PROCESS)
if (auto* gpuProcess = GPUProcessProxy::singletonIfCreated())
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (272375 => 272376)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2021-02-04 18:01:36 UTC (rev 272375)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2021-02-04 18:10:39 UTC (rev 272376)
@@ -1990,13 +1990,15 @@
resolveDirectoriesIfNecessary();
- networkProcess().send(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(m_sessionID, true), 0);
+ if (m_networkProcess)
+ m_networkProcess->send(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(m_sessionID, true), 0);
for (auto& processPool : processPools())
processPool->sendToAllProcessesForSession(Messages::WebProcess::SetResourceLoadStatisticsEnabled(true), m_sessionID);
return;
}
- networkProcess().send(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(m_sessionID, false), 0);
+ if (m_networkProcess)
+ m_networkProcess->send(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(m_sessionID, false), 0);
for (auto& processPool : processPools())
processPool->sendToAllProcessesForSession(Messages::WebProcess::SetResourceLoadStatisticsEnabled(false), m_sessionID);
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (272375 => 272376)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2021-02-04 18:01:36 UTC (rev 272375)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2021-02-04 18:10:39 UTC (rev 272376)
@@ -122,6 +122,7 @@
NetworkProcessProxy& networkProcess() const;
NetworkProcessProxy& networkProcess();
+ NetworkProcessProxy* networkProcessIfExists() { return m_networkProcess.get(); }
static WebsiteDataStore* existingDataStoreForSessionID(PAL::SessionID);
Modified: trunk/Tools/ChangeLog (272375 => 272376)
--- trunk/Tools/ChangeLog 2021-02-04 18:01:36 UTC (rev 272375)
+++ trunk/Tools/ChangeLog 2021-02-04 18:10:39 UTC (rev 272376)
@@ -1,3 +1,14 @@
+2021-02-04 Alex Christensen <achristen...@apple.com>
+
+ REGRESSION(r267763) Network process launches earlier than before
+ https://bugs.webkit.org/show_bug.cgi?id=221384
+ <rdar://problem/73507706>
+
+ Reviewed by Chris Dumez.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm:
+ (TEST):
+
2021-02-04 Philippe Normand <pnorm...@igalia.com>
[GStreamer] Misc Thunder nitpicks
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm (272375 => 272376)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm 2021-02-04 18:01:36 UTC (rev 272375)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm 2021-02-04 18:10:39 UTC (rev 272376)
@@ -78,3 +78,10 @@
checkReferer([NSURL URLWithString:longHost], nullptr);
checkReferer([NSURL URLWithString:shorterHost], shorterHost.UTF8String);
}
+
+TEST(WebKit, NetworkProcessLaunchOnlyWhenNecessary)
+{
+ auto webView = [[WKWebView new] autorelease];
+ webView.configuration.websiteDataStore._resourceLoadStatisticsEnabled = YES;
+ EXPECT_FALSE([webView.configuration.websiteDataStore _networkProcessExists]);
+}