Bug 180813 - [GTK] Notifications broken under flatpak and bubblewrap sandbox
Summary: [GTK] Notifications broken under flatpak and bubblewrap sandbox
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: Other
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 218121
  Show dependency treegraph
 
Reported: 2017-12-14 08:05 PST by Michael Catanzaro
Modified: 2021-06-30 08:00 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Catanzaro 2017-12-14 08:05:07 PST
Notifications do not work under Flatpak. We either need to use the notification portal D-Bus API, or (more likely) use GNotification.

Carlos Garcia wants to keep support for libnotify, so we should use GNotification if there is a GApplication (which will be required for notifications to work under flatpak), and libnotify otherwise.
Comment 1 Michael Catanzaro 2019-07-13 15:48:19 PDT
Using GNotification would also help us fix https://gitlab.gnome.org/GNOME/epiphany/issues/853.
Comment 2 Michael Catanzaro 2019-07-13 15:50:17 PDT
(In reply to Michael Catanzaro from comment #1)
> Using GNotification would also help us fix
> https://gitlab.gnome.org/GNOME/epiphany/issues/853.

We'll need to create a separate WebKit bug for this if we close this one using direct portal access rather than GNotification. But I think GNotification is the way to go. That kills two birds with one stone.
Comment 3 Patrick Griffis 2019-07-13 17:11:18 PDT
GNotification is highly tied to GApplication. So it is unusable in all cases where the application using WebKitGTK doesn't use GApplication.

We already assert that applications using the bubblewrap sandbox use GApplication though so maybe thats a direction we want to move towards?
Comment 4 Patrick Griffis 2019-07-13 17:12:45 PDT
I now realize you covered that but using the portal directly probably avoids the need for GApplication.

libnotify is honestly awful, everything it does is main thread blocking for example, so its best to avoid it and let it die.
Comment 5 Michael Catanzaro 2019-07-13 18:24:25 PDT
So libnotify would be only for fallback regardless.

To use the portal directly, we'd still need to rely on GtkApplication for the app ID in order to solve epiphany#853 I guess?

Matthias previously indicated he'd allow a libnotify-style portal implementation instead of a GApplication-style implementation, but hopefully we won't need that.
Comment 6 Patrick Griffis 2019-07-14 13:26:30 PDT
(In reply to Michael Catanzaro from comment #5)
> So libnotify would be only for fallback regardless.

Well, the `org.freedesktop.Notification` service is the fallback. My point is the literal `libnotify` library is bad.

> To use the portal directly, we'd still need to rely on GtkApplication for
> the app ID in order to solve epiphany#853 I guess?

No, every flatpak contains its own id. GApplication is not required:


    flatpak run --command=sh org.gnome.Epiphany/x86_64/master    
    gdbus call -d org.freedesktop.portal.Desktop -e -o /org/freedesktop/portal/desktop -m org.freedesktop.portal.Notification.AddNotification "''" "{'title': <'foo'>, 'body': <'bar'>}"
    # Works as expected
Comment 7 Michael Catanzaro 2019-07-14 17:24:55 PDT
(In reply to Patrick Griffis from comment #6)
> Well, the `org.freedesktop.Notification` service is the fallback. My point
> is the literal `libnotify` library is bad.

We could stop using it and use org.freedesktop.Notification directly, of course.

> > To use the portal directly, we'd still need to rely on GtkApplication for
> > the app ID in order to solve epiphany#853 I guess?
> 
> No, every flatpak contains its own id. GApplication is not required:
> 
> 
>     flatpak run --command=sh org.gnome.Epiphany/x86_64/master    
>     gdbus call -d org.freedesktop.portal.Desktop -e -o
> /org/freedesktop/portal/desktop -m
> org.freedesktop.portal.Notification.AddNotification "''" "{'title': <'foo'>,
> 'body': <'bar'>}"
>     # Works as expected

Does WebKit have any way to know the flatpak app ID (other than to hope it's the same as the GtkApplication ID)?
Comment 8 Patrick Griffis 2019-07-14 21:52:23 PDT
(In reply to Michael Catanzaro from comment #7)
> Does WebKit have any way to know the flatpak app ID (other than to hope it's
> the same as the GtkApplication ID)?

Sure we can parse `/.flatpak-info`.
Comment 9 Michael Catanzaro 2021-06-30 08:00:38 PDT
(In reply to Michael Catanzaro from comment #0)
> Carlos Garcia wants to keep support for libnotify, so we should use
> GNotification if there is a GApplication (which will be required for
> notifications to work under flatpak), and libnotify otherwise.

Since r279369 we made WebKit crash if the bubblewrap sandbox is enabled but GApplication is not used, so IMO we should just drop use of libnotify.

Applications that aren't using GApplication surely do not need desktop notifications. Even WPE applications that don't use GtkApplication should be expected to use GApplication, as they should all be sandboxed.