- From: Drew Wilson <atwilson@google.com>
- Date: Wed, 9 Feb 2011 14:30:30 -0800
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