Re: MediaStreams and src attributes

On 2012-08-24 00:17, Robert O'Callahan wrote:
> On Fri, Aug 24, 2012 at 4:54 AM, Travis Leithead
> <travis.leithead@microsoft.com <mailto:travis.leithead@microsoft.com>>
> wrote:
>
>     There seems to be a lot of concerns about lifetime problems. Can you
>     elaborate on this? I would expect "lifetime problems" to plague all
>     users of createObjectURL (such as FileAPI), which is one reason for
>     the current behavior of defaulting to "autoRevoke" = true in
>     http://www.w3.org/TR/FileAPI/#creating-revoking. Do you have another
>     concern?
>
> autoRevoke helps but it's not as good as automatic garbage collection.
> For example, making code asynchronous breaks autoRevoke URLs. This works:
>    var url = URL.createObjectURL(stream, {autoRevoke:true});
>    element.src = url;
> But this doesn't:
>    var url = URL.createObjectURL(stream, {autoRevoke:true});
>    stream.onplaying = function() { element.src = url; };

This was interesting. I thought the URL was auto revoked after the first 
usage (in which case your async example would have been fine). Perhaps 
that's the old behavior.

/Adam

>
> Whereas changing
>    element.srcObject = stream;
> to
>    stream.onplaying = function() { element.srcObject = stream; }
> is completely safe (as well as being simpler code).
>
> Also, once you've set an element's 'src' to an autoRevoke URL, it's a
> useless magical string for most of the rest of the lifetime of the page.
> For example it gives you no way to create another media element with the
> same source. With 'srcObject', you can do element2.srcObject =
> element.srcObject at any time. (element2.src = element.src would have
> worked for all kinds of sources until Adam thwarted our evil plans
> (actually IIRC it was Hixie's plan originally), but "element2.src =
> element.src; element2.srcObject = element.srcObject;" will do.)
>
> [Aside: it seems unlikely autoRevoke change to default to true for
> createObjectURL(url) given FF, IE10 and I think Chrome are all shipping
> implementations of createObjectURL(url) which do not autoRevoke! The
> likelihood of breaking content by changing the autoRevoke default seems
> high.]
>
> Rob
> --
> “You have heard that it was said, ‘Love your neighbor and hate your
> enemy.’ But I tell you, love your enemies and pray for those who
> persecute you, that you may be children of your Father in heaven. ... If
> you love those who love you, what reward will you get? Are not even the
> tax collectors doing that? And if you greet only your own people, what
> are you doing more than others?" [Matthew 5:43-47]
>

Received on Friday, 24 August 2012 08:41:23 UTC