Preloaded video is still fetched with video.src = preloadedVideoUrl |
||||||||||||||
Issue descriptionChrome Version : 61.0.3130.0 OS Version: 9658.0.0 URLs (if applicable) : https://beaufortfrancois.github.io/sandbox/media/link-preload-full-video.html What steps will reproduce the problem? 1. Open DevTools Network tab 2. Go to https://beaufortfrancois.github.io/sandbox/media/link-preload-full-video.html What is the expected result? As I'm using link rel=preload as=video to preload a 79.4MB video and setting HTML video element src to the preloaded video URL, I expect no delay as the video content has already been downloaded. What happens instead of that? A range request fetches video content from a remote server ;( See screenshot below. UserAgentString: Mozilla/5.0 (X11; CrOS x86_64 9658.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3130.0 Safari/537.36
,
Jul 11 2017
,
Jul 12 2017
,
Jul 12 2017
This isn't quite media network related. The media stack just uses the URL information provided from Blink, we expect that either it provides us a different resource URI for such preloaded resources or that the underlying network stack is responsible for this preload behavior. cc: those labels since I'm not sure which should actually be happening for rel=preload
,
Jul 12 2017
Adding one of the preload spec authors, maybe they can clarify how this should work.
,
Jul 13 2017
jww@ is no longer working on Chromium. IIRC, <video> is using DocumentThreadableLoader. Currently, Chrome doesn't use data preloaded by a link element for DocumentThreadableLodaer-based stuff including XMLHttpRequest, fetch(), etc. Until recently, Chrome accidentally allowed XHR to reuse data loaded by <link rel=preload> without crossOrigin attribute, but we also just disabled it. Once we fix the loader architecture, we can make the combination of <link rel=preload crossOrigin> and DocumentThreadableLoader-based CORS-enabled APIs work again.
,
Jul 13 2017
s/we also just disabled/we are about to disable/
,
Jul 13 2017
Not sure what DocumentThreadableLoader is. <video> calls CreateAssociatedURLLoader() on the frame and loads data through whatever it returns.
,
Oct 6 2017
The video doesn't have "crossorigin" attribute, so the link preload shouldn't have it. The script sets the href long after onload is fired. As the console warning The resource https://storage.googleapis.com/fbeaufort-test/sample-video.webm was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it wasn't preloaded for nothing. suggests, the preloaded resource is discarded at that time.
,
Oct 6 2017
You're right. I've removed the "crossorigin" attribute from the demo. Regarding the warning, I've updated the code to fetch a short piece of a video so that it the video src is used right after the onload event: https://github.com/beaufortfrancois/sandbox/commit/bbaea8759629fc29ea60976dfb743464640b58e2 See screenshot below. There is still something wrong but I'm not sure what...
,
Oct 6 2017
Ah, you're right. The preloaded one is not used due to header difference: Accept-Encoding, Range and chrome-proxy in my environment. Among these, Range is crucial, I guess.
,
Oct 6 2017
Probably Accept-Encoding also matters. I don't know about chrome-proxy.
,
Oct 6 2017
Would you know how can I make sure these values are the same?
,
Oct 6 2017
I see the difference (other than chrome-proxy) in devtools.
,
Oct 6 2017
In Chrome 63.0.3230.0 (Official Build) canary (64-bit), I see only one request in DevTools. In Stable though: - The "link preload" request has no range HTTP Headers while the "src" one has a range HTTP Header of "bytes=0-". - The "link preload" request has a "accept-encoding" HTTP Headers set to "gzip, deflate, br" while the "src" one has a "accept-encoding" HTTP Header of "identity;q=1, *;q=0".
,
Oct 6 2017
,
Oct 10 2017
,
Oct 11 2017
Blink::ResourceMultiBufferDataProvider attaches such headers but they're not consistent with preloads. Media people, can you take a look?
,
Oct 11 2017
Take a look at what? We need those headers.
,
Oct 11 2017
Then you may need to add them to as=video preloads as well.
,
Oct 13 2017
,
Oct 13 2017
I suppose we could do that. But it would be somewhat error-prone so we'd need a test to make sure it doesn't randomly break. Where would I need to add this header?
,
Oct 30 2017
,
Mar 9 2018
yhirano@ could you help me figure out how to fix as=video headers?
,
May 18 2018
yhirano, ping?
,
May 22 2018
Sorry for the delay. > #22 core/link_loader.cc maybe.
,
May 23 2018
So I made an attempt to add the headers ( https://chromium-review.googlesource.com/#/c/chromium/src/+/1067752 ) but it doesn't seem to work. The headers do not show up in the actual request. yhirano, could you take a look and tell me what I'm doing wrong?
,
May 24 2018
What happens if you set Range?
,
Jul 27
Setting range should not affect caching. If it did, then requesting a sub-range would not hit the cache.
,
Nov 2
link rel=preload is different from the HTTP cache. We don't have any Range related logic in that, so ignoring requests with different headers sounds good to me.
,
Nov 2
The video code will make many requests with different ranges against the same resource. For link preloading to work, it must ignore the range header I think. Simply "set Range" doesn't work.
,
Nov 5
Then I think we should remove as="video" support from link rel="preload".
,
Nov 5
I support temporary removal. We need to properly define the preload cache and how it should work for media fetches and range requests: https://github.com/w3c/preload/issues/97 That will make it easier to then add such support to the preload cache.
,
Nov 5
Ok, so who should I assign this bug to?
,
Dec 1
Assigning to yharino to figure out who can remove the as=video support. |
||||||||||||||
►
Sign in to add a comment |
||||||||||||||
Comment 1 by fbeaufort@chromium.org
, Jun 21 2017