- Revision
- 272536
- Author
- [email protected]
- Date
- 2021-02-08 13:04:02 -0800 (Mon, 08 Feb 2021)
Log Message
Cherry-pick r272376. rdar://problem/74032694
REGRESSION(r267763) Network process launches earlier than before
https://bugs.webkit.org/show_bug.cgi?id=221384
<rdar://problem/73507706>
Patch by Alex Christensen <[email protected]> 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):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272376 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Diff
Modified: branches/safari-611-branch/Source/WebKit/ChangeLog (272535 => 272536)
--- branches/safari-611-branch/Source/WebKit/ChangeLog 2021-02-08 21:03:57 UTC (rev 272535)
+++ branches/safari-611-branch/Source/WebKit/ChangeLog 2021-02-08 21:04:02 UTC (rev 272536)
@@ -1,5 +1,91 @@
2021-02-08 Russell Epstein <[email protected]>
+ Cherry-pick r272376. rdar://problem/74032694
+
+ REGRESSION(r267763) Network process launches earlier than before
+ https://bugs.webkit.org/show_bug.cgi?id=221384
+ <rdar://problem/73507706>
+
+ Patch by Alex Christensen <[email protected]> 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):
+
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272376 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-02-04 Alex Christensen <[email protected]>
+
+ 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-08 Russell Epstein <[email protected]>
+
Cherry-pick r272368. rdar://problem/74032667
[macOS] Selecting a date on datetime-local inputs unexpectedly adds second and millisecond fields
Modified: branches/safari-611-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (272535 => 272536)
--- branches/safari-611-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2021-02-08 21:03:57 UTC (rev 272535)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2021-02-08 21:04:02 UTC (rev 272536)
@@ -700,4 +700,9 @@
WebKit::WebsiteDataStore::makeNextNetworkProcessLaunchFailForTesting();
}
+- (BOOL)_networkProcessExists
+{
+ return !!_websiteDataStore->networkProcessIfExists();
+}
+
@end
Modified: branches/safari-611-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h (272535 => 272536)
--- branches/safari-611-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2021-02-08 21:03:57 UTC (rev 272535)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2021-02-08 21:04:02 UTC (rev 272536)
@@ -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: branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (272535 => 272536)
--- branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2021-02-08 21:03:57 UTC (rev 272535)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm 2021-02-08 21:04:02 UTC (rev 272536)
@@ -140,7 +140,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: branches/safari-611-branch/Source/WebKit/UIProcess/WebProcessPool.cpp (272535 => 272536)
--- branches/safari-611-branch/Source/WebKit/UIProcess/WebProcessPool.cpp 2021-02-08 21:03:57 UTC (rev 272535)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/WebProcessPool.cpp 2021-02-08 21:04:02 UTC (rev 272536)
@@ -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: branches/safari-611-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (272535 => 272536)
--- branches/safari-611-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2021-02-08 21:03:57 UTC (rev 272535)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2021-02-08 21:04:02 UTC (rev 272536)
@@ -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: branches/safari-611-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (272535 => 272536)
--- branches/safari-611-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2021-02-08 21:03:57 UTC (rev 272535)
+++ branches/safari-611-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2021-02-08 21:04:02 UTC (rev 272536)
@@ -122,6 +122,7 @@
NetworkProcessProxy& networkProcess() const;
NetworkProcessProxy& networkProcess();
+ NetworkProcessProxy* networkProcessIfExists() { return m_networkProcess.get(); }
static WebsiteDataStore* existingDataStoreForSessionID(PAL::SessionID);
Modified: branches/safari-611-branch/Tools/ChangeLog (272535 => 272536)
--- branches/safari-611-branch/Tools/ChangeLog 2021-02-08 21:03:57 UTC (rev 272535)
+++ branches/safari-611-branch/Tools/ChangeLog 2021-02-08 21:04:02 UTC (rev 272536)
@@ -1,5 +1,66 @@
2021-02-08 Russell Epstein <[email protected]>
+ Cherry-pick r272376. rdar://problem/74032694
+
+ REGRESSION(r267763) Network process launches earlier than before
+ https://bugs.webkit.org/show_bug.cgi?id=221384
+ <rdar://problem/73507706>
+
+ Patch by Alex Christensen <[email protected]> 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):
+
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272376 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-02-04 Alex Christensen <[email protected]>
+
+ 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-08 Russell Epstein <[email protected]>
+
Cherry-pick r272368. rdar://problem/74032667
[macOS] Selecting a date on datetime-local inputs unexpectedly adds second and millisecond fields
Modified: branches/safari-611-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm (272535 => 272536)
--- branches/safari-611-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm 2021-02-08 21:03:57 UTC (rev 272535)
+++ branches/safari-611-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm 2021-02-08 21:04:02 UTC (rev 272536)
@@ -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]);
+}