- From: Robert O'Callahan <robert@ocallahan.org>
- Date: Fri, 24 Aug 2012 10:17:20 +1200
- To: Travis Leithead <travis.leithead@microsoft.com>
- Cc: Adam Barth <w3c@adambarth.com>, "public-media-capture@w3.org" <public-media-capture@w3.org>, Anant Narayanan <anant@mozilla.com>
- Message-ID: <CAOp6jLZHNw=8qaaW_xbTfC428-rzYx0cPR3mycRg33JpVgxJHQ@mail.gmail.com>
On Fri, Aug 24, 2012 at 4:54 AM, Travis Leithead < 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; }; 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 Thursday, 23 August 2012 22:17:53 UTC