Call for testing: native messaging support in the Firefox snap

It doesn’t seem to work by default with FirefoxPWA

However, it works after running flatpak permission-set webextensions firefoxpwa snap.firefox yes. I’m certain I have not seen any permissions request dialog. Is this a bug that it automatically denies access?

$ snap version
snap    2.57.1
snapd   2.57.1
series  16
ubuntu  22.04
kernel  5.15.0-47-generic
$ snap info firefox
...
installed:          105.0b9-1               (1836) 187MB -
MOZ_LOG=NativeMessagingPortal:5 snap run firefox

[Parent 99494: Main Thread]: D/NativeMessagingPortal creating session with handle suffix firefox_firefoxpwa_80670177
[Parent 99494: Main Thread]: D/NativeMessagingPortal session created with handle /org/freedesktop/portal/desktop/session/1_1212/firefox_firefoxpwa_80670177
[Parent 99494: Main Thread]: D/NativeMessagingPortal starting firefoxpwa, requested by firefoxpwa@filips.si in session /org/freedesktop/portal/desktop/session/1_1212/firefox_firefoxpwa_80670177
[Parent 99494: Main Thread]: D/NativeMessagingPortal native application start requested in session /org/freedesktop/portal/desktop/session/1_1212/firefox_firefoxpwa_80670177, pending response for /org/freedesktop/portal/desktop/request/1_1212/firefox/630856936
[Parent 99494: Main Thread]: D/NativeMessagingPortal got response signal for /org/freedesktop/portal/desktop/request/1_1212/firefox/630856936 in session /org/freedesktop/portal/desktop/session/1_1212/firefox_firefoxpwa_80670177
[Parent 99494: Main Thread]: D/NativeMessagingPortal native application start canceled by user in session /org/freedesktop/portal/desktop/session/1_1212/firefox_firefoxpwa_80670177
[Parent 99494: Main Thread]: D/NativeMessagingPortal session /org/freedesktop/portal/desktop/session/1_1212/firefox_firefoxpwa_80670177 was closed by the portal
[Parent 99494: Main Thread]: D/NativeMessagingPortal cannot close session /org/freedesktop/portal/desktop/session/1_1212/firefox_firefoxpwa_80670177, unknown handle
[Parent 99494: Main Thread]: D/NativeMessagingPortal will be used
[Parent 99494: Main Thread]: D/NativeMessagingPortal is available

EDIT: I just got the permissions request dialog for KeepassXC, and now I’m 200% sure I did not get this dialog for firefoxpwa.

1 Like

Can you try the following when firefox is not running:

flatpak permission-set webextensions firefoxpwa snap.firefox ask

Then start firefox and use the PWA addon. Do you get a prompt?

To install beta in parallel with stable, try this:

snap install --beta --unaliased firefox_beta

I noticed there’s a 105.0-2 version on latest/candidate channel. Unfortunately, native messaging seems to be broken on it. - works fine with 105.0b9-1 on beta channel Is this by design? Will 105.0 official release not include native messaging support?

Yes, this is expected: the native messaging support requires a patch that isn’t merged upstream yet, and until it is merged it will be available only in the beta channel, regardless of version number.

Thanks for explaining. It seems I’ll be beta testing for a little longer than expected. :slight_smile:

The native messaging support continues to work (using KeePassXC extension), but unlike the stable FF version, there continues to be a problem with the cursor (FFsnap 106.0b1; Ubuntu 22.04 on thinkpad). With a hi DPI screen, the cursor size is so small it is difficult to see.

On the stable version of FF and all other programs including Chromium and other snaps, the cursor is much larger - as set by the user.

This looks like bug #1746759.

Hi,

This is probably of low consequence, but one side effect of using xdg-desktop-portal is that the native messaging host cannot be identified with the Firefox process from outside, as it’s now running under a different PID;

The context is (i’ll try to make it short) -

I have a window switcher GUI application, that also lists currently running browser tabs. In order to get the tabs info, it communicates with an extension in the running browser, via the native messaging host. It then knows which tabs to associate to which browser instance, because the native messaging host runs under the browser’s PID. However this is not the case with snap Firefox.

I realize that having the same PID was not guaranteed in the first place. But do you know of any way around it? (is there a way to tell which browser started the xdg-desktop-portal?)

Thanks. And apologies if this is not the right place to post this.

That’s a very interesting use of native messaging, and I must admit I’m not sure how to make this work in a confined snap where the external process is a child of the portal, not of the browser.

I just noticed a lock file in my firefox profile directory that’s a broken symlink to a file called 127.0.0.1:+PID (where PID is the pid of the main firefox process). Could that be of any use?

I tested ff2mpg, which also requires native messaging, and works well on nightly.

I did however need to run the following to get it to work:

flatpak permission-set webextensions ff2mpv snap.firefox yes

Which is counter intuitive because:

  1. it’s a manual step
  2. flatpak???

This needs to be automated somehow and not require flatpak.

2 Likes

It’s a manual step only if you missed the initial modal dialog requesting your permission, or if your desktop environment doesn’t have the required wiring to present this dialog. Can you share details about your desktop environment?

Regardless, we definitely need a UI to allow changing these permissions, having to use the flatpak CLI doesn’t cut it, of course. There’s no good reason for this permissions database management tool to be flatpak really, other than “it was originally written by flatpak developers, and no-one else used it at the time”. I agree this is confusing.

The installation of the extension was pre-existing, that is, firefox latched on to a pre-existing firefox nightly profile folder. Not sure if that would make the permission dialog not appear.

I’m using Sway, not gnome.

That would explain why you didn’t get any modal dialog in the first place.

Long awaited update: native messaging support is now available in the stable channel.

If you find issues with the functionality, feel free to either report them here, or file a bug.

Thanks to everyone who helped along the way to get here, the testing and feedback has been very valuable.

4 Likes

thanks for this tip. I was seeing this:

systemctl --user status xdg-desktop-portal
    ● xdg-desktop-portal.service - Portal service
         Loaded: loaded (/usr/lib/systemd/user/xdg-desktop-portal.service; static)
         Active: active (running) since Sun 2022-11-20 11:13:50 AEDT; 22min ago
       Main PID: 2730 (xdg-desktop-por)
          Tasks: 7 (limit: 19119)
         Memory: 4.1M
            CPU: 1.041s
         CGroup: /user.slice/user-1000.slice/user@1000.service/session.slice/xdg-desktop-portal.service
                 └─2730 /usr/libexec/xdg-desktop-portal

Nov 20 11:13:49 ubuntu-virtio systemd[2394]: Starting Portal service...
Nov 20 11:13:50 ubuntu-virtio systemd[2394]: Started Portal service.
Nov 20 11:25:04 ubuntu-virtio xdg-desktop-por[2730]: Could not find WebExtensions backend: cannot find native messaging server
Nov 20 11:34:57 ubuntu-virtio xdg-desktop-por[2730]: Could not find WebExtensions backend: cannot find native messaging server

after the suggestion:

[~] [test-dear@eks] $ rm -f ~/.local/share/flatpak/db/webextensions
[~] [test-dear@eks] $ systemctl --user restart xdg-desktop-portal

and now via the Firefox Gnome Shell Extension add-on I can control and install extensions. The website has a warning about the latest API not being supported, but the integration with Firefox works none the less, Firefox beta 108.