<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>180813</bug_id>
          
          <creation_ts>2017-12-14 08:05:07 -0800</creation_ts>
          <short_desc>[GTK] Notifications broken under flatpak and bubblewrap sandbox</short_desc>
          <delta_ts>2022-07-29 14:16:50 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKitGTK</component>
          <version>Other</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=192748</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=212079</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=240347</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>218121</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Catanzaro">mcatanzaro</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>aperez</cc>
    
    <cc>bugs-noreply</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>pgriffis</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1381614</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2017-12-14 08:05:07 -0800</bug_when>
    <thetext>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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1552714</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2019-07-13 15:48:19 -0700</bug_when>
    <thetext>Using GNotification would also help us fix https://gitlab.gnome.org/GNOME/epiphany/issues/853.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1552715</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2019-07-13 15:50:17 -0700</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #1)
&gt; Using GNotification would also help us fix
&gt; https://gitlab.gnome.org/GNOME/epiphany/issues/853.

We&apos;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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1552720</commentid>
    <comment_count>3</comment_count>
    <who name="Patrick Griffis">pgriffis</who>
    <bug_when>2019-07-13 17:11:18 -0700</bug_when>
    <thetext>GNotification is highly tied to GApplication. So it is unusable in all cases where the application using WebKitGTK doesn&apos;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?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1552721</commentid>
    <comment_count>4</comment_count>
    <who name="Patrick Griffis">pgriffis</who>
    <bug_when>2019-07-13 17:12:45 -0700</bug_when>
    <thetext>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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1552725</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2019-07-13 18:24:25 -0700</bug_when>
    <thetext>So libnotify would be only for fallback regardless.

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

Matthias previously indicated he&apos;d allow a libnotify-style portal implementation instead of a GApplication-style implementation, but hopefully we won&apos;t need that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1552753</commentid>
    <comment_count>6</comment_count>
    <who name="Patrick Griffis">pgriffis</who>
    <bug_when>2019-07-14 13:26:30 -0700</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #5)
&gt; 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.

&gt; To use the portal directly, we&apos;d still need to rely on GtkApplication for
&gt; 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 &quot;&apos;&apos;&quot; &quot;{&apos;title&apos;: &lt;&apos;foo&apos;&gt;, &apos;body&apos;: &lt;&apos;bar&apos;&gt;}&quot;
    # Works as expected</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1552779</commentid>
    <comment_count>7</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2019-07-14 17:24:55 -0700</bug_when>
    <thetext>(In reply to Patrick Griffis from comment #6)
&gt; Well, the `org.freedesktop.Notification` service is the fallback. My point
&gt; is the literal `libnotify` library is bad.

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

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

Does WebKit have any way to know the flatpak app ID (other than to hope it&apos;s the same as the GtkApplication ID)?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1552788</commentid>
    <comment_count>8</comment_count>
    <who name="Patrick Griffis">pgriffis</who>
    <bug_when>2019-07-14 21:52:23 -0700</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #7)
&gt; Does WebKit have any way to know the flatpak app ID (other than to hope it&apos;s
&gt; the same as the GtkApplication ID)?

Sure we can parse `/.flatpak-info`.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1773744</commentid>
    <comment_count>9</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2021-06-30 08:00:38 -0700</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #0)
&gt; Carlos Garcia wants to keep support for libnotify, so we should use
&gt; GNotification if there is a GApplication (which will be required for
&gt; 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&apos;t using GApplication surely do not need desktop notifications. Even WPE applications that don&apos;t use GtkApplication should be expected to use GApplication, as they should all be sandboxed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1868258</commentid>
    <comment_count>10</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2022-05-11 17:25:20 -0700</bug_when>
    <thetext>Notifications seem to work fine currently, except the urgency is not set properly. I wonder if libnotify learned to use portals.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1868431</commentid>
    <comment_count>11</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2022-05-12 08:46:32 -0700</bug_when>
    <thetext>Follow-up bug for GNotification: bug #240347</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1887324</commentid>
    <comment_count>12</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2022-07-28 07:52:39 -0700</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #10)
&gt; Notifications seem to work fine currently, except the urgency is not set
&gt; properly. I wonder if libnotify learned to use portals.

I was testing with Epiphany, but Epiphany handles notifications manually using GNotification. Oops.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1887731</commentid>
    <comment_count>13</comment_count>
    <who name="Patrick Griffis">pgriffis</who>
    <bug_when>2022-07-29 12:58:10 -0700</bug_when>
    <thetext>libnotify 0.8 uses the notification portal now.

I still agree it should be migrated away from but it probably resolves this issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1887741</commentid>
    <comment_count>14</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2022-07-29 13:19:57 -0700</bug_when>
    <thetext>That should certainly resolve this. OK, closing again.

P.S. Maybe we could just add an async API to libnotify. Then there wouldn&apos;t really be anything wrong with using libnotify anymore? As long as WebKit doesn&apos;t block when showing a notification, it&apos;s OK? Well, that&apos;s a separate issue, for a separate bug report....</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1887753</commentid>
    <comment_count>15</comment_count>
    <who name="Patrick Griffis">pgriffis</who>
    <bug_when>2022-07-29 14:16:50 -0700</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #14)
&gt; P.S. Maybe we could just add an async API to libnotify. Then there wouldn&apos;t
&gt; really be anything wrong with using libnotify anymore? As long as WebKit
&gt; doesn&apos;t block when showing a notification, it&apos;s OK? Well, that&apos;s a separate
&gt; issue, for a separate bug report....

I think its worth doing. Upstream seemed on the fence if libnotify should add async API though.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>