On Fri, May 20, 2016 at 12:28 PM, Ben Kelly <
bke...@mozilla.com> wrote:
> On Fri, May 20, 2016 at 3:12 PM, Jonas Sicking <
jo...@sicking.cc> wrote:
>>
>> On Fri, May 20, 2016 at 8:04 AM, Ben Kelly <
bke...@mozilla.com> wrote:
>> > On Fri, May 20, 2016 at 10:56 AM, Boris Zbarsky <
bzba...@mit.edu>
>> > wrote:
>> >
>> >> Thoughts? Any obvious problems with this plan?
>> >
>> > We have the concept of network requests made from workers not associated
>> > with a single document. For example, SharedWorker attached to multiple
>> > documents or a ServiceWorker servicing a push event. In theory we want
>> > the
>> > same load grouping behavior to abort requests if those workers
>> > terminate,
>> > etc.
>> >
>> > If we are refactoring things, can we include that concept as well?
>>
>> I *think* the current setup that we have dedicated workers is that
>> each worker gets its own loadgroup, and that all
>> XHR/fetch()/importScripts() loads are added to that loadgroup. Ideally
>> that loadgroup should be added as a child loadgroup of the owning
>> document, or the owning worker. But I'm not sure that is the case.
>>
>> For SharedWorkers/ServiceWorkers, we should just skip the last step.
>> I.e. we should not make the loadgroup be a child of any other
>> loadgroup.
>
>
> We don't use "child" load groups at all AFAIK. We inherit the document
> LoadGroup for dedicated workers:
>
>
https://dxr.mozilla.org/mozilla-central/source/dom/workers/WorkerPrivate.cpp#4356
That doesn't sound good. We should give each worker its own loadgroup.
Independent of if it's a dedicated, shared or service worker.
Or is there a reason to share loadgroup with the document that I'm missing?
This looks like the worker loadinfo, which is different from the
loadgroup (and also different from nsILoadInfo, despite the same name
sadly).
>
https://dxr.mozilla.org/mozilla-central/source/dom/workers/WorkerPrivate.cpp#2071
>
> This tab child stuff was to support security checking on b2g I think. I'm
> not sure we strictly need it any more.
>
> Maybe all of this is fine. The behavior of SharedWorker and ServiceWorker
> seem a bit fragile, though. And it seems we get broken network stuff on
> workers periodically for things that assume a document. So I just wanted to
> avoid any more document specific behavior if we can. Maybe thats not a
> concern here.
It's generally a concern that we still have a lot of code which rely
on loads happening through a document.
In part because it's convenient to have a single object through which
you can get all needed information when doing "networky stuff".
The best solution i've been able to think of so far is to rely less on
nsILoadContext (which is strongly tied to docshells, which workers
don't always have) and more on nsILoadInfo (which is information
sitting directly on channels). We're at the point now where we should
be able to start deprecating stuff off of nsILoadContext.
Something like this would also be very helpful:
https://bugzilla.mozilla.org/show_bug.cgi?id=1259873
/ Jonas