Title: [233738] trunk
Revision
233738
Author
jer.no...@apple.com
Date
2018-07-11 12:29:58 -0700 (Wed, 11 Jul 2018)

Log Message

Disable all network caching for HLS streams.
https://bugs.webkit.org/show_bug.cgi?id=187544
<rdar://problem/41863600>

Reviewed by Chris Dumez.

Source/WebKit:

Revert the behavior added in r215263 where Media responses are cached if they are from
a resource whose expected content length is <4MB.

* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::makeStoreDecision):
(WebKit::NetworkCache::expectedTotalResourceSizeFromContentRange): Deleted.

LayoutTests:

* http/tests/cache/disk-cache/disk-cache-media-small-expected.txt:
* http/tests/cache/disk-cache/disk-cache-media-small.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (233737 => 233738)


--- trunk/LayoutTests/ChangeLog	2018-07-11 19:22:07 UTC (rev 233737)
+++ trunk/LayoutTests/ChangeLog	2018-07-11 19:29:58 UTC (rev 233738)
@@ -1,3 +1,14 @@
+2018-07-11  Jer Noble  <jer.no...@apple.com>
+
+        Disable all network caching for HLS streams.
+        https://bugs.webkit.org/show_bug.cgi?id=187544
+        <rdar://problem/41863600>
+
+        Reviewed by Chris Dumez.
+
+        * http/tests/cache/disk-cache/disk-cache-media-small-expected.txt:
+        * http/tests/cache/disk-cache/disk-cache-media-small.html:
+
 2018-07-11  Ms2ger  <ms2...@igalia.com>
 
         [GTK] Unreviewed test gardening

Modified: trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-media-small-expected.txt (233737 => 233738)


--- trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-media-small-expected.txt	2018-07-11 19:22:07 UTC (rev 233737)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-media-small-expected.txt	2018-07-11 19:29:58 UTC (rev 233738)
@@ -1,5 +1,5 @@
 First load
 PASS: All response ranges from: Network
 Second Load
-PASS: All response ranges from: Disk cache
+PASS: All response ranges from: Network
  

Modified: trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-media-small.html (233737 => 233738)


--- trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-media-small.html	2018-07-11 19:22:07 UTC (rev 233737)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-media-small.html	2018-07-11 19:29:58 UTC (rev 233738)
@@ -43,7 +43,7 @@
     logResponses(await loadTestMedia(), "Network");
 
     logdiv.innerHTML += "Second Load<br>";
-    logResponses(await loadTestMedia(), "Disk cache");
+    logResponses(await loadTestMedia(), "Network");
 
     testRunner.notifyDone();
 }

Modified: trunk/Source/WebKit/ChangeLog (233737 => 233738)


--- trunk/Source/WebKit/ChangeLog	2018-07-11 19:22:07 UTC (rev 233737)
+++ trunk/Source/WebKit/ChangeLog	2018-07-11 19:29:58 UTC (rev 233738)
@@ -1,3 +1,18 @@
+2018-07-11  Jer Noble  <jer.no...@apple.com>
+
+        Disable all network caching for HLS streams.
+        https://bugs.webkit.org/show_bug.cgi?id=187544
+        <rdar://problem/41863600>
+
+        Reviewed by Chris Dumez.
+
+        Revert the behavior added in r215263 where Media responses are cached if they are from
+        a resource whose expected content length is <4MB.
+
+        * NetworkProcess/cache/NetworkCache.cpp:
+        (WebKit::NetworkCache::makeStoreDecision):
+        (WebKit::NetworkCache::expectedTotalResourceSizeFromContentRange): Deleted.
+
 2018-07-11  Zan Dobersek  <zdober...@igalia.com>
 
         [WPE] AC for fixed-position elements is not enabled

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp (233737 => 233738)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp	2018-07-11 19:22:07 UTC (rev 233737)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp	2018-07-11 19:29:58 UTC (rev 233738)
@@ -225,33 +225,6 @@
     return startsWithLettersIgnoringASCIICase(type, "video/") || startsWithLettersIgnoringASCIICase(type, "audio/");
 }
 
-static std::optional<size_t> expectedTotalResourceSizeFromContentRange(const WebCore::ResourceResponse& response)
-{
-    ASSERT(response.httpStatusCode() == 206);
-
-    auto contentRange = response.httpHeaderField(WebCore::HTTPHeaderName::ContentRange);
-    if (contentRange.isNull())
-        return { };
-
-    if (!contentRange.startsWith("bytes "))
-        return { };
-
-    auto slashPosition = contentRange.find('/');
-    if (slashPosition == notFound)
-        return { };
-
-    auto sizeStringLength = contentRange.length() - slashPosition - 1;
-    if (!sizeStringLength)
-        return { };
-
-    bool isValid;
-    auto size = StringView(contentRange).right(sizeStringLength).toIntStrict(isValid);
-    if (!isValid)
-        return { };
-
-    return size;
-}
-
 static StoreDecision makeStoreDecision(const WebCore::ResourceRequest& originalRequest, const WebCore::ResourceResponse& response, size_t bodySize)
 {
     if (!originalRequest.url().protocolIsInHTTPFamily() || !response.isHTTP())
@@ -286,25 +259,15 @@
             return StoreDecision::NoDueToUnlikelyToReuse;
     }
 
+    // Media loaded via XHR is likely being used for MSE streaming (YouTube and Netflix for example).
     // Streaming media fills the cache quickly and is unlikely to be reused.
     // FIXME: We should introduce a separate media cache partition that doesn't affect other resources.
     // FIXME: We should also make sure make the MSE paths are copy-free so we can use mapped buffers from disk effectively.
     auto requester = originalRequest.requester();
-    bool isDefinitelyMedia = requester == WebCore::ResourceRequest::Requester::Media;
-    if (isDefinitelyMedia) {
-        // Allow caching of smaller media files if we know the total size.
-        const size_t maximumCacheableMediaSize = 5 * 1024 * 1024;
-        auto totalSize = response.httpStatusCode() == 206 ? expectedTotalResourceSizeFromContentRange(response) : bodySize;
-        if (!totalSize || *totalSize > maximumCacheableMediaSize)
-            return StoreDecision::NoDueToStreamingMedia;
-    }
-
+    bool isDefinitelyStreamingMedia = requester == WebCore::ResourceRequest::Requester::Media;
     bool isLikelyStreamingMedia = requester == WebCore::ResourceRequest::Requester::XHR && isMediaMIMEType(response.mimeType());
-    if (isLikelyStreamingMedia) {
-        // Media loaded via XHR is likely being used for MSE streaming (YouTube and Netflix for example).
-        // We have no way of knowing the total media size so disallow caching.
+    if (isLikelyStreamingMedia || isDefinitelyStreamingMedia)
         return StoreDecision::NoDueToStreamingMedia;
-    }
 
     return StoreDecision::Yes;
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to