Title: [287899] trunk/Source/WebCore
Revision
287899
Author
[email protected]
Date
2022-01-11 15:25:09 -0800 (Tue, 11 Jan 2022)

Log Message

DataURLResourceMediaLoader decodes the URL repeatedly during a video playback
https://bugs.webkit.org/show_bug.cgi?id=234940

Reviewed by Darin Adler.

In r264864, we adopted a new SPI to tell AVFoundation that the entire file is available for custom URLs.
As a result, during a video playback, AVFoundation will request small data ranges instead of "caching"
the whole file again.

However, that leads to efficiency issue for DataURLResourceMediaLoader. Because it needs to decode the whole
URL when AVFoundation requests a data range, which is inefficient when the URL is very long.

This patch reverts the change in r264864 for the DataURLResourceMediaLoader case to fix the performance issue.
If DataURLDecoder::decode() supports decoding a data range in the future, we can change it back for better
memory efficiency.

* platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
(WebCore::WebCoreAVFResourceLoader::responseReceived):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (287898 => 287899)


--- trunk/Source/WebCore/ChangeLog	2022-01-11 23:17:02 UTC (rev 287898)
+++ trunk/Source/WebCore/ChangeLog	2022-01-11 23:25:09 UTC (rev 287899)
@@ -1,3 +1,24 @@
+2022-01-11  Peng Liu  <[email protected]>
+
+        DataURLResourceMediaLoader decodes the URL repeatedly during a video playback
+        https://bugs.webkit.org/show_bug.cgi?id=234940
+
+        Reviewed by Darin Adler.
+
+        In r264864, we adopted a new SPI to tell AVFoundation that the entire file is available for custom URLs.
+        As a result, during a video playback, AVFoundation will request small data ranges instead of "caching"
+        the whole file again.
+
+        However, that leads to efficiency issue for DataURLResourceMediaLoader. Because it needs to decode the whole
+        URL when AVFoundation requests a data range, which is inefficient when the URL is very long.
+
+        This patch reverts the change in r264864 for the DataURLResourceMediaLoader case to fix the performance issue.
+        If DataURLDecoder::decode() supports decoding a data range in the future, we can change it back for better
+        memory efficiency.
+
+        * platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
+        (WebCore::WebCoreAVFResourceLoader::responseReceived):
+
 2022-01-11  Antoine Quint  <[email protected]>
 
         css/css-transitions/KeyframeEffect-setKeyframes.tentative.html is a failure (part 2)

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm (287898 => 287899)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm	2022-01-11 23:17:02 UTC (rev 287898)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm	2022-01-11 23:25:09 UTC (rev 287899)
@@ -357,8 +357,12 @@
 
         [contentInfo setContentLength:contentRange.isValid() ? contentRange.instanceLength() : response.expectedContentLength()];
         [contentInfo setByteRangeAccessSupported:YES];
-        
-        if ([contentInfo respondsToSelector:@selector(setEntireLengthAvailableOnDemand:)])
+
+        // Do not set "EntireLengthAvailableOnDemand" to YES when the loader is DataURLResourceMediaLoader.
+        // When the property is YES, AVAssetResourceLoader will request small data ranges over and over again
+        // during the playback. For DataURLResourceMediaLoader, that means it needs to decode the URL repeatedly,
+        // which is very inefficient for long URLs.
+        if (!m_dataURLMediaLoader && [contentInfo respondsToSelector:@selector(setEntireLengthAvailableOnDemand:)])
             [contentInfo setEntireLengthAvailableOnDemand:YES];
 
         if (![m_avRequest dataRequest]) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to