Title: [208049] trunk
Revision
208049
Author
[email protected]
Date
2016-10-28 08:39:27 -0700 (Fri, 28 Oct 2016)

Log Message

Always use iOS preload behavior
https://bugs.webkit.org/show_bug.cgi?id=164127

Reviewed by Andreas Kling.

Source/WebCore:

On non-iOS platforms we were delaying issuing lower priority preload (images mostly) until document has body.
This should be unnecessary as networking layer prioritization should ensure higher priority resources are
loaded earlier. Testing on iOS has showed that more aggressive behavior is a win.

This patch switches to iOS behavior on all platforms (and simplified the logic).

* html/parser/HTMLResourcePreloader.cpp:
(WebCore::HTMLResourcePreloader::preload):
* loader/LinkLoader.cpp:
(WebCore::LinkLoader::preloadIfNeeded):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::performPostLoadActions):
(WebCore::CachedResourceLoader::preload):
(WebCore::CachedResourceLoader::isPreloaded):
(WebCore::CachedResourceLoader::checkForPendingPreloads): Deleted.
(WebCore::CachedResourceLoader::requestPreload): Deleted.
(WebCore::CachedResourceLoader::clearPendingPreloads): Deleted.
* loader/cache/CachedResourceLoader.h:

LayoutTests:

* http/tests/webgl/1.0.2/readPixelsBadArgs-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (208048 => 208049)


--- trunk/LayoutTests/ChangeLog	2016-10-28 15:11:21 UTC (rev 208048)
+++ trunk/LayoutTests/ChangeLog	2016-10-28 15:39:27 UTC (rev 208049)
@@ -1,3 +1,12 @@
+2016-10-28  Antti Koivisto  <[email protected]>
+
+        Always use iOS preload behavior
+        https://bugs.webkit.org/show_bug.cgi?id=164127
+
+        Reviewed by Andreas Kling.
+
+        * http/tests/webgl/1.0.2/readPixelsBadArgs-expected.txt:
+
 2016-10-28  Antoine Quint  <[email protected]>
 
         [Modern Media Controls] Media Controller: scrubbing support

Modified: trunk/LayoutTests/http/tests/webgl/1.0.2/readPixelsBadArgs-expected.txt (208048 => 208049)


--- trunk/LayoutTests/http/tests/webgl/1.0.2/readPixelsBadArgs-expected.txt	2016-10-28 15:11:21 UTC (rev 208048)
+++ trunk/LayoutTests/http/tests/webgl/1.0.2/readPixelsBadArgs-expected.txt	2016-10-28 15:39:27 UTC (rev 208049)
@@ -1,4 +1,5 @@
 Blocked access to external URL http://www.opengl.org/img/opengl_logo.jpg
+Blocked access to external URL http://www.opengl.org/img/opengl_logo.jpg
 This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.
 
 Test: resources/webgl_test_files/conformance/more/functions/readPixelsBadArgs.html

Modified: trunk/Source/WebCore/ChangeLog (208048 => 208049)


--- trunk/Source/WebCore/ChangeLog	2016-10-28 15:11:21 UTC (rev 208048)
+++ trunk/Source/WebCore/ChangeLog	2016-10-28 15:39:27 UTC (rev 208049)
@@ -1,3 +1,29 @@
+2016-10-28  Antti Koivisto  <[email protected]>
+
+        Always use iOS preload behavior
+        https://bugs.webkit.org/show_bug.cgi?id=164127
+
+        Reviewed by Andreas Kling.
+
+        On non-iOS platforms we were delaying issuing lower priority preload (images mostly) until document has body.
+        This should be unnecessary as networking layer prioritization should ensure higher priority resources are
+        loaded earlier. Testing on iOS has showed that more aggressive behavior is a win.
+
+        This patch switches to iOS behavior on all platforms (and simplified the logic).
+
+        * html/parser/HTMLResourcePreloader.cpp:
+        (WebCore::HTMLResourcePreloader::preload):
+        * loader/LinkLoader.cpp:
+        (WebCore::LinkLoader::preloadIfNeeded):
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::performPostLoadActions):
+        (WebCore::CachedResourceLoader::preload):
+        (WebCore::CachedResourceLoader::isPreloaded):
+        (WebCore::CachedResourceLoader::checkForPendingPreloads): Deleted.
+        (WebCore::CachedResourceLoader::requestPreload): Deleted.
+        (WebCore::CachedResourceLoader::clearPendingPreloads): Deleted.
+        * loader/cache/CachedResourceLoader.h:
+
 2016-10-28  Youenn Fablet  <[email protected]>
 
         [Fetch] Ensure redirection count is no more than 20 in case of cross origin requests

