Changeset 272376 in webkit
- Timestamp:
- Feb 4, 2021, 10:10:39 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r272368 r272376 1 2021-02-04 Alex Christensen <achristensen@apple.com> 2 3 REGRESSION(r267763) Network process launches earlier than before 4 https://bugs.webkit.org/show_bug.cgi?id=221384 5 <rdar://problem/73507706> 6 7 Reviewed by Chris Dumez. 8 9 Before r267763 we could have an app launch, allocate a WKWebView, and set _resourceLoadStatisticsEnabled 10 all without having a network process launch. 11 12 When setting _resourceLoadStatisticsEnabled, we don't need to launch a network process if we haven't already 13 because when we do, WebsiteDataStore::parameters will send the correct value. I added a test that verifies this doesn't 14 launch the network process if it hasn't already been launched. 15 16 We also don't need to update the process assertion or the process suspension state if there is no network process. 17 18 sendNetworkProcessXPCEndpointToWebProcess is also called when opening Safari on iOS and would be the next thing to 19 unnecessarily launch the network process during app initialization. I manually verified that if we add an early return 20 if there is no network process yet, we do send the XPC endpoint to the web process when the network process does launch 21 through the call site in sendNetworkProcessXPCEndpointToAllWebProcesses. 22 23 I verified on my phone that this is the minimal change needed for Safari on iOS to not launch the network process before 24 application:didFinishLaunchingWithOptions: is called as it did before r267763. 25 26 * UIProcess/Cocoa/WebProcessPoolCocoa.mm: 27 (WebKit::WebProcessPool::updateProcessSuppressionState): 28 * UIProcess/WebProcessPool.cpp: 29 (WebKit::WebProcessPool::updateProcessAssertions): 30 * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: 31 (WebKit::WebsiteDataStore::sendNetworkProcessXPCEndpointToWebProcess): 32 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 33 (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled): 34 * UIProcess/WebsiteData/WebsiteDataStore.h: 35 (WebKit::WebsiteDataStore::networkProcessIfExists): 36 1 37 2021-02-04 Aditya Keerthi <akeerthi@apple.com> 2 38 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
r269712 r272376 701 701 } 702 702 703 - (BOOL)_networkProcessExists 704 { 705 return !!_websiteDataStore->networkProcessIfExists(); 706 } 707 703 708 @end -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h
r271813 r272376 97 97 - (pid_t)_networkProcessIdentifier WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 98 98 + (void)_makeNextNetworkProcessLaunchFailForTesting WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 99 - (BOOL)_networkProcessExists WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 99 100 100 101 @end -
trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
r272335 r272376 142 142 { 143 143 WebsiteDataStore::forEachWebsiteDataStore([enabled = processSuppressionEnabled()] (WebsiteDataStore& dataStore) { 144 dataStore.networkProcess().setProcessSuppressionEnabled(enabled); 144 if (auto* networkProcess = dataStore.networkProcessIfExists()) 145 networkProcess->setProcessSuppressionEnabled(enabled); 145 146 }); 146 147 -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r272209 r272376 1719 1719 { 1720 1720 WebsiteDataStore::forEachWebsiteDataStore([] (WebsiteDataStore& dataStore) { 1721 dataStore.networkProcess().updateProcessAssertion(); 1721 if (auto* networkProcess = dataStore.networkProcessIfExists()) 1722 networkProcess->updateProcessAssertion(); 1722 1723 }); 1723 1724 #if ENABLE(GPU_PROCESS) -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r271714 r272376 1991 1991 resolveDirectoriesIfNecessary(); 1992 1992 1993 networkProcess().send(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(m_sessionID, true), 0); 1993 if (m_networkProcess) 1994 m_networkProcess->send(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(m_sessionID, true), 0); 1994 1995 for (auto& processPool : processPools()) 1995 1996 processPool->sendToAllProcessesForSession(Messages::WebProcess::SetResourceLoadStatisticsEnabled(true), m_sessionID); … … 1997 1998 } 1998 1999 1999 networkProcess().send(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(m_sessionID, false), 0); 2000 if (m_networkProcess) 2001 m_networkProcess->send(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(m_sessionID, false), 0); 2000 2002 for (auto& processPool : processPools()) 2001 2003 processPool->sendToAllProcessesForSession(Messages::WebProcess::SetResourceLoadStatisticsEnabled(false), m_sessionID); -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
r271714 r272376 123 123 NetworkProcessProxy& networkProcess() const; 124 124 NetworkProcessProxy& networkProcess(); 125 NetworkProcessProxy* networkProcessIfExists() { return m_networkProcess.get(); } 125 126 126 127 static WebsiteDataStore* existingDataStoreForSessionID(PAL::SessionID); -
trunk/Tools/ChangeLog
r272369 r272376 1 2021-02-04 Alex Christensen <achristensen@apple.com> 2 3 REGRESSION(r267763) Network process launches earlier than before 4 https://bugs.webkit.org/show_bug.cgi?id=221384 5 <rdar://problem/73507706> 6 7 Reviewed by Chris Dumez. 8 9 * TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm: 10 (TEST): 11 1 12 2021-02-04 Philippe Normand <pnormand@igalia.com> 2 13 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm
r267763 r272376 79 79 checkReferer([NSURL URLWithString:shorterHost], shorterHost.UTF8String); 80 80 } 81 82 TEST(WebKit, NetworkProcessLaunchOnlyWhenNecessary) 83 { 84 auto webView = [[WKWebView new] autorelease]; 85 webView.configuration.websiteDataStore._resourceLoadStatisticsEnabled = YES; 86 EXPECT_FALSE([webView.configuration.websiteDataStore _networkProcessExists]); 87 }
Note:
See TracChangeset
for help on using the changeset viewer.