New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 675280 link

Starred by 9 users

Issue metadata

Status: Assigned
Owner:
Last visit > 30 days ago
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

Setting responseType to 'blob' causes double download when using link rel="preload"

Project Member Reported by andyb...@chromium.org, Dec 17 2016

Issue description

See reduced test case of this at https://github.com/andybons/preload

On the page I have:

<link rel="preload" href="/thing.json">

and then I construct my XMLHttpRequest to request /thing.json...

var xhr = new XMLHttpRequest();
xhr.responseType = 'blob';
xhr.open('GET', '/thing.json', true);
xhr.send();

Will cause /thing.json to download twice, with a console warning:
The resource http://localhost:8080/thing.json 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.

However, removing the responseType line causes things to happen as expected, with no double download.
 
Cc: kouhei@chromium.org dmu...@chromium.org
Components: Blink>Loader
dmurph@ Got ideas about what's going on with blobs?

Comment 2 by y...@yoav.ws, Dec 17 2016

Setting blob on XMLHttpRequest means that it is setting m_downloadingToFile on the ResourceRequest, which ResourceFetcher::determineRevalidationPolicy looks into in order to avoid reusing that resource.

I'm not sure why that is...
Cc: yhirano@chromium.org
Setting m_downloadingToFile means the client is expecting that the response body is dispatched in the form of blob URL rather than bytes. So skipping MemoryCache is the intended behavior.

Comment 4 by y...@yoav.ws, Dec 19 2016

yhirano - What happens when two different XHRs fetch the same resource as blob? Do we get two separate downloads? If so, is that intended as well?
When m_downloadingToFile is specified, the response contains a URL for the blob body, but that URL will get stale after loading unless you manually protect it. Protecting the blob URL too much leads to resource leaks in the browser process, so I would like to avoid that if possible.

Excluding preloading, XHR is not using the blink MemoryCache in order to reduce memory consumption: see  issue 659789 .
Components: Blink>Network>XHR
Status: WontFix (was: Untriaged)
Seems to be working as intended, changing status to get off of triage list.

Comment 8 by y...@yoav.ws, Dec 21 2016

Owner: y...@yoav.ws
Status: Assigned (was: WontFix)
I disagree. I think the link preload case should be special cased. Assigning to myself.

Comment 9 by addyo@chromium.org, Mar 29 2017

Cc: addyo@chromium.org
Still happens (Chromium 61)

<link crossorigin rel="preload" href="file.json" as="fetch">
then later on:
fetch("file.json").then(status).then(json).then(function(data) { ... }

Results in:
1) double-fetch, first from preload (with type=json according to devtools) and later from javascript (with type=fetch)
2) Chrome's warning: XXX was preloaded using link preload but not used within a few seconds
Similar issue with as="fetch" used for fetch HTML template content.

<link crossorigin rel="preload" href="results-template.html" as="fetch">
then later on:
$.get("results-template.html").done(function(html) { $("body").append(html); });

Results in:
1) double-fetch, first from preload (with type=text/html according to devtools) and later from javascript (with type=xhr)
2) Chrome's warning: XXX was preloaded using link preload but not used within a few seconds
This seems to be still an issue with Chromium 64.

I came here from https://stackoverflow.com/questions/41655955/why-are-preload-link-not-working-for-json-requests; right now it seems preloading JSON simply doesn't work at all in Chromium, 'blob' or not.
Sorry, I wasn't really clear. What I meant to say was that the issue description says:

> However, removing the responseType line causes things to happen as expected, with no double download.

But for me it doesn't work even with the responseType line removed.

Can anybody confirm this ever worked, and with what Chromium version, so we know whether this is a regression?
That is, in the current form, the repro at https://github.com/andybons/preload, using `without.html`, prints:

  <link rel=preload> must have a valid `as` value

that's why it doesn't double-load. If you add the required `as="prefetch"`, then it double-loads with Chromium 64, so what's written in the issue description doesn't work at least in my Chromium.

Sign in to add a comment