Bug 216041 - Move NetworkProcessProxy ownership from WebProcessPool to WebsiteDataStore
Summary: Move NetworkProcessProxy ownership from WebProcessPool to WebsiteDataStore
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords: InRadar
: 203547 (view as bug list)
Depends on: 216822 216927 217063
Blocks:
  Show dependency treegraph
 
Reported: 2020-09-01 10:03 PDT by Alex Christensen
Modified: 2021-07-21 03:25 PDT (History)
13 users (show)

See Also:


Attachments
Patch (275.88 KB, patch)
2020-09-01 10:04 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (307.57 KB, patch)
2020-09-14 12:15 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (302.16 KB, patch)
2020-09-15 13:23 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (306.82 KB, patch)
2020-09-19 14:21 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (308.09 KB, patch)
2020-09-19 16:34 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (314.94 KB, patch)
2020-09-21 12:36 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (317.50 KB, patch)
2020-09-21 14:59 PDT, Alex Christensen
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (317.50 KB, patch)
2020-09-21 15:13 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (320.22 KB, patch)
2020-09-21 18:53 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (320.47 KB, patch)
2020-09-21 18:54 PDT, Alex Christensen
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (322.17 KB, patch)
2020-09-21 19:51 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (331.97 KB, patch)
2020-09-21 23:42 PDT, Alex Christensen
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (332.22 KB, patch)
2020-09-21 23:56 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (336.14 KB, patch)
2020-09-22 09:21 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (343.93 KB, patch)
2020-09-22 10:44 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (344.32 KB, patch)
2020-09-22 23:01 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (334.52 KB, patch)
2020-09-23 00:19 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (349.54 KB, patch)
2020-09-23 10:58 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Rebased patch (355.27 KB, patch)
2020-09-24 06:51 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
GLib API changes (13.50 KB, patch)
2020-09-24 06:52 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Patch (344.62 KB, patch)
2020-09-24 10:53 PDT, Alex Christensen
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (344.66 KB, patch)
2020-09-24 11:00 PDT, Alex Christensen
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (344.88 KB, patch)
2020-09-24 11:11 PDT, Alex Christensen
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (344.88 KB, patch)
2020-09-24 11:17 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (344.80 KB, patch)
2020-09-24 11:38 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (358.11 KB, patch)
2020-09-24 16:06 PDT, Alex Christensen
beidson: review+
Details | Formatted Diff | Diff
Rebased patch (355.55 KB, patch)
2020-09-29 03:47 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Patch (359.34 KB, patch)
2020-09-29 11:02 PDT, Alex Christensen
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (359.85 KB, patch)
2020-09-29 11:17 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2020-09-01 10:03:38 PDT
Move NetworkProcessProxy ownership from WebProcessPool to WebsiteDataStore
Comment 1 Alex Christensen 2020-09-01 10:04:54 PDT
Created attachment 407690 [details]
Patch
Comment 2 EWS Watchlist 2020-09-01 10:05:45 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 3 Alex Christensen 2020-09-01 10:07:28 PDT
I'm separating this approach's attempts so the EWS bubbles load faster and to keep the two approaches separate from each other so I can see my progress.
This first patch is just to see the EWS results.  It is not done yet.
Comment 5 Radar WebKit Bug Importer 2020-09-08 10:04:12 PDT
<rdar://problem/68514363>
Comment 6 Alex Christensen 2020-09-14 12:15:43 PDT
Created attachment 408733 [details]
Patch
Comment 7 EWS Watchlist 2020-09-14 12:16:31 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See https://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 8 Alex Christensen 2020-09-14 12:16:43 PDT
Not done yet.  Uploading WIP to get a checkpoint on which tests still need work.
Comment 9 Alex Christensen 2020-09-15 13:23:25 PDT
Created attachment 408853 [details]
Patch
Comment 10 Alex Christensen 2020-09-19 14:21:33 PDT
Created attachment 409211 [details]
Patch
Comment 11 Alex Christensen 2020-09-19 16:34:05 PDT
Created attachment 409214 [details]
Patch
Comment 12 Alex Christensen 2020-09-21 12:36:33 PDT
Created attachment 409300 [details]
Patch
Comment 13 Alex Christensen 2020-09-21 14:59:59 PDT
Created attachment 409323 [details]
Patch
Comment 14 Alex Christensen 2020-09-21 15:13:04 PDT
Created attachment 409327 [details]
Patch
Comment 15 Alex Christensen 2020-09-21 18:53:21 PDT
Created attachment 409341 [details]
Patch
Comment 16 Alex Christensen 2020-09-21 18:54:36 PDT
Created attachment 409342 [details]
Patch
Comment 17 Alex Christensen 2020-09-21 19:51:40 PDT
Created attachment 409345 [details]
Patch
Comment 18 Alex Christensen 2020-09-21 23:42:41 PDT
Created attachment 409349 [details]
Patch
Comment 19 Alex Christensen 2020-09-21 23:56:20 PDT
Created attachment 409350 [details]
Patch
Comment 20 Carlos Garcia Campos 2020-09-22 00:37:08 PDT
Comment on attachment 409350 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=409350&action=review

> Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:195
> +        if (m_sessionID.isEphemeral() || m_sessionID == PAL::SessionID::defaultSessionID())
> +            m_networkProcess = NetworkProcessProxy::defaultNetworkProcess();

This is actually making the network process a singleton for the default session and the reason why tests are failing in GTK. I'll investigate more to see why they fail when reusing the same process.
Comment 21 Carlos Garcia Campos 2020-09-22 01:01:20 PDT
Comment on attachment 409350 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=409350&action=review

>> Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:195
>> +            m_networkProcess = NetworkProcessProxy::defaultNetworkProcess();
> 
> This is actually making the network process a singleton for the default session and the reason why tests are failing in GTK. I'll investigate more to see why they fail when reusing the same process.

Every test case uses a new web context (process pool) to ensure a clean env. What happens now is that the first test case creates a website data store for the default session id, when the next test starts a new websitedata store is created for the default session id again, and the previous one is destroyed, since destroy happens after the create, we end up removing the newly created one, since we use the session id. I don't think we can share the network process for GLib API, it's ok to move the ownership to the data manager, but the process should be created and destroyed with the data store. I think we could share a process for ephemeral sessions, though.
Comment 22 Alex Christensen 2020-09-22 09:21:48 PDT
Created attachment 409367 [details]
Patch
Comment 23 Alex Christensen 2020-09-22 10:44:57 PDT
Created attachment 409378 [details]
Patch
Comment 24 Chris Dumez 2020-09-22 11:00:21 PDT
Comment on attachment 409378 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=409378&action=review

> Source/WebKit/ChangeLog:3
> +        Move NetworkProcessProxy ownership from WebProcessPool to WebsiteDataStore

Could the changelog explain why we're doing this? Why this is better than the current state? It is non-obvious to me at least.
Comment 25 Alex Christensen 2020-09-22 23:01:02 PDT
Created attachment 409451 [details]
Patch
Comment 26 Alex Christensen 2020-09-23 00:19:46 PDT
Created attachment 409452 [details]
Patch
Comment 27 Alex Christensen 2020-09-23 10:58:38 PDT
Created attachment 409484 [details]
Patch
Comment 28 Alex Christensen 2020-09-23 14:41:47 PDT
*** Bug 203547 has been marked as a duplicate of this bug. ***
Comment 29 Carlos Garcia Campos 2020-09-24 06:23:08 PDT
Comment on attachment 409484 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=409484&action=review

> Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:183
> -    if (m_sessionID != PAL::SessionID::defaultSessionID()) {
> -        auto result = nonDefaultDataStores().add(m_sessionID, this);
> -        ASSERT_UNUSED(result, result.isNewEntry);
> +    auto result = allDataStores().add(m_sessionID, this);
> +    ASSERT_UNUSED(result, result.isNewEntry);

This is a problem for GLib API too. In our API persistent data stores are always created with the default session ID, and are expected to be asociated with a web context (a process pool). So, you could have two default data stores each associated to a different context. Both are the default one, but the default for its network process. With this patch, creating a second data store will assert in debug. Note that we don't expose session IDs in our API on purpose. A possible solution would be to remove the concept of default session, and simply use a different session ID for each data store. After this patch the default session is not used that much, for soup we would just need to figure out how to implement the DNS resolver.
Comment 30 Carlos Garcia Campos 2020-09-24 06:51:27 PDT
Created attachment 409568 [details]
Rebased patch

This is the patch rebased on top of current trunk and patch attached to bug #216927.
Comment 31 Carlos Garcia Campos 2020-09-24 06:52:37 PDT
Created attachment 409569 [details]
GLib API changes

This patch contains the changes I added on top of the rebased patch just to make it easier to see them
Comment 32 Carlos Garcia Campos 2020-09-24 06:54:19 PDT
Comment on attachment 409569 [details]
GLib API changes

View in context: https://bugs.webkit.org/attachment.cgi?id=409569&action=review

> Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:163
> +#if PLATFORM(GTK) || PLATFORM(WPE)
> +    RELEASE_ASSERT_NOT_REACHED();
> +#endif

I added this to catch code using the default data store with the GLib API. I think the inspector uses it and probably some other places, so a few tests might still fail. I'll check those.
Comment 33 Carlos Garcia Campos 2020-09-24 06:56:54 PDT
Ah, there's also the initial accept cookie policy, but I think we no longer need that, I'll check that too, but I think bug #216927 is the only one blocking this from the GLib API now.
Comment 34 Alex Christensen 2020-09-24 09:14:54 PDT
Wonderful!  Thanks, Carlos!
Comment 35 Alex Christensen 2020-09-24 10:53:59 PDT
Created attachment 409598 [details]
Patch
Comment 36 Alex Christensen 2020-09-24 11:00:37 PDT
Created attachment 409600 [details]
Patch
Comment 37 Alex Christensen 2020-09-24 11:11:59 PDT
Created attachment 409603 [details]
Patch
Comment 38 Alex Christensen 2020-09-24 11:17:44 PDT
Created attachment 409604 [details]
Patch
Comment 39 Alex Christensen 2020-09-24 11:38:55 PDT
Created attachment 409607 [details]
Patch
Comment 40 Alex Christensen 2020-09-24 16:06:30 PDT
Created attachment 409631 [details]
Patch
Comment 41 Brady Eidson 2020-09-25 09:42:17 PDT
Comment on attachment 409631 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=409631&action=review

Too big to critically analyze every single change.

Overall, seems fine.

Yay tests.

One specific review comment.

> Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h:82
> -    bool shouldEnableITPDatabase { false };
> +    bool shouldEnableITPDatabase { true };

Why this change?
Comment 42 Alex Christensen 2020-09-25 12:32:55 PDT
Comment on attachment 409631 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=409631&action=review

>> Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h:82
>> +    bool shouldEnableITPDatabase { true };
> 
> Why this change?

This changed under me during my many rebases.  I don't think this did any change because it is always set from elsewhere, but I'll not make this change.
I'll also double check everything before landing to find any more there may be.
Comment 43 Alex Christensen 2020-09-25 16:54:01 PDT
http://trac.webkit.org/r267608
Comment 44 Alex Christensen 2020-09-25 23:36:13 PDT
This caused some API tests to fail on the bots.  Why they're so different than EWS, I may never know.

{
    "Failed": [
        {
            "output": "\n/Volumes/Data/slave/catalina-release/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:1543\nValue of: isRegistered\n  Actual: false\nExpected: true\n\n", 
            "name": "TestWebKitAPI.ResourceLoadStatistics.MigrateDataFromMissingTopFrameUniqueRedirectSameSiteStrictTableSchema"
        }, 
        {
            "output": "\n/Volumes/Data/slave/catalina-release/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:1582\nExpected equality of these values:\n  static_cast<int>([thirdPartyData count])\n    Which is: 0\n  1\n\n\n/Volumes/Data/slave/catalina-release/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:1586\nExpected equality of these values:\n  thirdParty.thirdPartyDomain\n    Which is: \"\"\n  @\"webkit.org\"\n    Which is: \"webkit.org\"\n\n\n/Volumes/Data/slave/catalina-release/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:1591\nExpected equality of these values:\n  firstParty.firstPartyDomain\n    Which is: \"\"\n  @\"apple.com\"\n    Which is: \"apple.com\"\n\n", 
            "name": "TestWebKitAPI.ResourceLoadStatistics.CanAccessDataSummaryWithNoProcessPool"
        }, 
        {
            "output": "\n/Volumes/Data/slave/catalina-release/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:1453\nValue of: isRegistered\n  Actual: false\nExpected: true\n\n", 
            "name": "TestWebKitAPI.ResourceLoadStatistics.MigrateDataFromIncorrectCreateTableSchema"
        }
    ], 
    "Timedout": [
        {
            "output": "", 
            "name": "TestWebKitAPI.ResourceLoadStatistics.ShouldNotGrandfatherOnStartup"
        }, 
        {
            "output": "", 
            "name": "TestWebKitAPI.ResourceLoadStatistics.GrandfatherCallback"
        }, 
        {
            "output": "", 
            "name": "TestWebKitAPI.ResourceLoadStatistics.ChildProcessesNotLaunched"
        }, 
        {
            "output": "", 
            "name": "TestWebKitAPI.ResourceLoadStatistics.GrandfatherCallbackDatabase"
        }, 
        {
            "output": "", 
            "name": "TestWebKitAPI.Fullscreen.WKViewDelegate"
        }
    ], 
    "Skipped": [], 
    "Crashed": []
}
Comment 45 Alex Christensen 2020-09-25 23:39:44 PDT
Reverted r267608 for reason:

Caused API test failures

Committed r267618: <https://trac.webkit.org/changeset/267618>
Comment 46 Carlos Garcia Campos 2020-09-26 00:26:13 PDT
Please, give me some time to check the layout test failures too before landing this again. See bug #217006
Comment 47 Carlos Garcia Campos 2020-09-28 00:56:16 PDT
Comment on attachment 409631 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=409631&action=review

> Tools/WebKitTestRunner/TestController.cpp:-3173
> -    WKContextSetPrimaryWebsiteDataStore(context, defaultWebsiteDataStore());

This is the problem of layout tests for GTK and WPE. The WTR default data store is not set as web view data store either now, so when the web page is created the default data store s created and used for the page. I'll submit a rebased patch with the fix.
Comment 48 Carlos Garcia Campos 2020-09-29 03:47:36 PDT
Created attachment 409981 [details]
Rebased patch

Patch rebased and updated to fix GTK and WPE layout tests
Comment 49 Alex Christensen 2020-09-29 11:02:24 PDT
Created attachment 410019 [details]
Patch
Comment 50 Alex Christensen 2020-09-29 11:17:25 PDT
Created attachment 410023 [details]
Patch
Comment 51 Alex Christensen 2020-09-29 14:44:05 PDT
http://trac.webkit.org/r267763
Comment 52 Alex Christensen 2020-10-05 16:46:44 PDT
This was rdar://problem/69175060
Comment 53 Alex Christensen 2021-01-15 13:51:34 PST
Comment on attachment 410023 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=410023&action=review

> Source/WebKit/NetworkProcess/NetworkProcess.cpp:-350
> -    addIndexedDatabaseSession(sessionID, parameters.defaultDataStoreParameters.indexedDatabaseDirectory, parameters.defaultDataStoreParameters.indexedDatabaseDirectoryExtensionHandle);

This is still needed.  See https://bugs.webkit.org/show_bug.cgi?id=220666