[webkit-dev] SharedWorkers alternate design
ap at webkit.org
Mon Jun 1 12:16:32 PDT 2009
01.06.2009, в 22:37, Drew Wilson написал(а):
> 1) Since SharedWorkers aren't explicitly tied to a specific
> Document, it doesn't make sense to have them possibly get loaded
> from an out-of-date version of the app cache. If you have two
> separate documents running from different caches, it's weird (and
> indeterminate) if the version of the cache used to load the
> SharedWorker script is dependent on which one happens to call "new
> SharedWorker()" first.
I don't see how exposing DOMApplicationCache methods to workers can
help this - a worker will only be able to call
DOMApplicationCache.update() after it has started, which is too late.
Besides, won't the document using an old version of cache break if a
newer SharedWorker is suddenly returned to it? The main idea of
appcache is that all application resources are versioned, so if we see
SharedWorkers as part of application, they should use the same cache
version. And if they are independent entities with a stable API, using
an out of date version for a while cannot hurt.
> As for what happens to a SharedWorker whose cache was updated? My
> presumption is that all future resource loads would use that cache.
> At that point, the SharedWorker has a few different things it could
> Reload all of its scripts again using importScripts(). This implies
> that its script loading is idempotent, but that's not too hard to do.
> Send messages to all of its client documents letting it know that it
> is shutting down, then invoke close() to shut itself down. The
> client documents can re-create the SharedWorker the next time they
> want one. This is inherently race-y, though, since you can't easily
> coordinate the shutdown of the worker with instantiations of new ones.
> Do nothing at all
All of these options seem quite dangerous - it may be difficult for JS
authors to write applications that won't break at update time.
A document can reload itself after updating, but SharedWorkers do not
have a way to reload themselves. As you mentioned, they can reload
imported scripts (but the main script will remain the same, which
would be inconsistent). Or they can shut down and ask a document to re-
create themselves - at which point, we can as well say that the
document can update the cache.
Interaction of SharedWorkers and appcache, explicit or not, sounds
like a major issue to me. It can significantly affect the design (or
even make SharedWorkers not worth being added, if no acceptable
solution is found).
- WBR, Alexey Proskuryakov
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev