Bug 213290 - [GTK][WPE] Add API to configure and handle service worker registrations to WebKitWebsiteDataManager
Summary: [GTK][WPE] Add API to configure and handle service worker registrations to We...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: Gtk
Depends on:
Blocks:
 
Reported: 2020-06-17 06:46 PDT by Carlos Garcia Campos
Modified: 2020-06-19 00:56 PDT (History)
5 users (show)

See Also:


Attachments
Patch (28.53 KB, patch)
2020-06-17 06:52 PDT, Carlos Garcia Campos
mcatanzaro: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2020-06-17 06:46:17 PDT
The default path is always used even for apps setting a base data directory. We should handle WebsiteDataType::ServiceWorkerRegistrations to configure the directory and allow to fetch and clear them.
Comment 1 Carlos Garcia Campos 2020-06-17 06:52:42 PDT
Created attachment 402101 [details]
Patch
Comment 2 EWS Watchlist 2020-06-17 06:53: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 Michael Catanzaro 2020-06-17 07:31:22 PDT
Comment on attachment 402101 [details]
Patch

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

> Source/WebKit/ChangeLog:8
> +        The default path is always used even for apps setting a base data directory. We should handle

I suggest we rm -rf the default path each time WebKit is started, and change the default path to something new. Leaking website data outside the application's base data directory is really bad.
Comment 4 Michael Catanzaro 2020-06-17 07:33:16 PDT
i.e. we could do the equivalent of:

$ rm -rf ~/.local/share/webkitgtk/serviceworkers

And change the new default path to: ~/.local/share/webkitgtk/ServiceWorkers.

That way, previously-leaked website data gets cleaned up on upgrade to 2.30. We have a one-time loss of previous service workers, but I guess that's OK?
Comment 5 Michael Catanzaro 2020-06-17 07:33:34 PDT
Comment on attachment 402101 [details]
Patch

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

> Source/WebKit/UIProcess/API/glib/WebKitWebsiteDataManager.cpp:222
> +        if (!priv->swRegistrationsDirectory)
> +            priv->swRegistrationsDirectory.reset(g_build_filename(priv->baseDataDirectory.get(), "serviceworkers", nullptr));

Maybe: "ServiceWorkers"?
Comment 6 Carlos Garcia Campos 2020-06-17 07:47:28 PDT
(In reply to Michael Catanzaro from comment #4)
> i.e. we could do the equivalent of:
> 
> $ rm -rf ~/.local/share/webkitgtk/serviceworkers
> 
> And change the new default path to: ~/.local/share/webkitgtk/ServiceWorkers.
> 
> That way, previously-leaked website data gets cleaned up on upgrade to 2.30.
> We have a one-time loss of previous service workers, but I guess that's OK?

But this is the default location, applications not using base data directory would still use that one. I think it was a mistake to use shared locations, and we should probably change all default locations to depend on the app name, but unfortunately we can't remove the default dirs :-(
Comment 7 Carlos Garcia Campos 2020-06-17 07:49:54 PDT
(In reply to Michael Catanzaro from comment #5)
> Comment on attachment 402101 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=402101&action=review
> 
> > Source/WebKit/UIProcess/API/glib/WebKitWebsiteDataManager.c:222
> > +        if (!priv->swRegistrationsDirectory)
> > +            priv->swRegistrationsDirectory.reset(g_build_filename(priv->baseDataDirectory.get(), "serviceworkers", nullptr));
> 
> Maybe: "ServiceWorkers"?

That's consistent with other default dir names that are lowercase like localstorage, but I don't really mind, this is not expected to be ever accessed by users.
Comment 8 Michael Catanzaro 2020-06-17 08:32:05 PDT
(In reply to Carlos Garcia Campos from comment #7)
> That's consistent with other default dir names that are lowercase like
> localstorage, but I don't really mind, this is not expected to be ever
> accessed by users.

It doesn't matter either way. I guess matching the default location is best, though. If we were going to rename the default location and delete the old default -- note I used capitals for the proposed new default default location to distinguish it from the old default location -- then it would be needed for consistency.

(In reply to Carlos Garcia Campos from comment #6)
> I think it was a mistake to use shared locations,
> and we should probably change all default locations to depend on the app
> name, but unfortunately we can't remove the default dirs :-(

I agree it was a mistake. Let's fix this in the GTK 4 API? We can use GtkApplication ID if g_application_get_default() returns non-null, otherwise use g_get_prgname(). Applications that set base data and cache directory would be unaffected.
Comment 9 Carlos Garcia Campos 2020-06-18 01:17:56 PDT
Committed r263204: <https://trac.webkit.org/changeset/263204>
Comment 10 Michael Catanzaro 2020-06-18 09:15:37 PDT
OK, we missed a couple spots. It also has to be added to WebProcessProxy::platformGetLaunchOptions in WebProcessProxyGLib.cpp and bubblewrapSpawn in BubblewrapLauncher.cpp. We should probably add comments to warn about this....
Comment 11 Carlos Garcia Campos 2020-06-19 00:56:12 PDT
(In reply to Michael Catanzaro from comment #10)
> OK, we missed a couple spots. It also has to be added to
> WebProcessProxy::platformGetLaunchOptions in WebProcessProxyGLib.cpp and
> bubblewrapSpawn in BubblewrapLauncher.cpp. We should probably add comments
> to warn about this....

Registrations are handled by the network process.