Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat blob: URLs as local in the resource selection algorithm #1037

Merged
merged 1 commit into from
Jun 9, 2016

Conversation

foolip
Copy link
Member

@foolip foolip commented Apr 12, 2016

Fixes #295.

@foolip
Copy link
Member Author

foolip commented Apr 12, 2016

I looked at many ways of doing this, and it looked tempting to eliminate the mode variable and just use current media resource, but in the end I went with the simplest possible thing that matched option 2 from #295 (comment)

@zcorpan, review?

@zcorpan
Copy link
Member

zcorpan commented Apr 13, 2016

AFAICT this won't invoke "fetch" of the blob: URL. I suppose that's necessary?

@foolip
Copy link
Member Author

foolip commented Apr 13, 2016

What are the correct words from checking if a URL corresponds to an object and for getting that object? In Blink's implementation it doesn't have anything to do with fetching, and it's a synchronous operation. I guess https://w3c.github.io/FileAPI/#requestResponseModel should cover this, but if one expresses it in terms of an async fetch then the structure will be very different.

https://w3c.github.io/FileAPI/#BlobURLStore is a primitive which does support synchronous operations, but there's no synchronous "get an entry from the Blob URL Store".

Thoughts?

@zcorpan
Copy link
Member

zcorpan commented Apr 13, 2016

@annevk can you help here?

@foolip
Copy link
Member Author

foolip commented Apr 14, 2016

In https://codereview.chromium.org/1881733004/ (by @wolenetz) it looks like implementation-wise it's more straightforward to just check if it's a blob: URL and not care whether it corresponds to an object at that point.

Depending on how one correctly gets from a blob: URL to an actual object (@annevk?) it might make more sense to keep blob: URLs in the remote branch and instead just skip the preload check, which is what the Chromium CL does.

@annevk
Copy link
Member

annevk commented Apr 14, 2016

If you have a parsed URL (a URL record), it'll have an object property to it pointing to the Blob object. See https://url.spec.whatwg.org/#url-parsing for details.

@zcorpan
Copy link
Member

zcorpan commented Apr 15, 2016

Right now it seems there is confusion in the spec between URL string and URL record.

⌛ Let urlString be the resulting URL string that would have resulted from parsing the URL specified by the src attribute's value relative to the media element's node document when the src attribute was last changed.

and in the resource fetch algorithm

Let request be the result of creating a potential-CORS request given current media resource's absolute URL and the media element's crossorigin content attribute value.

But "creating a potential-CORS request" takes a URL record, not a URL string.

So we need to change the spec here to work with the URL record instead.

(Similar in the img section and maybe elsewhere.)

@annevk
Copy link
Member

annevk commented Apr 15, 2016

Yeah, I have not tried to correct that yet. Baby steps, but if you can do some of it that'd be great.

@zcorpan
Copy link
Member

zcorpan commented Apr 20, 2016

@annevk OK I tried to fix that here, PTAL.

@annevk
Copy link
Member

annevk commented Apr 20, 2016

The changes that commit make look reasonable. I'm not a big fan of the "would have" style, but that was already there.

@wolenetz
Copy link

wolenetz commented Apr 21, 2016

Regarding #1037 (comment), I'm not clear on whether or not MSE or other blob/object URLs would best be handled in the whatwg html5 spec as "remote" or "local" mode, but at least MSE and MediaStream blob/object URLs need to skip the "remote" mode "optional preload none" steps.

@zcorpan zcorpan assigned foolip and unassigned zcorpan Apr 22, 2016
@foolip
Copy link
Member Author

foolip commented Apr 22, 2016

I agree that the "would have" bits are silly, that's #798

@zcorpan's changes LGTM.

The one point of uncertainty now is that in https://codereview.chromium.org/1881733004/ the preload check will be skipped for any URL using the blob: scheme, even if doesn't resolve to an object. That would be observably different from this. But I think that what this PR does makes pretty good sense, and it could be left as a TODO in the implementation. If it's left unfixed for a long time and other implementations do the same, then we might consider changing the spec. Any objections to that?

@foolip
Copy link
Member Author

foolip commented Apr 29, 2016

@annevk, final check before I merge? I'll combine the two commits.

@annevk
Copy link
Member

annevk commented Apr 30, 2016

I think the thing that is missing is that later on you don't actually use the object given by the URL. Fetch has a way of turning that into a response, but it seems that for the local mode you don't invoke fetch.

@foolip
Copy link
Member Author

foolip commented Jun 8, 2016

OK, I've fixed a build error and checked the diff again.

I think the thing that is missing is that later on you don't actually use the object given by the URL. Fetch has a way of turning that into a response, but it seems that for the local mode you don't invoke fetch.

"otherwise, let the current media resource be the resource given by the media provider object" in the following step implicitly refers to that object. Do we really need to fetch anything when we already have the object we want? The implementation wouldn't I think.

A problem, however, is that https://url.spec.whatwg.org/#concept-url-object can only be Blob object, but we also have MediaStream and MediaSource objects. Should the URL spec just be updated to allow for that?

@annevk
Copy link
Member

annevk commented Jun 8, 2016

Yeah, I didn't know it had spread beyond Blob objects, but I guess it has. I was hoping any new kind of resource we'd just support direct object assignment. File an issue?

You need to read the object somehow. Maybe the implicitness is okay for now though.

@annevk
Copy link
Member

annevk commented Jun 8, 2016

Anyway, LGTM if you file that issue, although I think at some point we probably want to be more explicit how we read objects and such.

@foolip
Copy link
Member Author

foolip commented Jun 9, 2016

Filed whatwg/url#126

@foolip foolip merged commit f8bc379 into master Jun 9, 2016
@foolip foolip deleted the media-element-blob-urls branch June 9, 2016 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants