[html5] Newbie question about SharedWorkers
ian at hixie.ch
Tue Aug 3 18:17:34 PDT 2010
On Thu, 27 May 2010, David John Burrowes wrote:
> The spec makes various references to shared workers being used by
> multiple pages in parallel. My question is can a shared worker be used
> by two sequentially accessed pages? My reading of the spec says "no",
> but my intuition about what behavior I would "expect" says I should be
> able to. Is my reading of the spec right?
> Here's an example:
> We have two pages: P1 and P2 (from the same origin etc)
> P1 has a link to P2 on it (<a href="P2">)
> Both P1 and P2 reference a shared worker SW
> When the user gets page P1, then SW is created.
> User then clicks on the link to P2
> My interpretation of the spec says that when this link is clicked, P1
> will be made no longer active, so it will be removed from SW's list of
> Documents. This will leave SW's list empty, which will make it no
> longer a permissable worker. It's closing flag will be set to true, and
> presumably there's a chance it will be destroyed before P2 can be loaded
> and access SW. So, P2 will need to re-create SW.
> It seems desirable to me that if a page transition is being made between
> pages with compatible origins, that a shared worker would be preserved
> across them, allowing complex calculations being done by the worker to
> be shared by the pages (obviously, the worker could be storing its work
> in a database, and then reloading that when it is created. But, that
> seems like overkill)
I agree that this makes some sense. It isn't currently possible. Once
shared workers are more widely deployed, it's something I think we should
examine -- if lots of pages are trying to work around this limitation, we
should do something about it (e.g. making workers live until the next
page's onload if it's on the same domain).
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
More information about the Help