Re: File API "oneTimeOnly" is too poorly defined

On Thu, Mar 29, 2012 at 2:29 AM, Darin Fisher <> wrote:

> I've never been terribly happy with createObjectURL and the requirement for
> folks to remember to call revokeObjectURL.  I really like that we're
> talking
> about ways to minimize this pain :-)
> I noticed the WeakRefs proposal:

This exposes GC behavior, though.  They try to reduce that by making it
only collectable during the event loop, but it's still observable.  For

blob = createObjectURL();
blob = null;
setTimeout(function() { img.src = blob; }, 0);

might or might not succeed.

(IIRC, WeakMaps avoid GC exposure by being non-enumerable.  That seems to
make them not very useful, since it's hardly different from simply
assigning properties to the object.)

On Thu, Mar 29, 2012 at 6:08 AM, Robert O'Callahan <>wrote:

> It might be a bit better to revoke the URL at the next stable state.
> Microtask checkpoints can happen during synchronous script execution.

I'm confused.  I'd never seen microtasks actually defined (only suggested),
but I see it's just not defined in the page I was viewing.  It looks like
Google's returning out of date spec links (
 This is the second time I've been bit recently by landing on a weird,
out-of-date spec URL (ignoring the /TR/ trap, which I know to watch out

So, "microtask" isn't what we need here (and not what IndexedDB needs,
either).  Stable state might be correct.  I think that has another effect,
which you don't get by waiting for the event loop: blob URLs would also be
freed between <script> execution.  That is, in

<script>url = URL.createObjectURL(blob); ...</script><script>...</script>

the blob is released before the second <script> is run.  That seems like a

getObjectURL(blob, {auto: true}) would simply do:

N+1. Return the generated url, and then continue running this algorithm
N+2. Await a stable state.
N+3. Revoke url.

which doesn't require any new concepts.

I'd suggest "auto" as the option name; it's short, since it'd probably be
used a lot.

On Thu, Mar 29, 2012 at 3:03 AM, Charles Pritchard <> wrote:

> Any feedback on what exists in modern implementations? MS seems to have
> the most hard-line stance when talking about this API.

As far as I could tell, MS implemented something behind closed doors,
presented it whole, and then more or less refused to change anything,
despite the serious issues pointed out in it.  Web API development can't
work that way in 2012.

Glenn Maynard

Received on Thursday, 29 March 2012 22:20:01 UTC