Bug 201517 - Move the ResourceLoadObserver logic to WebKit2
Summary: Move the ResourceLoadObserver logic to WebKit2
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-09-05 14:16 PDT by Chris Dumez
Modified: 2019-09-07 15:29 PDT (History)
12 users (show)

See Also:


Attachments
Patch (58.63 KB, patch)
2019-09-05 14:26 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (59.72 KB, patch)
2019-09-05 14:41 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (59.77 KB, patch)
2019-09-06 15:59 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (59.83 KB, patch)
2019-09-06 16:58 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2019-09-05 14:16:31 PDT
Move the ResourceLoadObserver logic to WebKit2 since it is not used by WebKit1. This allows us to simplify code.

In a follow-up patch, I will simplify the code even further by leveraging the fact that a WebContent process is always associated with a single WebsiteDataStore / sessionID:
- No need for a HashMap of sessionIDs
- No need to even allocate the ResourceLoadObserver if the WebProcess is associated with an ephemeral session.
Comment 1 Chris Dumez 2019-09-05 14:26:46 PDT
Created attachment 378122 [details]
Patch
Comment 2 Chris Dumez 2019-09-05 14:41:00 PDT
Created attachment 378123 [details]
Patch
Comment 3 Chris Dumez 2019-09-05 15:31:46 PDT
Kate Cheney
Comment 4 Chris Dumez 2019-09-05 15:32:06 PDT
(In reply to Chris Dumez from comment #3)
> Kate Cheney

LoL, I was trying to cc.
Comment 5 youenn fablet 2019-09-06 02:22:39 PDT
(In reply to Chris Dumez from comment #0)
> Move the ResourceLoadObserver logic to WebKit2 since it is not used by
> WebKit1. This allows us to simplify code.
> 
> In a follow-up patch, I will simplify the code even further by leveraging
> the fact that a WebContent process is always associated with a single
> WebsiteDataStore / sessionID:

This is tempting!

But this is not (yet) the case.
I believe service workers are all being run in the same web process as long as they belong to the same domain, no matter which sessionID they are associated with.

We could also think of reusing a web process (which no longer runs a web page but is in the process cache) to run a web page with the same domain but a different session ID. Or even run different pages with different session IDs in the same process.
Not sure whether we want to do that but that is something we could easily do with the current infrastructure if we want to.

I agree the sessionID infrastructure is adding some complexity.
Since it is there and working though, I am a bit hesitant to remove it.

There is a lot of related complexity in NetworkProcess as well, the benefits would be even greater there (simplifications, limiting sandbox extensions...).
The worry is again the added cost in spinning more processes.

Not sure whether this simplification is doable in WebProcessPool.
Comment 6 Chris Dumez 2019-09-06 07:42:55 PDT
(In reply to youenn fablet from comment #5)
> (In reply to Chris Dumez from comment #0)
> > Move the ResourceLoadObserver logic to WebKit2 since it is not used by
> > WebKit1. This allows us to simplify code.
> > 
> > In a follow-up patch, I will simplify the code even further by leveraging
> > the fact that a WebContent process is always associated with a single
> > WebsiteDataStore / sessionID:
> 
> This is tempting!
> 
> But this is not (yet) the case.
> I believe service workers are all being run in the same web process as long
> as they belong to the same domain, no matter which sessionID they are
> associated with.
> 
> We could also think of reusing a web process (which no longer runs a web
> page but is in the process cache) to run a web page with the same domain but
> a different session ID. Or even run different pages with different session
> IDs in the same process.
> Not sure whether we want to do that but that is something we could easily do
> with the current infrastructure if we want to.
> 
> I agree the sessionID infrastructure is adding some complexity.
> Since it is there and working though, I am a bit hesitant to remove it.
> 
> There is a lot of related complexity in NetworkProcess as well, the benefits
> would be even greater there (simplifications, limiting sandbox
> extensions...).
> The worry is again the added cost in spinning more processes.
> 
> Not sure whether this simplification is doable in WebProcessPool.

We have assertions in place to make sure that a WebProcess is only associated with a single data store so I’d be surprised if it were not true for service workers. That said, I will take a look. The fact is that web processes can only support one session at the moment and of code tries to do differently, then it is buggy code.
Comment 7 Chris Dumez 2019-09-06 08:52:00 PDT
(In reply to Chris Dumez from comment #6)
> (In reply to youenn fablet from comment #5)
> > (In reply to Chris Dumez from comment #0)
> > > Move the ResourceLoadObserver logic to WebKit2 since it is not used by
> > > WebKit1. This allows us to simplify code.
> > > 
> > > In a follow-up patch, I will simplify the code even further by leveraging
> > > the fact that a WebContent process is always associated with a single
> > > WebsiteDataStore / sessionID:
> > 
> > This is tempting!
> > 
> > But this is not (yet) the case.
> > I believe service workers are all being run in the same web process as long
> > as they belong to the same domain, no matter which sessionID they are
> > associated with.
> > 
> > We could also think of reusing a web process (which no longer runs a web
> > page but is in the process cache) to run a web page with the same domain but
> > a different session ID. Or even run different pages with different session
> > IDs in the same process.
> > Not sure whether we want to do that but that is something we could easily do
> > with the current infrastructure if we want to.
> > 
> > I agree the sessionID infrastructure is adding some complexity.
> > Since it is there and working though, I am a bit hesitant to remove it.
> > 
> > There is a lot of related complexity in NetworkProcess as well, the benefits
> > would be even greater there (simplifications, limiting sandbox
> > extensions...).
> > The worry is again the added cost in spinning more processes.
> > 
> > Not sure whether this simplification is doable in WebProcessPool.
> 
> We have assertions in place to make sure that a WebProcess is only
> associated with a single data store so I’d be surprised if it were not true
> for service workers. That said, I will take a look. The fact is that web
> processes can only support one session at the moment and of code tries to do
> differently, then it is buggy code.

Looks like you're right that if I open the same page in private and non-private browsing, I get a single Service Worker Process. This is a very bad bug that we need to fix ASAP. Sharing WebContent processes in such way is not allowed, as we found while working on PSON.
That said, this is not strictly related to the patch at hand here, this will merely impact the next patch to simplify the code.
Comment 8 Chris Dumez 2019-09-06 15:21:57 PDT
ping review?
Comment 9 Brent Fulgham 2019-09-06 15:50:43 PDT
Comment on attachment 378123 [details]
Patch

This move looks correct to me, but it's troubling that both wincairo and iOS-wk2 seem to be having problems with service workers. Can you confirm these are unrelated to your patch before landing?
Comment 10 Chris Dumez 2019-09-06 15:59:03 PDT
(In reply to Brent Fulgham from comment #9)
> Comment on attachment 378123 [details]
> Patch
> 
> This move looks correct to me, but it's troubling that both wincairo and
> iOS-wk2 seem to be having problems with service workers. Can you confirm
> these are unrelated to your patch before landing?

The iOS-WK2 failures are unrelated (flaky tests, one of them being https://bugs.webkit.org/show_bug.cgi?id=201550).

The wincairo issue seems to be a related build failure. I am working on fixing this one before landing.
Comment 11 Chris Dumez 2019-09-06 15:59:20 PDT
Created attachment 378248 [details]
Patch
Comment 12 Chris Dumez 2019-09-06 16:58:37 PDT
Created attachment 378253 [details]
Patch
Comment 13 Chris Dumez 2019-09-06 18:53:25 PDT
Comment on attachment 378253 [details]
Patch

Clearing flags on attachment: 378253

Committed r249603: <https://trac.webkit.org/changeset/249603>
Comment 14 Chris Dumez 2019-09-06 18:53:27 PDT
All reviewed patches have been landed.  Closing bug.
Comment 15 Radar WebKit Bug Importer 2019-09-06 18:54:17 PDT
<rdar://problem/55137069>
Comment 16 Alex Christensen 2019-09-07 15:26:48 PDT
http://trac.webkit.org/r249617
Comment 17 Chris Dumez 2019-09-07 15:29:06 PDT
(In reply to Alex Christensen from comment #16)
> http://trac.webkit.org/r249617

Thanks.