[html5] Newbie question about SharedWorkers

David John Burrowes davidjohnburrowes at gmail.com
Fri Jun 4 09:45:27 PDT 2010


Thank you very much for your thoughts, Dmitry!

I'm sure one can use the iframe approach you mention. Would you agree, though, that this is not a very elegant way of solving this problem?

I also completely agree that a timeout would be a bad idea here (unreliable in so many ways it gives me hives)

However, I feel like I don't understand your point about redirects being difficult/unreliable.  Sounds like there's something I don't understand.  Can you explain more?

Thanks!

David


On 2010/6/4, at 上午9:25, Dmitry Titov wrote:

> Hi David,
> 
> Yes, the shared worker will not survive this transition. One way to keep it alive is to use more complex page with nested iframe (and navigate the iframe, keeping parent alive).
> 
> Theoretically, the spec could prescribe keeping the worker alive for a certain period of time, or when navigating to another page in the same origin, but all those methods are somewhat unreliable (timeouts are arbitrary, redirects are difficult etc).
> 
> Dmitry
>  
> ---------- Forwarded message ----------
> From: David John Burrowes <davidjohnburrowes at gmail.com>
> Date: Thu, May 27, 2010 at 5:53 PM
> Subject: [html5] Newbie question about SharedWorkers
> To: help at lists.whatwg.org
> 
> 
> Hello all,
> 
> I'm making my way through the spec about Workers, and have a question about SharedWorkers.
> 
> 
> 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)
> 
> Thoughts?
> 
> David
> 
> _______________________________________________
> Help mailing list
> Help at lists.whatwg.org
> http://lists.whatwg.org/listinfo.cgi/help-whatwg.org
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/help-whatwg.org/attachments/20100604/a7c04e45/attachment-0002.htm>


More information about the Help mailing list