W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2011

[whatwg] SharedWorkers and "document discarded"

From: Drew Wilson <atwilson@google.com>
Date: Wed, 9 Feb 2011 14:30:30 -0800
Message-ID: <AANLkTik1nhgZc5mSmSZe8GKtoj-ThPqLUde6iCCX_d6R@mail.gmail.com>
Hi all,

Jonas brought up an interesting point regarding SharedWorkers in an
unrelated thread that I wanted to clarify here.

His contention is that the current SharedWorker spec specifies that the
lifecycle of a SharedWorker is currently tied to the GC behavior of the
underlying VM - specifically, that a SharedWorker is shutdown after its last
parent document has been GC'd.

The relevant spec language is (from
http://www.whatwg.org/specs/web-workers/current-work/#the-worker's-lifetime
):

Whenever a Document d is added to the worker's Documents, the user agent
must, for each worker in the list of the worker's
workers<http://www.whatwg.org/specs/web-workers/current-work/#the-worker's-workers>
whose
list of the worker's
Documents<http://www.whatwg.org/specs/web-workers/current-work/#the-worker's-documents>
does
not contain d, add dto q's WorkerGlobalScope owner's list of the worker's
Documents<http://www.whatwg.org/specs/web-workers/current-work/#add-a-document-to-the-worker's-documents>
.

Whenever a Document object is discarded, it must be removed from the list
of the worker's
Documents<http://www.whatwg.org/specs/web-workers/current-work/#the-worker's-documents>
of
each worker whose list contains that Document.
So I'm not an expert on Document lifecycles, so I don't entirely understand
under which circumstances the spec requires that a Document object be
"discarded". For example, if I have a top level window with a child iframe,
and that child iframe creates a SharedWorker, then reloads itself or
navigates, could that cause the original document to be discarded/suspended,
or does this depend on GC (whether script in the top level window maintains
a reference to the document javascript object)?

My understanding from previous discussions was that the only thing impacting
whether a document is discarded is whether the UA decided to keep it
suspended in the history cache - can javascript-level references also
prevent a document from being discarded?

-atw
Received on Wednesday, 9 February 2011 14:30:30 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:30 UTC