Firefox has moved into a snap
in Ubuntu.
Because the KeepassXC extensions relies on NativeMessaging to communicate with the KeepassXC application, this initially broke use of that password manager.
Support for NativeMessaging has been added, and I've written about how to get Firefox running with KeepassXC.
But, I've now run into a somewhat odd issue.
It works exactly as described if I run
snap run firefox
from within a terminal.
However if I launch Firefox from the K-Menu, communication with KeepassXC breaks.
Activity
13-Sep-22 16:42
assigned to @btasker
13-Sep-22 16:42
moved from project-management-only/staging#4
13-Sep-22 16:42
assigned to @btasker
13-Sep-22 16:44
I gave some detail from my previous testing here.
/snap/bin/firefox %u
and KeepassXC doesn’t work.snap run firefox
in a terminal, KeepassXC workssnap run firefox
doesn't resolve itrun in terminal
however does13-Sep-22 16:47
Checking environment:
about:support
and then saved the resulting page.about:support
and then saved the resulting page.diff
reports no difference between them13-Sep-22 16:53
OK, this gets weirder.
I did the following
Launch firefox using the working mechanism, verified it was working. Preserved a copy of the desktop file
Edited the K-Menu item to disable
run in terminal
Ran from the K-Menu and verified that it's not working Preserved a copy of the desktop fileBut.... if I go into Dolphin and double-click
firefox_firefox_notworking.desktop
Firefox launches with KeepassXC communication working.It's seems like this issue is specific to stuff launched from the K-Menu
13-Sep-22 16:54
For posterity, a diff of the two
.desktop
files13-Sep-22 17:16
Going to try and capture some logs during the "broken" state.
Have updated the command in the K-Menu
There's a log per worker by the looks of it
They're all empty though - I've screwed up somewhere clearly.
I've tried a few different invocations and it just won't log anything.
What I have noticed, though, is that working/broken seems to change depending on how you construct the command.
This gives the broken behaviour
This gives the working behaviour
I'm guessing the K-Menu is deciding the second is a shell command, whereas the other gets fired some other way?
Could it be launch feedback?
Disabling that
It fucking works!
There must be something D-Bus'y getting in the way.
I've tried the various different options for
X-DBUS-StartupType=
and it doesn't work with any of them13-Sep-22 19:06
The other question that needs answering though, is why isn't my other system affected? I've just checked and it's got Launch Feedback enabled...
Working
Not Working
So, we are looking at different versions - I'll update Optimus and see if it breaks
13-Sep-22 19:14
We've ended up on a slightly newer version
Issue doesn't occur.
Bringing bumblebee up to date
The issue is still present.
Version of Keepassxc is consistent between systems
As is
xdg-desktop-portal
KDE's the same version etc etc.
13-Sep-22 19:25
Ah-ha.
When running Firefox using the broken mechanism, the following gets written to the journal
So, the reason Keepassxc can't be communicated with is
xdg-desktop-portal
is throwing an assert and failing.Grabbing the code from https://github.com/flatpak/xdg-desktop-portal.git, whilst I see the function call it doesn't tell us too much.
The function throwing the assert is part of Glib rather than xdg-desktop-portal: #g-app-info-get-id, but it's got issues with the object that
xdg-desktop-portal
is passing into it.13-Sep-22 19:32
Running xdg-desktop-portal in a terminal so I can collect output
File:
xdg.log
The line
is interesting.
Running again, but with the "fix" in place in the K-Menu item (run in terminal)
xdg-working.log
No complaints about permissions in that one
Runnning a
diff
of the files we find there's another difference further up14-Sep-22 07:44
Waking up for the day, so figured I'd have a quick poke through the sources whilst my coffee sinks in.
It looks like the assert
Happens here
The function doesn't do anything too special - if the first argument evaluates false then the second argument is returned.
The subsequent assert will be because
desktop_id
is null.xdg-desktop-portal
ultimately segfaults.I don't think we need/want to chase that down though. Really we need to figure out why what we're passing in isn't of type
GAppInfo
.The difference in startup's might point us in the right direction
In particular, that early change in process:
The failed one seems to rely on a unit, whereas the working one invokes a routine.
One of the things I wondered about overnight - is it that the broken one is somehow invoked on my user's behalf, rather than as my user?
14-Sep-22 09:04
Running
Didn't yield anything.
However, it's because I've stopped and started Firefox since then (although still in the broken state). The hash at the end has changed (a run id maybe?)
Value:
The second one is a directory
So, under the hood, the broken version is in a SystemD scope (within the
app
slice). Of course, it's possible (likely, even) that the working version is too (presumablysnap
relies on this).Annoyingly,
systemctl
seems to lack an option to list scopes (or slices for that matter), but we can check which scopes are running in that slice withThere are a few
Killing Firefox and launching the working version (I need it working to work anyway)
Ok, will have to come back to this later. I'm not currently sure how to go about it, but I guess we need to find a way to identify how it ultimately gets called, and from what context.
14-Sep-22 11:02
Figured I'd have a quick go at getting
auditd
to log the call chain to see whether we can spot anything interesting.Telling
auditd
to log everythingThen tailed
/var/log/audit/audit.log
andtee
'd into a file:14-Sep-22 11:22
OK, so in the not working one, we see the run occur
The parent pid is 11541, which is
(makes sense)
There's a fair old chain there
Ultimately we seen
snap-confine
being calledand
desktop-launch
Then there are lots and lots of file accesses as firefox comes up
There are some dbus comms
Actually, it does that a lot, but the exit code is 0 so I assume it's OK
Eventually,
xdg-desktop-portal
gets kicked offThe parent there is systemd's user process
There's lots of chatter, and then eventually we see
xdg-desktop-portal
die14-Sep-22 11:33
in
working.log
We see the terminal get opened
The parent there (unsurprisingly) is plasmashell
That invokes snap
and desktop-launch
Eventually
xdg-desktop-portal
is launchedAgain, the parent PID is the same as in notworking
Problem is, I just don't see much difference - albeit from a quick skim.
It does seem, though, like the snap being launched directly by
plasmashell
yields different behaviour to when run another way.14-Sep-22 11:47
I created a new K-Menu item
Then ran it.
Then switched it over to without.
Running a diff of the two, there are various differences (because the terminal -
konsole
- also sets env vars), but the version without terminal has thisIt's used in startup notification:
So, it might be interesting to override this in the run command and see if that gains us anything
14-Sep-22 12:49
Setting
DESKTOP_STARTUP_ID
doesn't seem to have broken the working version - though perhaps because it won't have reached anything with that id?Just in case my initial check of environments was wrong, I've also pulled environment vars out of
/proc
for both broken and non-broken instances of FirefoxNothing really stands out.
The
auditd
stuff shows the commands run are the same, so it'd have to be something in the environment right? And yet there's nothing.From the
xdg-desktop-portal
failure we can see it's failing to get the application's information, which I think is effectively derived from the underlying.desktop
. I just can't work out why - I don't really know what I'm looking for.Perhaps though, I'm looking at the wrong process? Maybe I should be looking closer at the portal process rather than Firefox - it's spawned as a result of the Firefox snap, so perhaps the way Firefox is started has a knock-on effect down the chain in a way that won't be visible when looking at Firefox itself?
14-Sep-22 13:26
Working:
To check it in the notworking state, I need it to stay up, so will disable the keepassxc browser extension for the test
So.... it has the same PID - because, of course, we've not gone and segfaulted it yet. That'd suggest that the issue isn't related to the way it's launched...
Not much point grabbing the env then, as it won't have changed.
But... what happens if I now reenable keepassxc - will it cause
xdg-desktop-portal
to crash out?no:
and the extensions working!
Closing Firefox and re-launching to verify it still dies on startup
It killed it
So, lets disable the extension again and re-launch, just to verify that I didn't accidentally leave a working session open.
It killed it that time.
Ahh, but there's a difference - last time there was a preexisting working
xdg-desktop-portal
whereas this instance was launched by the "broken" Firefox. Let's do that cycle again quicklyNo, didn't work. Did I screw up before, or was it blind luck?
In the
ps
above, I see that some of the subprocesses have been running for quite some time - does this still happen if I kill them?It does.
Let's get back on track and compare the environments just in case (doesn't seem likely though as the original
xdg-desktop-portal
doesn't seem to survive)Basically exactly the same (some changes in PIDs).
Have hit a bit of dead-end this way then. I guess it's time to dig into the code a bit more - it definitely looks like it's something about the way in which
xdg-desktop-portal
retrieves information about apps rather than the way it's instantiated.14-Sep-22 14:26
HOLY SHIT, A CLUE!!!
I had my browser open in the broken state, and turned the KeepassXC browser extension back on in Firefox's settings.
I was on a Zoom call at the time, and Zoom exited as soon as I turned the extension back on.
I've had weird shit previously with Zoom doing weird stuff to terminator because of Zoom's
ibus
dependency. I wonder if it's something along those lines?It would also go some way to explaining why my other system doesn't suffer from this - it doesn't have Zoom installed. I might have to install it and see whether that breaks it.
14-Sep-22 14:30
OK, installing Zoom didn't break comms on my other laptop.
But, updating Zoom on this laptop
Did fix the issue.
There must have been something about the older version which interfered.
They have a changelog at https://support.zoom.us/hc/en-us/articles/205759689-Release-notes-for-Linux but I don't see anything obvious - there is one about notification issues on Fedora, I wonder if the fix for that involved changing the way that Zoom hooks into the system?
14-Sep-22 15:02
Just to TL:DR this in case I need to refer back:
Firefox on Ubuntu is now run via
snap
In order to facilitate communication with local applications (such as
KeepassXC
) via Native Messaging, there's a new daemon calledxdg-desktop-portal
If a certain version (
5.7.31792.0820
and possibly some later/earlier versions - it's not known when this was fixed) of Zoom is present (doesn't need to be running, just installed) on the machine, thenxdg-desktop-portal
will segfault if the following is truerun in terminal
setxdg-desktop-portal
will not segfault if Firefox is started from the commandline, by doubleclicking a.desktop
file (even the one used by the K-Menu) or if the K-Menu item is set torun in terminal
.If the extension is disabled, the launching Firefox from the K-Menu will not cause
xdg-desktop-portal
to segfault. However, it will segfault once the extension is enabled.Curiously, if the extension is disabled, Firefox launched, a Zoom video call started and then the extension re-enabled, not only will
xdg-desktop-portal
segfault, but Zoom will die too.Updating Zoom to the latest version (
5.11.10.4400
) resolves the issue.22-Sep-22 07:36
Re-opening - this has broken again.
There was an update pending, so I did
snap refresh
and was moved tofirefox (beta) 106.0b2-1
- comms with KeepassXC broke again.As before, using "Run in Terminal" allows it to work...
I don't have time to troubleshoot this further at the moment, so am using "Run in Terminal" so that I can work. When I've a little more time free, I'll start by rebooting and then try and troubleshoot this again/further.
Although the previous Zoom update didn't update any dependencies, I wonder if it's post-install scripts (I assume it has them, haven't checked) disturbed the state of something somewhere.
Can check quite quickly/easily what it does
Which gives us
Seems unlikely that the
chown
at the end is going to fix an unrelated application. It's plausible thatupdate-desktop-database
might though - we saw earlier in the investigation that the Application details fetched byxdg-desktop-portal
are empty, so it might be thatupdate-desktop-database
causes it to be repopulated.We can test that quickly.
04-Oct-22 19:14
Another user has reported that they're experiencing the same
Should really try and find time to troubleshoot this further.
26-Jun-23 10:38
Never got chance to dig in more, and it's all working fine for me again. I've had a change of laptop in the ensuing time and am now running XFCE rather than KDE (which may or may not be relevant).