Diff
Modified: branches/safari-612-branch/Source/WebKit/ChangeLog (282933 => 282934)
--- branches/safari-612-branch/Source/WebKit/ChangeLog 2021-09-23 05:13:51 UTC (rev 282933)
+++ branches/safari-612-branch/Source/WebKit/ChangeLog 2021-09-23 05:13:56 UTC (rev 282934)
@@ -1,5 +1,79 @@
2021-09-22 Alan Coon <alanc...@apple.com>
+ Cherry-pick r282034. rdar://problem/83429808
+
+ Safari’s Privacy Report window is completely blank
+ https://bugs.webkit.org/show_bug.cgi?id=229847
+ <rdar://problem/80974688>
+
+ Reviewed by Chris Dumez.
+
+ Source/WebKit:
+
+ We should not wait for an IPC reply on a cached web process, because
+ it will cause long hangs.
+
+ In order to test this I added a new SPI to update the
+ cachedProcessSuspensionDelay (the usual timeout is 30 seconds). I also
+ moved the initial suspension timer call to be after the responsiveness
+ check, otherwise the cached process will be resumed very soon.
+
+ * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+ (+[WKWebsiteDataStore _setCachedProcessSuspensionDelayForTesting:]):
+ * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
+ * UIProcess/WebProcessCache.cpp:
+ (WebKit::WebProcessCache::setCachedProcessSuspensionDelayForTesting):
+ (WebKit::WebProcessCache::addProcess):
+ (WebKit::WebProcessCache::CachedProcess::CachedProcess):
+ (WebKit::WebProcessCache::CachedProcess::startSuspensionTimer):
+ * UIProcess/WebProcessCache.h:
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::sendResourceLoadStatisticsDataImmediately):
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::setCachedProcessSuspensionDelayForTesting):
+ * UIProcess/WebsiteData/WebsiteDataStore.h:
+
+ Tools:
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:
+ (TEST):
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282034 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-09-03 Kate Cheney <katherine_che...@apple.com>
+
+ Safari’s Privacy Report window is completely blank
+ https://bugs.webkit.org/show_bug.cgi?id=229847
+ <rdar://problem/80974688>
+
+ Reviewed by Chris Dumez.
+
+ We should not wait for an IPC reply on a cached web process, because
+ it will cause long hangs.
+
+ In order to test this I added a new SPI to update the
+ cachedProcessSuspensionDelay (the usual timeout is 30 seconds). I also
+ moved the initial suspension timer call to be after the responsiveness
+ check, otherwise the cached process will be resumed very soon.
+
+ * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+ (+[WKWebsiteDataStore _setCachedProcessSuspensionDelayForTesting:]):
+ * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
+ * UIProcess/WebProcessCache.cpp:
+ (WebKit::WebProcessCache::setCachedProcessSuspensionDelayForTesting):
+ (WebKit::WebProcessCache::addProcess):
+ (WebKit::WebProcessCache::CachedProcess::CachedProcess):
+ (WebKit::WebProcessCache::CachedProcess::startSuspensionTimer):
+ * UIProcess/WebProcessCache.h:
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::sendResourceLoadStatisticsDataImmediately):
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::setCachedProcessSuspensionDelayForTesting):
+ * UIProcess/WebsiteData/WebsiteDataStore.h:
+
+2021-09-22 Alan Coon <alanc...@apple.com>
+
Cherry-pick r282013. rdar://problem/83430076
[GPUP] Temporarily allow access to power logging service
Modified: branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (282933 => 282934)
--- branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2021-09-23 05:13:51 UTC (rev 282933)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2021-09-23 05:13:56 UTC (rev 282934)
@@ -544,6 +544,11 @@
#endif
}
++ (void)_setCachedProcessSuspensionDelayForTesting:(double)delayInSeconds
+{
+ WebKit::WebsiteDataStore::setCachedProcessSuspensionDelayForTesting(Seconds(delayInSeconds));
+}
+
- (void)_isRelationshipOnlyInDatabaseOnce:(NSURL *)firstPartyURL thirdParty:(NSURL *)thirdPartyURL completionHandler:(void (^)(BOOL))completionHandler
{
#if ENABLE(RESOURCE_LOAD_STATISTICS)
Modified: branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h (282933 => 282934)
--- branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2021-09-23 05:13:51 UTC (rev 282933)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2021-09-23 05:13:56 UTC (rev 282934)
@@ -82,6 +82,8 @@
- (void)_appBoundDomains:(void (^)(NSArray<NSString *> *))completionHandler WK_API_AVAILABLE(macos(11.0), ios(14.0));
- (void)_appBoundSchemes:(void (^)(NSArray<NSString *> *))completionHandler WK_API_AVAILABLE(macos(11.0), ios(14.0));
++ (void)_setCachedProcessSuspensionDelayForTesting:(double)delayInSeconds WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
- (void)_allowTLSCertificateChain:(NSArray *)certificateChain forHost:(NSString *)host WK_API_AVAILABLE(macos(12.0), ios(15.0));
- (void)_renameOrigin:(NSURL *)oldName to:(NSURL *)newName forDataOfTypes:(NSSet<NSString *> *)dataTypes completionHandler:(void (^)(void))completionHandler;
Modified: branches/safari-612-branch/Source/WebKit/UIProcess/WebProcessCache.cpp (282933 => 282934)
--- branches/safari-612-branch/Source/WebKit/UIProcess/WebProcessCache.cpp 2021-09-23 05:13:51 UTC (rev 282933)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/WebProcessCache.cpp 2021-09-23 05:13:56 UTC (rev 282934)
@@ -40,8 +40,13 @@
Seconds WebProcessCache::cachedProcessLifetime { 30_min };
Seconds WebProcessCache::clearingDelayAfterApplicationResignsActive { 5_min };
-static constexpr Seconds cachedProcessSuspensionDelay { 30_s };
+static Seconds cachedProcessSuspensionDelay { 30_s };
+void WebProcessCache::setCachedProcessSuspensionDelayForTesting(Seconds delay)
+{
+ cachedProcessSuspensionDelay = delay;
+}
+
static uint64_t generateAddRequestIdentifier()
{
static uint64_t identifier = 0;
@@ -133,6 +138,10 @@
m_processesPerRegistrableDomain.remove(it);
}
+#if PLATFORM(MAC)
+ cachedProcess->startSuspensionTimer();
+#endif
+
WEBPROCESSCACHE_RELEASE_LOG("addProcess: Added process to WebProcess cache (size=%u, capacity=%u)", cachedProcess->process().processIdentifier(), size() + 1, capacity());
m_processesPerRegistrableDomain.add(registrableDomain, WTFMove(cachedProcess));
@@ -268,9 +277,6 @@
RELEASE_ASSERT_WITH_MESSAGE(!m_process->websiteDataStore().processes().contains(*m_process), "Only processes with pages should be registered with the data store");
m_process->setIsInProcessCache(true);
m_evictionTimer.startOneShot(cachedProcessLifetime);
-#if PLATFORM(MAC)
- m_suspensionTimer.startOneShot(cachedProcessSuspensionDelay);
-#endif
}
WebProcessCache::CachedProcess::~CachedProcess()
@@ -311,6 +317,11 @@
}
#if PLATFORM(MAC)
+void WebProcessCache::CachedProcess::startSuspensionTimer()
+{
+ m_suspensionTimer.startOneShot(cachedProcessSuspensionDelay);
+}
+
void WebProcessCache::CachedProcess::suspensionTimerFired()
{
ASSERT(m_process);
Modified: branches/safari-612-branch/Source/WebKit/UIProcess/WebProcessCache.h (282933 => 282934)
--- branches/safari-612-branch/Source/WebKit/UIProcess/WebProcessCache.h 2021-09-23 05:13:51 UTC (rev 282933)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/WebProcessCache.h 2021-09-23 05:13:56 UTC (rev 282934)
@@ -58,6 +58,7 @@
enum class ShouldShutDownProcess { No, Yes };
void removeProcess(WebProcessProxy&, ShouldShutDownProcess);
+ static void setCachedProcessSuspensionDelayForTesting(Seconds);
private:
static Seconds cachedProcessLifetime;
@@ -71,6 +72,7 @@
Ref<WebProcessProxy> takeProcess();
WebProcessProxy& process() { ASSERT(m_process); return *m_process; }
+ void startSuspensionTimer();
#if PLATFORM(MAC)
bool isSuspended() const { return !m_suspensionTimer.isActive(); }
Modified: branches/safari-612-branch/Source/WebKit/UIProcess/WebProcessPool.cpp (282933 => 282934)
--- branches/safari-612-branch/Source/WebKit/UIProcess/WebProcessPool.cpp 2021-09-23 05:13:51 UTC (rev 282933)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/WebProcessPool.cpp 2021-09-23 05:13:56 UTC (rev 282934)
@@ -2038,8 +2038,12 @@
{
auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
- for (auto& process : processes())
+ for (auto& process : processes()) {
+ if (!process->pageCount())
+ continue;
+
process->sendWithAsyncReply(Messages::WebProcess::SendResourceLoadStatisticsDataImmediately(), [callbackAggregator] { });
+ }
}
#endif
Modified: branches/safari-612-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (282933 => 282934)
--- branches/safari-612-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2021-09-23 05:13:51 UTC (rev 282933)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2021-09-23 05:13:56 UTC (rev 282934)
@@ -1593,6 +1593,11 @@
}
#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
+void WebsiteDataStore::setCachedProcessSuspensionDelayForTesting(Seconds delay)
+{
+ WebProcessCache::setCachedProcessSuspensionDelayForTesting(delay);
+}
+
void WebsiteDataStore::syncLocalStorage(CompletionHandler<void()>&& completionHandler)
{
networkProcess().sendWithAsyncReply(Messages::NetworkProcess::SyncLocalStorage(), WTFMove(completionHandler));
Modified: branches/safari-612-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (282933 => 282934)
--- branches/safari-612-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2021-09-23 05:13:51 UTC (rev 282933)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2021-09-23 05:13:56 UTC (rev 282934)
@@ -260,6 +260,8 @@
const String& resolvedModelElementCacheDirectory() const { return m_resolvedConfiguration->modelElementCacheDirectory(); }
#endif
+ static void setCachedProcessSuspensionDelayForTesting(Seconds);
+
void allowSpecificHTTPSCertificateForHost(const WebCertificateInfo*, const String& host);
DeviceIdHashSaltStorage& deviceIdHashSaltStorage() { return m_deviceIdHashSaltStorage.get(); }
Modified: branches/safari-612-branch/Tools/ChangeLog (282933 => 282934)
--- branches/safari-612-branch/Tools/ChangeLog 2021-09-23 05:13:51 UTC (rev 282933)
+++ branches/safari-612-branch/Tools/ChangeLog 2021-09-23 05:13:56 UTC (rev 282934)
@@ -1,5 +1,59 @@
2021-09-22 Alan Coon <alanc...@apple.com>
+ Cherry-pick r282034. rdar://problem/83429808
+
+ Safari’s Privacy Report window is completely blank
+ https://bugs.webkit.org/show_bug.cgi?id=229847
+ <rdar://problem/80974688>
+
+ Reviewed by Chris Dumez.
+
+ Source/WebKit:
+
+ We should not wait for an IPC reply on a cached web process, because
+ it will cause long hangs.
+
+ In order to test this I added a new SPI to update the
+ cachedProcessSuspensionDelay (the usual timeout is 30 seconds). I also
+ moved the initial suspension timer call to be after the responsiveness
+ check, otherwise the cached process will be resumed very soon.
+
+ * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+ (+[WKWebsiteDataStore _setCachedProcessSuspensionDelayForTesting:]):
+ * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
+ * UIProcess/WebProcessCache.cpp:
+ (WebKit::WebProcessCache::setCachedProcessSuspensionDelayForTesting):
+ (WebKit::WebProcessCache::addProcess):
+ (WebKit::WebProcessCache::CachedProcess::CachedProcess):
+ (WebKit::WebProcessCache::CachedProcess::startSuspensionTimer):
+ * UIProcess/WebProcessCache.h:
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::sendResourceLoadStatisticsDataImmediately):
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::setCachedProcessSuspensionDelayForTesting):
+ * UIProcess/WebsiteData/WebsiteDataStore.h:
+
+ Tools:
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:
+ (TEST):
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@282034 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2021-09-03 Kate Cheney <katherine_che...@apple.com>
+
+ Safari’s Privacy Report window is completely blank
+ https://bugs.webkit.org/show_bug.cgi?id=229847
+ <rdar://problem/80974688>
+
+ Reviewed by Chris Dumez.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:
+ (TEST):
+
+2021-09-22 Alan Coon <alanc...@apple.com>
+
Cherry-pick r282365. rdar://problem/83429982
Crash under WebPage::runJavaScript()
Modified: branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm (282933 => 282934)
--- branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm 2021-09-23 05:13:51 UTC (rev 282933)
+++ branches/safari-612-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm 2021-09-23 05:13:56 UTC (rev 282934)
@@ -38,6 +38,7 @@
#import <WebKit/_WKProcessPoolConfiguration.h>
#import <WebKit/_WKWebsiteDataStoreConfiguration.h>
#import <wtf/RetainPtr.h>
+#import <wtf/text/StringConcatenateNumbers.h>
static bool finishedNavigation = false;
@@ -1337,6 +1338,62 @@
@end
+#if PLATFORM(MAC)
+TEST(ResourceLoadStatistics, DataSummaryWithCachedProcess)
+{
+ auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
+ processPoolConfiguration.get().processSwapsOnNavigation = YES;
+ processPoolConfiguration.get().usesWebProcessCache = YES;
+ processPoolConfiguration.get().processSwapsOnNavigationWithinSameNonHTTPFamilyProtocol = YES;
+ processPoolConfiguration.get().prewarmsProcessesAutomatically = NO;
+ auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+
+ EXPECT_GT([processPool _maximumSuspendedPageCount], 0u);
+ EXPECT_GT([processPool _processCacheCapacity], 0u);
+
+ auto *dataStore = [WKWebsiteDataStore defaultDataStore];
+ [WKWebsiteDataStore _setCachedProcessSuspensionDelayForTesting:0];
+
+ auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ [webViewConfiguration setProcessPool:processPool.get()];
+ [webViewConfiguration setWebsiteDataStore:dataStore];
+
+ auto handler = adoptNS([[ResourceLoadStatisticsSchemeHandler alloc] init]);
+
+ const unsigned maxSuspendedPageCount = [processPool _maximumSuspendedPageCount];
+ [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"resource-load-statistics"];
+
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+ auto delegate = adoptNS([[TestNavigationDelegate alloc] init]);
+ [webView setNavigationDelegate:delegate.get()];
+
+ for (unsigned i = 0; i < maxSuspendedPageCount + 1; i++) {
+ NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:makeString("resource-load-statistics://www.domain-", i, ".com")]];
+ [webView loadRequest:request];
+ [delegate waitForDidFinishNavigation];
+
+ EXPECT_EQ(i + 1, [processPool _webProcessCount]);
+ EXPECT_EQ(i + 1, [processPool _webProcessCountIgnoringPrewarmedAndCached]);
+ EXPECT_FALSE([processPool _hasPrewarmedWebProcess]);
+ }
+
+ NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:makeString("resource-load-statistics://www.domain-", maxSuspendedPageCount + 1, ".com")]];
+ [webView loadRequest:request];
+ [delegate waitForDidFinishNavigation];
+
+ // This will timeout if waiting for IPC from a cached process.
+ static bool doneFlag = false;
+ [dataStore _getResourceLoadStatisticsDataSummary:^void(NSArray<_WKResourceLoadStatisticsThirdParty *> *thirdPartyData)
+ {
+ doneFlag = true;
+ }];
+
+ TestWebKitAPI::Util::run(&doneFlag);
+
+ [WKWebsiteDataStore _setCachedProcessSuspensionDelayForTesting:30];
+}
+#endif
+
TEST(ResourceLoadStatistics, BackForwardPerPageData)
{
auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);