On Thu, Nov 19, 2015 at 2:48 PM, Boris Zbarsky <bzbar...@mit.edu> wrote: > On 11/19/15 5:39 PM, Jonas Sicking wrote: >> >> This API doesn't seem to work for nested workers (which Blink doesn't >> implement), does it? Since there's no way in the window to get hold of >> a reference of a sub-sub-worker. > > While true, there is also no way to directly get a message from a > sub-sub-worker, right? The only way to get one is via the intermediate > worker.
You can actually create a MessageChannel and then send one of the ports to a sub-sub-worker. Unfortunately the other port can't be used as something that represents the sub-sub-worker since even after a port has started getting used, it can be sent around again. > So you have a window create worker W1, W1 creates W2. W2 does something, > posts a message back to W1 with some timestamps. W1 translates those into > its timeline and posts message back to the window, which translates into its > timeline. Yes, this is possible. It's not great, but it's probably a fine enough solution. >> It also doesn't seem possible for a worker to convert to the timeline >> of a parent window, since there's no object representing the parent of >> a worker. > > That's true. If you want to ship timestamps from a window to a worker, > there's no convenient way to do that, though you can hack it together like > so: > > w.postMessage(myTimeStamp - Performance.translateTime(0, w)) > > It seemed to me when this was being discussed that typically your timestamps > would flow the other way, but maybe that's a bad assumption? I suspect having a worker which takes care of coordinating network traffic to a server is likely to be a good design. Especially having a sharedworker or serviceworker take care of coordinating the network traffic if the website expects the user to have multiple tabs open. Though Service Workers do actually have a 'client' object which represent window objects. So we could enable passing those as global to the translate function. / Jonas _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform