[whatwg] Possible bug in the way the spec about worker GC behavior

Ehsan Akhgari ehsan at mozilla.com
Thu Oct 10 08:06:43 PDT 2013

On Thu, Oct 10, 2013 at 7:58 AM, Andrew Wilson <atwilson at google.com> wrote:

> Can you be more specific about what in the spec is incorrect? I guess
> you're saying that Gecko shuts down the worker as soon as the parent
> document is no longer active (when the worker transitions to suspendable),
> so the worker is generally shutdown before the document is discarded?

It's even worse than that, we GC the worker object if we can prove that it
will not have any outstanding work to do in the future.

> I think that behavior is a reasonable interpretation of the spec, and I
> don't think the language you cite implies otherwise - did you want to
> suggest an alternate wording that is clearer? I think implicit in the quote
> you described is that it only applies to workers that are still running,
> not to workers that have previously been shutdown.

Well, removing a document from the worker's list of documents to me implies
that the worker object is not GCed, which implies that UAs cannot GC worker
objects until the document is discarded.  This is a bit tied into the
worker lifetime language in the spec, so I don't think that a simple
rewording fixes this, and honestly the worker lifetime prose in the spec is
very difficult to understand.  But I'm more interested to know whether I'm
just reading too much into that sentence, or if this is actually what the
spec means to say first.


> On Thu, Oct 10, 2013 at 12:12 AM, Ehsan Akhgari <ehsan at mozilla.com> wrote:
>> Right now the spec says[1] "Whenever a Document object is discarded, it
>> must be removed from the list of the worker's Documents of each worker
>> whose list contains that Document.".  If I'm reading this correctly, this
>> implies that the worker object should be alive by the time that the
>> document gets discarded, which is not what Gecko implements.
>> Should this be fixed in the spec?
>> [1] <
>> http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html#the-worker%27s-lifetime
>> >
>> Cheers,
>> --
>> Ehsan
>> <http://ehsanakhgari.org/>

More information about the whatwg mailing list