This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 19594 - createObjectURL behaviour needs documentation, not BLOB
Summary: createObjectURL behaviour needs documentation, not BLOB
Status: RESOLVED FIXED
Alias: None
Product: WebRTC Working Group
Classification: Unclassified
Component: Media Capture and Streams (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Harald Alvestrand
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 23091
Blocks:
  Show dependency treegraph
 
Reported: 2012-10-18 09:20 UTC by Yang Sun
Modified: 2013-10-14 08:08 UTC (History)
7 users (show)

See Also:


Attachments

Description Yang Sun 2012-10-18 09:20:04 UTC
As has been discussed in email thread, people raise concern about restriction to BLOB type url which mint by createObjectURL().

I suggest to remove BLOB from 4.5.1 and replace with stream since we know it is different.



/////////////////////////change begin//////////////////////////////////
4.5 URL

partial interface URL {
    static DOMString createObjectURL (MediaStream stream);
};
4.5.1 Methods

createObjectURL, static
Mints a Stream URL to refer to the given MediaStream.

When the createObjectURL() method is called with a MediaStream argument, the user agent must return a unique Stream URL for the given MediaStream. [TBD, may be STREAM API in WebAPP?]

For audio and video streams, the data exposed on that stream must be in a format supported by the user agent for use in audio and video elements.


Parameter	Type	Nullable	Optional	Description
stream	MediaStream	✘	✘	
Return type: DOMString
Comment 1 Harald Alvestrand 2013-03-25 10:59:04 UTC
This ties in with the topic of direct assignment of a mediastream as a media source. The reuse of the word "blob" can mislead people into thinking that the minted URL can be used for anything except assigning to a mediaelement's src attribute. It can't - in particular "the data exposed" doesn't make senses.

Calling it a "Stream URL" doesn't help as long as that isn't defined eitehr.

Suggest removing the word "blob" and just saying "an URL", and stating that its only required valid use is for assigning to an HTMLMediaElement.src attribute, removing the sentence about "data exposed on that stream".
Comment 2 Anne 2013-04-12 13:52:31 UTC
A URL has observable bits so you cannot just say "a URL".

What is the concern with re-using blob URLs? You can key off the identifier part of the URL.
Comment 3 Robert O'Callahan (Mozilla) 2013-04-13 12:57:20 UTC
createObjectURL(MediaStream) does not return a URL representing a blob. The URL it returns can only be used as a media element source and does not correspond to a fixed array of bytes as blobs do. Thus the URL should use a different scheme.

In Firefox we return a URL of the form "mediastream:<uuid>".

Likewise, our WIP MediaSource implementation has createObjectURL(MediaSource) returning a URL of the form "mediasource:<uuid>".
Comment 4 Anne 2013-04-16 13:05:51 UTC
Note that we still have not resolved how createObjectURL() should actually work for blob URLs: http://lists.w3.org/Archives/Public/public-webapps/2013AprJun/thread.html#msg240

It might be a good idea to wait a bit before expanding the usage of this method if that's still feasible.
Comment 5 Robert O'Callahan (Mozilla) 2013-04-16 22:55:05 UTC
We're kinda stuck with it already. It's in the wild and spreading fast.

I also think that we're stuck with the default behavior being NOT to auto-revoke, since that's what browsers currently implement.

I think this is basically OK as long as we spec the default to be not to auto-revoke, when we finally define how auto-revocation works.
Comment 6 Arun 2013-04-17 17:34:22 UTC
Are we stuck with default being NOT autoRevoke because of shipping applications that will break since they rely on default being NOT autoRevoke, or any other reason?
Comment 7 Robert O'Callahan (Mozilla) 2013-04-17 20:38:14 UTC
I'm worried about shipping applications that would break it, but I don't know of any concrete examples.

I'm not enthusiastic enough about this change to volunteer Firefox to be the first browser to try to change. If another browser vendor wants to try the compatibility experiment, that's fine.
Comment 8 Arun 2013-04-17 21:48:26 UTC
(In reply to comment #7)
> I'm worried about shipping applications that would break it, but I don't
> know of any concrete examples.
> 
> I'm not enthusiastic enough about this change to volunteer Firefox to be the
> first browser to try to change. If another browser vendor wants to try the
> compatibility experiment, that's fine.

Well, the spec shouldn't coerce implementations to do things they are reluctant to do :(  One of the reasons we put in autoRevoke=true by default was to minimize leaked strings (Blob URLs that persisted past their use), and to minimize forcing developers to couple a create* call with a revoke* call.  Do you think that's needlessly cautious?
Comment 9 Robert O'Callahan (Mozilla) 2013-04-17 22:22:04 UTC
I don't think it's needlessly cautious --- I think leaked Blobs could be a real problem. Auto-revoke by default would have been the right thing to do if we'd done it that way from the start (which would have required have a good spec for auto-revoke from the start, which we still don't have!).
Comment 10 Arun 2013-04-18 00:06:25 UTC
> I don't think it's needlessly cautious --- I think leaked Blobs could be a
> real problem. Auto-revoke by default would have been the right thing to do
> if we'd done it that way from the start (which would have required have a
> good spec for auto-revoke from the start, which we still don't have!).

(In reply to comment #9)

I'm honestly not sure it's too late to fix this to be right, especially since we're not sure what's broken, but we are sure that leaked Blob strings can be a "real problem."  

What can we do to fix the autoRevoke behavior to be better, or address the nits you may have (per Comment 9)?  Right now autoRevoke=true is tied in with HTML's global script cleanup steps.  Advice appreciated, maybe on the public listserv (public-webapps@w3.org) if you think this bug isn't right. Spec at http://dev.w3.org/2006/webapi/FileAPI/
Comment 11 Robert O'Callahan (Mozilla) 2013-04-18 00:18:21 UTC
The thread starting at http://lists.w3.org/Archives/Public/public-webapps/2013AprJun/0240.html about the behavior of auto-revoke has still not reached a consensus.

Let's first reach a consensus on how auto-revoke should be work before we try to make it the default. Nothing would be worse than making it the default and then realizing that whatever compatibility data we collected was invalid because we had to change the behavior.
Comment 12 Harald Alvestrand 2013-08-21 10:58:29 UTC
Suggested resolution:

CreateObjectURL returns an URL that can be used for setting as the .src URL of a <video> or <audio> element. The platform guarantees that it can be used for this purpose, and it guarantees that it can be used for this purpose once.

The effect of video.src = CreateObjectURL(stream) should be exactly the same
as video.srcObject = stream.

This specification should not need to make any more statements than this.
Comment 13 Robert O'Callahan (Mozilla) 2013-08-21 11:51:23 UTC
> CreateObjectURL returns an URL that can be used for setting as the .src URL of
> a <video> or <audio> element.

You mean specifically createObjectURL called with a MediaStream parameter, right?

> The platform guarantees that it can be used for
> this purpose, and it guarantees that it can be used for this purpose once.

Why only once? Gecko doesn't have that limitation.

> The effect of video.src = CreateObjectURL(stream) should be exactly the same
> as video.srcObject = stream.

It should be the same as far as the behavior of the media element goes, I agree. But you have to be careful with the wording because using srcObject has different implications for the lifetime of the stream than using createObjectURL.
Comment 14 Martin Thomson 2013-08-21 16:03:52 UTC
(In reply to comment #13)
> > The platform guarantees that it can be used for
> > this purpose, and it guarantees that it can be used for this purpose once.
> 
> Why only once? Gecko doesn't have that limitation.

Yeah, I thought that odd too.  I can see why you might say "at least once", but I would have thought it straightforward enough to use the same URL as many times as the platform can handle, as long as the stream remains valid.
 
> But you have to be careful with the wording because using srcObject
> has different implications for the lifetime of the stream than using
> createObjectURL.

I lost you.  The two ways of doing essentially the same thing have different properties?  In what way?
Comment 15 Anne 2013-08-21 16:13:27 UTC
You need to garbage collect the string-variant manually, because usage cannot be reference counted.

createObjectURL() should definitely not return an auto-revoking URL though for MediaStream as it doesn't do that for Blob. We will introduce a new API for that.
Comment 16 Martin Thomson 2013-08-21 16:20:30 UTC
(In reply to comment #15)
> You need to garbage collect the string-variant manually, because usage
> cannot be reference counted.

Geez, that sounds like a great answer.  But I'm not buying it.  The URL is just a weak reference that allows for the creation of a strong reference.  If the referenced object happens to be garbage collected while there are only weak references, that's just too bad.
Comment 17 Anne 2013-08-21 16:54:07 UTC
That would expose the garbage collector. Anyway, you don't have to take my word for it, just read http://dev.w3.org/2006/webapi/FileAPI/#dfn-createObjectURL
Comment 18 Martin Thomson 2013-08-21 17:25:44 UTC
(In reply to comment #17)
> That would expose the garbage collector. Anyway, you don't have to take my
> word for it, just read
> http://dev.w3.org/2006/webapi/FileAPI/#dfn-createObjectURL

So, if you ascribe similar properties to MediaStream URLs as you do to blob URLs, then you get these properties.  Because this uses the same URL.createObjectURL() function, then I guess you have to keep those properties.  That's a shame, because I think that those properties aren't desirable.
Comment 19 Robert O'Callahan (Mozilla) 2013-08-21 22:48:54 UTC
The fundamental problem with createObjectURL is that there is no way for the browser to automatically know when the Web application is no longer using the string. That's why manual (or auto) revocation is needed. This problem is common to Blobs, MediaStreams and every other user of createObjectURL.

Anyway we're only quibbling about wording here. It's already pretty clear what Harald meant, and I just would like to see it stated a little more precisely.
Comment 20 Harald Alvestrand 2013-08-26 11:33:44 UTC
Suggested resolution, take 2:

CreateObjectURL returns an URL that can be used for setting as the .src URL of a <video> or <audio> element.
It has exactly the same effect on the underlying MediaStream as CreateObjectURL has on a Blob: Creating a reference that has to be revoked before the MediaStream is garbage collected.

The effect of <tag>.src = CreateObjectURL(stream) on a HTML media tag is exactly the same as <tag>.srcObject = stream.
Comment 21 Robert O'Callahan (Mozilla) 2013-08-26 22:50:46 UTC
Good enough, but say "element" rather than "tag".
Comment 22 Anne 2013-08-27 09:37:21 UTC
roc, how was it clear? He suggested it could be used just once which is not the behavior for Blob. I'm not sure we want to do that. In any event, this needs to be defined to the same level of detail as createObjectURL for Blob is defined. A paragraph doesn't seem good enough.
Comment 23 Robert O'Callahan (Mozilla) 2013-08-27 09:48:45 UTC
(In reply to comment #22)
> roc, how was it clear? He suggested it could be used just once which is not
> the behavior for Blob.

Comment #20 doesn't suggest that.

I'm not sure we want to do that. In any event, this
> needs to be defined to the same level of detail as createObjectURL for Blob
> is defined. A paragraph doesn't seem good enough.

OK.
Comment 24 Cullen Jennings 2013-08-27 15:49:21 UTC
I think this bug should be closed and the conversation moved to the list until we can figure out what direction the WG wants to go it. The editors discussed it for awhile and it was clear we did not know what we needed to to.
Comment 25 Harald Alvestrand 2013-08-28 11:43:06 UTC
I am changing the subject of this bug to be more appropriate to the discussion.
What we seem to be converging on:

- The behaviour of CreateObjectURL(Mediastream) needs to be documented. In particular, that it behaves exactly the same as CreateObjectURL(Blob) with regards to creating references that prevent garbage-collecting the Mediastream.

- The URL that is returned from this CreateObjectURL operation should not start with the letters "blob:", because it can't be used or dereferenced in the ways that a "blob:" URL can. This is in line with what implementations do today.

- It would be great if the File API specification had a term we could point to just say "MediaStream is a FOO", and get the properties we want.
Comment 26 Harald Alvestrand 2013-08-29 13:09:11 UTC
Adding a dependency on 23091. If CreateObjectURL is removed, we don't have to document it.
Comment 27 Harald Alvestrand 2013-10-14 08:08:31 UTC
We have removed createObjectURL from the spec, so this is no longer relevant.