Modified: trunk/Source/WebCore/html/parser/HTMLResourcePreloader.cpp (208048 => 208049)


--- trunk/Source/WebCore/html/parser/HTMLResourcePreloader.cpp	2016-10-28 15:11:21 UTC (rev 208048)
+++ trunk/Source/WebCore/html/parser/HTMLResourcePreloader.cpp	2016-10-28 15:39:27 UTC (rev 208049)
@@ -68,7 +68,7 @@
     if (!preload->media().isEmpty() && !mediaAttributeMatches(m_document, &m_document.renderView()->style(), preload->media()))
         return;
 
-    m_document.cachedResourceLoader().preload(preload->resourceType(), preload->resourceRequest(m_document), CachedResourceLoader::ImplicitPreload);
+    m_document.cachedResourceLoader().preload(preload->resourceType(), preload->resourceRequest(m_document));
 }
 
 

Modified: trunk/Source/WebCore/loader/LinkLoader.cpp (208048 => 208049)


--- trunk/Source/WebCore/loader/LinkLoader.cpp	2016-10-28 15:11:21 UTC (rev 208048)
+++ trunk/Source/WebCore/loader/LinkLoader.cpp	2016-10-28 15:39:27 UTC (rev 208049)
@@ -162,7 +162,7 @@
     linkRequest.setInitiator("link");
 
     linkRequest.setAsPotentiallyCrossOrigin(crossOriginMode, document);
-    CachedResourceHandle<CachedResource> cachedLinkResource = document.cachedResourceLoader().preload(type.value(), WTFMove(linkRequest), CachedResourceLoader::ExplicitPreload);
+    CachedResourceHandle<CachedResource> cachedLinkResource = document.cachedResourceLoader().preload(type.value(), WTFMove(linkRequest));
 
     if (cachedLinkResource)
         m_preloadResourceClient = createLinkPreloadResourceClient(*cachedLinkResource, *this, type.value());

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (208048 => 208049)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2016-10-28 15:11:21 UTC (rev 208048)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2016-10-28 15:39:27 UTC (rev 208049)
@@ -1189,8 +1189,6 @@
 
 void CachedResourceLoader::performPostLoadActions()
 {
-    checkForPendingPreloads();
-
     platformStrategies()->loaderStrategy()->servePendingRequests();
 }
 
@@ -1211,51 +1209,8 @@
     ASSERT(m_requestCount > -1);
 }
 
-CachedResourceHandle<CachedResource> CachedResourceLoader::preload(CachedResource::Type type, CachedResourceRequest&& request, PreloadType preloadType)
+CachedResourceHandle<CachedResource> CachedResourceLoader::preload(CachedResource::Type type, CachedResourceRequest&& request)
 {
-    // We always preload resources on iOS. See <https://bugs.webkit.org/show_bug.cgi?id=91276>.
-    // FIXME: We should consider adding a setting to toggle aggressive preloading behavior as opposed
-    // to making this behavior specific to iOS.
-#if !PLATFORM(IOS)
-    bool hasRendering = m_document->bodyOrFrameset() && m_document->renderView();
-    bool canBlockParser = type == CachedResource::Script || type == CachedResource::CSSStyleSheet;
-    if (!hasRendering && !canBlockParser && preloadType == ImplicitPreload) {
-        // Don't preload subresources that can't block the parser before we have something to draw.
-        // This helps prevent preloads from delaying first display when bandwidth is limited.
-        PendingPreload pendingPreload = { type, WTFMove(request) };
-        m_pendingPreloads.append(pendingPreload);
-        return nullptr;
-    }
-#else
-    UNUSED_PARAM(preloadType);
-#endif
-    return requestPreload(type, WTFMove(request));
-}
-
-void CachedResourceLoader::checkForPendingPreloads()
-{
-    if (m_pendingPreloads.isEmpty())
-        return;
-    auto* body = m_document->bodyOrFrameset();
-    if (!body || !body->renderer())
-        return;
-#if PLATFORM(IOS)
-    // We always preload resources on iOS. See <https://bugs.webkit.org/show_bug.cgi?id=91276>.
-    // So, we should never have any pending preloads.
-    // FIXME: We should look to avoid compiling this code entirely when building for iOS.
-    ASSERT_NOT_REACHED();
-#endif
-    while (!m_pendingPreloads.isEmpty()) {
-        PendingPreload preload = m_pendingPreloads.takeFirst();
-        // Don't request preload if the resource already loaded normally (this will result in double load if the page is being reloaded with cached results ignored).
-        if (!cachedResource(preload.m_request.resourceRequest().url()))
-            requestPreload(preload.m_type, WTFMove(preload.m_request));
-    }
-    m_pendingPreloads.clear();
-}
-
-CachedResourceHandle<CachedResource> CachedResourceLoader::requestPreload(CachedResource::Type type, CachedResourceRequest&& request)
-{
     if (request.charset().isEmpty() && (type == CachedResource::Script || type == CachedResource::CSSStyleSheet))
         request.setCharset(m_document->charset());
 
@@ -1287,11 +1242,6 @@
                 return true;
         }
     }
-
-    for (auto& pendingPreload : m_pendingPreloads) {
-        if (pendingPreload.m_request.resourceRequest().url() == url)
-            return true;
-    }
     return false;
 }
 
@@ -1312,11 +1262,6 @@
     m_preloads = nullptr;
 }
 
-void CachedResourceLoader::clearPendingPreloads()
-{
-    m_pendingPreloads.clear();
-}
-
 #if PRELOAD_DEBUG
 void CachedResourceLoader::printPreloadStats()
 {

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.h (208048 => 208049)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.h	2016-10-28 15:11:21 UTC (rev 208048)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.h	2016-10-28 15:39:27 UTC (rev 208049)
@@ -130,10 +130,7 @@
 
     WEBCORE_EXPORT bool isPreloaded(const String& urlString) const;
     void clearPreloads();
-    void clearPendingPreloads();
-    enum PreloadType { ImplicitPreload, ExplicitPreload };
-    CachedResourceHandle<CachedResource> preload(CachedResource::Type, CachedResourceRequest&&, PreloadType);
-    void checkForPendingPreloads();
+    CachedResourceHandle<CachedResource> preload(CachedResource::Type, CachedResourceRequest&&);
     void printPreloadStats();
 
     bool updateRequestAfterRedirection(CachedResource::Type, ResourceRequest&, const ResourceLoaderOptions&);
@@ -157,7 +154,6 @@
     CachedResourceHandle<CachedResource> requestResource(CachedResource::Type, CachedResourceRequest&&, ForPreload = ForPreload::No, DeferOption = DeferOption::NoDefer);
     CachedResourceHandle<CachedResource> revalidateResource(CachedResourceRequest&&, CachedResource&);
     CachedResourceHandle<CachedResource> loadResource(CachedResource::Type, CachedResourceRequest&&);
-    CachedResourceHandle<CachedResource> requestPreload(CachedResource::Type, CachedResourceRequest&&);
 
     void prepareFetch(CachedResource::Type, CachedResourceRequest&);
     void updateHTTPRequestHeaders(CachedResource::Type, CachedResourceRequest&);
@@ -191,11 +187,6 @@
     int m_requestCount;
     
     std::unique_ptr<ListHashSet<CachedResource*>> m_preloads;
-    struct PendingPreload {
-        CachedResource::Type m_type;
-        CachedResourceRequest m_request;
-    };
-    Deque<PendingPreload> m_pendingPreloads;
 
     Timer m_garbageCollectDocumentResourcesTimer;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to