Diff
Modified: trunk/LayoutTests/ChangeLog (250413 => 250414)
--- trunk/LayoutTests/ChangeLog 2019-09-27 05:13:10 UTC (rev 250413)
+++ trunk/LayoutTests/ChangeLog 2019-09-27 06:17:17 UTC (rev 250414)
@@ -1,3 +1,16 @@
+2019-09-26 Chris Dumez <[email protected]>
+
+ Pages frequently fails to enter the back/forward cache due to pending loads
+ https://bugs.webkit.org/show_bug.cgi?id=202289
+ <rdar://problem/55758506>
+
+ Reviewed by Geoffrey Garen.
+
+ Add layout test coverage.
+
+ * http/tests/navigation/page-cache-pending-load-expected.txt: Added.
+ * http/tests/navigation/page-cache-pending-load.html: Added.
+
2019-09-26 Kate Cheney <[email protected]>
Resource Load Statistics: Downgrade all third-party referrer headers
Added: trunk/LayoutTests/http/tests/navigation/page-cache-pending-load-expected.txt (0 => 250414)
--- trunk/LayoutTests/http/tests/navigation/page-cache-pending-load-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/navigation/page-cache-pending-load-expected.txt 2019-09-27 06:17:17 UTC (rev 250414)
@@ -0,0 +1,13 @@
+Tests that a page with pending subresource loads goes into the page cache.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+pageshow - not from cache
+pagehide - entering cache
+pageshow - from cache
+PASS Page did enter and was restored from the page cache
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/navigation/page-cache-pending-load.html (0 => 250414)
--- trunk/LayoutTests/http/tests/navigation/page-cache-pending-load.html (rev 0)
+++ trunk/LayoutTests/http/tests/navigation/page-cache-pending-load.html 2019-09-27 06:17:17 UTC (rev 250414)
@@ -0,0 +1,54 @@
+<!-- webkit-test-runner [ enablePageCache=true ] -->
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<script src=""
+<script>
+description('Tests that a page with pending subresource loads goes into the page cache.');
+window.jsTestIsAsync = true;
+
+window.addEventListener("pageshow", function(event) {
+ debug("pageshow - " + (event.persisted ? "" : "not ") + "from cache");
+
+ if (event.persisted) {
+ testPassed("Page did enter and was restored from the page cache");
+ setTimeout(function() {
+ finishJSTest();
+ }, 0);
+ }
+}, false);
+
+window.addEventListener("pagehide", function(event) {
+ debug("pagehide - " + (event.persisted ? "" : "not ") + "entering cache");
+ if (!event.persisted) {
+ testFailed("Page did not enter the page cache.");
+ finishJSTest();
+ }
+}, false);
+
+window.addEventListener('load', function() {
+ var link = document.createElement("link");
+ link.rel = "stylesheet";
+ link.type = "text/css";
+ link.href = ""
+ document.head.appendChild(link);
+
+ var script = document.createElement("script");
+ script.async = true;
+ script.src = ""
+ document.head.appendChild(script);
+
+ // This needs to happen in a setTimeout because a navigation inside the onload handler would
+ // not create a history entry.
+ setTimeout(function() {
+ // Force a back navigation back to this page.
+ window.location.href = ""
+ }, 0);
+}, false);
+
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (250413 => 250414)
--- trunk/Source/WebCore/ChangeLog 2019-09-27 05:13:10 UTC (rev 250413)
+++ trunk/Source/WebCore/ChangeLog 2019-09-27 06:17:17 UTC (rev 250414)
@@ -1,3 +1,37 @@
+2019-09-26 Chris Dumez <[email protected]>
+
+ Pages frequently fails to enter the back/forward cache due to pending loads
+ https://bugs.webkit.org/show_bug.cgi?id=202289
+ <rdar://problem/55758506>
+
+ Reviewed by Geoffrey Garen.
+
+ Allow pages to enter the back / forward cache, even if they have pending loads.
+ Note that these pending loads get cancelled. Also note that we won't enter page
+ cache unless the 'load' event has been fired in the main frame, since a
+ HistoryItem would not get created otherwise. This was causing frequent transient
+ failures to enter the back / forward cache while browsing (e.g. on weather.com).
+
+ Test: http/tests/navigation/page-cache-pending-load.html
+
+ * history/PageCache.cpp:
+ (WebCore::canCacheFrame):
+ * loader/CrossOriginPreflightChecker.cpp:
+ * loader/CrossOriginPreflightChecker.h:
+ * loader/DocumentLoader.cpp:
+ (WebCore::DocumentLoader::setMainDocumentError):
+ (WebCore::DocumentLoader::stopLoading):
+ * loader/DocumentLoader.h:
+ * loader/DocumentThreadableLoader.cpp:
+ * loader/DocumentThreadableLoader.h:
+ * loader/cache/CachedResource.cpp:
+ * loader/cache/CachedResource.h:
+ * loader/cache/CachedResourceClient.h:
+ (WebCore::CachedResourceClient::deprecatedDidReceiveCachedResource):
+ * page/DiagnosticLoggingKeys.cpp:
+ (WebCore::DiagnosticLoggingKeys::mainFrameHasNotFinishedLoadingKey):
+ * page/DiagnosticLoggingKeys.h:
+
2019-09-26 Zalan Bujtas <[email protected]>
[LFC][IFC] Line::Run should have a reference to the associated InlineItem
Modified: trunk/Source/WebCore/history/PageCache.cpp (250413 => 250414)
--- trunk/Source/WebCore/history/PageCache.cpp 2019-09-27 05:13:10 UTC (rev 250413)
+++ trunk/Source/WebCore/history/PageCache.cpp 2019-09-27 06:17:17 UTC (rev 250414)
@@ -116,15 +116,6 @@
PCLOG(" Determining if subframe with URL (", currentURL.string(), ") can be cached:");
bool isCacheable = true;
- if (!documentLoader->mainDocumentError().isNull()) {
- PCLOG(" -Main document has an error");
- logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::mainDocumentErrorKey());
-
- if (documentLoader->mainDocumentError().isCancellation() && documentLoader->subresourceLoadersArePageCacheAcceptable())
- PCLOG(" -But, it was a cancellation and all loaders during the cancelation were loading images or XHR.");
- else
- isCacheable = false;
- }
// Do not cache error pages (these can be recognized as pages with substitute data or unreachable URLs).
if (documentLoader->substituteData().isValid() && !documentLoader->substituteData().failingURL().isEmpty()) {
PCLOG(" -Frame is an error page");
Modified: trunk/Source/WebCore/loader/CrossOriginPreflightChecker.cpp (250413 => 250414)
--- trunk/Source/WebCore/loader/CrossOriginPreflightChecker.cpp 2019-09-27 05:13:10 UTC (rev 250413)
+++ trunk/Source/WebCore/loader/CrossOriginPreflightChecker.cpp 2019-09-27 06:17:17 UTC (rev 250414)
@@ -169,9 +169,4 @@
m_resource->setDefersLoading(value);
}
-bool CrossOriginPreflightChecker::isXMLHttpRequest() const
-{
- return m_loader.isXMLHttpRequest();
-}
-
} // namespace WebCore
Modified: trunk/Source/WebCore/loader/CrossOriginPreflightChecker.h (250413 => 250414)
--- trunk/Source/WebCore/loader/CrossOriginPreflightChecker.h 2019-09-27 05:13:10 UTC (rev 250413)
+++ trunk/Source/WebCore/loader/CrossOriginPreflightChecker.h 2019-09-27 06:17:17 UTC (rev 250414)
@@ -59,8 +59,6 @@
static void handleLoadingFailure(DocumentThreadableLoader&, unsigned long, const ResourceError&);
static void validatePreflightResponse(DocumentThreadableLoader&, ResourceRequest&&, unsigned long, const ResourceResponse&);
- bool isXMLHttpRequest() const final;
-
DocumentThreadableLoader& m_loader;
CachedResourceHandle<CachedRawResource> m_resource;
ResourceRequest m_request;
Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (250413 => 250414)
--- trunk/Source/WebCore/loader/DocumentLoader.cpp 2019-09-27 05:13:10 UTC (rev 250413)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp 2019-09-27 06:17:17 UTC (rev 250414)
@@ -125,60 +125,6 @@
loader->setDefersLoading(defers);
}
-static bool shouldPendingCachedResourceLoadPreventPageCache(CachedResource& cachedResource)
-{
- if (!cachedResource.isLoading())
- return false;
-
- switch (cachedResource.type()) {
- case CachedResource::Type::ImageResource:
- case CachedResource::Type::Icon:
- case CachedResource::Type::Beacon:
- case CachedResource::Type::Ping:
- case CachedResource::Type::LinkPrefetch:
- return false;
- case CachedResource::Type::MainResource:
- case CachedResource::Type::CSSStyleSheet:
- case CachedResource::Type::Script:
- case CachedResource::Type::FontResource:
-#if ENABLE(SVG_FONTS)
- case CachedResource::Type::SVGFontResource:
-#endif
- case CachedResource::Type::MediaResource:
- case CachedResource::Type::RawResource:
- case CachedResource::Type::SVGDocumentResource:
-#if ENABLE(XSLT)
- case CachedResource::Type::XSLStyleSheet:
-#endif
-#if ENABLE(VIDEO_TRACK)
- case CachedResource::Type::TextTrackResource:
-#endif
-#if ENABLE(APPLICATION_MANIFEST)
- case CachedResource::Type::ApplicationManifest:
-#endif
- break;
- };
- return !cachedResource.areAllClientsXMLHttpRequests();
-}
-
-static bool areAllLoadersPageCacheAcceptable(const ResourceLoaderMap& loaders)
-{
- for (auto& loader : copyToVector(loaders.values())) {
- if (!loader->frameLoader() || !loader->frameLoader()->frame().page())
- return false;
-
- CachedResource* cachedResource = MemoryCache::singleton().resourceForRequest(loader->request(), loader->frameLoader()->frame().page()->sessionID());
- if (!cachedResource)
- return false;
-
- // Only image and XHR loads do not prevent the page from entering the PageCache.
- // All non-image loads will prevent the page from entering the PageCache.
- if (shouldPendingCachedResourceLoadPreventPageCache(*cachedResource))
- return false;
- }
- return true;
-}
-
DocumentLoader::DocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData)
: FrameDestructionObserver(nullptr)
, m_cachedResourceLoader(CachedResourceLoader::create(this))
@@ -314,13 +260,6 @@
// to stop loading. Because of this, we need to save it so we don't return early.
bool loading = isLoading();
- // We may want to audit the existing subresource loaders when we are on a page which has completed
- // loading but there are subresource loads during cancellation. This must be done before the
- // frame->stopLoading() call, which may evict the CachedResources, which we rely on to check
- // the type of the resource loads.
- if (loading && m_committed && !mainResourceLoader() && !m_subresourceLoaders.isEmpty())
- m_subresourceLoadersArePageCacheAcceptable = areAllLoadersPageCacheAcceptable(m_subresourceLoaders);
-
if (m_committed) {
// Attempt to stop the frame if the document loader is loading, or if it is done loading but
// still parsing. Failure to do so can cause a world leak.
Modified: trunk/Source/WebCore/loader/DocumentLoader.h (250413 => 250414)
--- trunk/Source/WebCore/loader/DocumentLoader.h 2019-09-27 05:13:10 UTC (rev 250413)
+++ trunk/Source/WebCore/loader/DocumentLoader.h 2019-09-27 06:17:17 UTC (rev 250414)
@@ -268,8 +268,6 @@
bool didCreateGlobalHistoryEntry() const { return m_didCreateGlobalHistoryEntry; }
void setDidCreateGlobalHistoryEntry(bool didCreateGlobalHistoryEntry) { m_didCreateGlobalHistoryEntry = didCreateGlobalHistoryEntry; }
- bool subresourceLoadersArePageCacheAcceptable() const { return m_subresourceLoadersArePageCacheAcceptable; }
-
void setDefersLoading(bool);
void setMainResourceDataBufferingPolicy(DataBufferingPolicy);
Modified: trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp (250413 => 250414)
--- trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp 2019-09-27 05:13:10 UTC (rev 250413)
+++ trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp 2019-09-27 06:17:17 UTC (rev 250414)
@@ -655,11 +655,6 @@
return m_sameOriginRequest && securityOrigin().canRequest(url);
}
-bool DocumentThreadableLoader::isXMLHttpRequest() const
-{
- return m_options.initiator == cachedResourceRequestInitiators().xmlhttprequest;
-}
-
SecurityOrigin& DocumentThreadableLoader::securityOrigin() const
{
return m_origin ? *m_origin : m_document.securityOrigin();
Modified: trunk/Source/WebCore/loader/DocumentThreadableLoader.h (250413 => 250414)
--- trunk/Source/WebCore/loader/DocumentThreadableLoader.h 2019-09-27 05:13:10 UTC (rev 250413)
+++ trunk/Source/WebCore/loader/DocumentThreadableLoader.h 2019-09-27 06:17:17 UTC (rev 250414)
@@ -102,8 +102,6 @@
bool isAllowedRedirect(const URL&);
bool isAllowedByContentSecurityPolicy(const URL&, ContentSecurityPolicy::RedirectResponseReceived);
- bool isXMLHttpRequest() const final;
-
SecurityOrigin& securityOrigin() const;
const ContentSecurityPolicy& contentSecurityPolicy() const;
Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (250413 => 250414)
--- trunk/Source/WebCore/loader/cache/CachedResource.cpp 2019-09-27 05:13:10 UTC (rev 250413)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp 2019-09-27 06:17:17 UTC (rev 250414)
@@ -869,18 +869,6 @@
return sizeof(CachedResource) + m_response.memoryUsage() + kAverageClientsHashMapSize + m_resourceRequest.url().string().length() * 2;
}
-bool CachedResource::areAllClientsXMLHttpRequests() const
-{
- if (type() != Type::RawResource)
- return false;
-
- for (auto& client : m_clients) {
- if (!client.key->isXMLHttpRequest())
- return false;
- }
- return true;
-}
-
void CachedResource::setLoadPriority(const Optional<ResourceLoadPriority>& loadPriority)
{
if (loadPriority)
Modified: trunk/Source/WebCore/loader/cache/CachedResource.h (250413 => 250414)
--- trunk/Source/WebCore/loader/cache/CachedResource.h 2019-09-27 05:13:10 UTC (rev 250413)
+++ trunk/Source/WebCore/loader/cache/CachedResource.h 2019-09-27 06:17:17 UTC (rev 250414)
@@ -165,8 +165,6 @@
SubresourceLoader* loader() { return m_loader.get(); }
- bool areAllClientsXMLHttpRequests() const;
-
bool isImage() const { return type() == Type::ImageResource; }
// FIXME: CachedRawResource could be a main resource, an audio/video resource, or a raw XHR/icon resource.
bool isMainOrMediaOrIconOrRawResource() const { return type() == Type::MainResource || type() == Type::MediaResource || type() == Type::Icon || type() == Type::RawResource || type() == Type::Beacon || type() == Type::Ping; }
Modified: trunk/Source/WebCore/loader/cache/CachedResourceClient.h (250413 => 250414)
--- trunk/Source/WebCore/loader/cache/CachedResourceClient.h 2019-09-27 05:13:10 UTC (rev 250413)
+++ trunk/Source/WebCore/loader/cache/CachedResourceClient.h 2019-09-27 06:17:17 UTC (rev 250414)
@@ -41,7 +41,6 @@
virtual ~CachedResourceClient() = default;
virtual void notifyFinished(CachedResource&) { }
virtual void deprecatedDidReceiveCachedResource(CachedResource&) { }
- virtual bool isXMLHttpRequest() const { return false; }
static CachedResourceClientType expectedType() { return BaseResourceType; }
virtual CachedResourceClientType resourceClientType() const { return expectedType(); }
Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp (250413 => 250414)
--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp 2019-09-27 05:13:10 UTC (rev 250413)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp 2019-09-27 06:17:17 UTC (rev 250414)
@@ -233,11 +233,6 @@
return "other"_s;
}
-String DiagnosticLoggingKeys::mainDocumentErrorKey()
-{
- return "mainDocumentError"_s;
-}
-
String DiagnosticLoggingKeys::mainResourceKey()
{
return "mainResource"_s;
Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.h (250413 => 250414)
--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.h 2019-09-27 05:13:10 UTC (rev 250413)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.h 2019-09-27 06:17:17 UTC (rev 250414)
@@ -88,7 +88,6 @@
WEBCORE_EXPORT static String isReloadIgnoringCacheDataKey();
static String loadingKey();
static String isLoadingKey();
- static String mainDocumentErrorKey();
static String mainResourceKey();
static String mediaLoadedKey();
static String mediaLoadingFailedKey();