site  contact  subhomenews

Fix Firefox second instance will not start

December 13, 2023 — BarryK

I posted about this problem to the forum:

https://forum.puppylinux.com/viewtopic.php?p=103201#p103201

The error popup states "Firefox is already running, but is not responding".

I discovered that dbus is the problem, as reported here:

https://discourse.mozilla.org/t/how-does-firefox-discover-a-running-instance-to-connect-to/109957

EasyOS is unique, in that it runs each app as its own user; or rather, that is an option. The choice is made for each browser to run as its own user, so Firefox runs as user "firefox". Same for appimage and flatpak apps, and there was a problem with dbus, that was solved awhile back:

https://bkhome.org/news/202304/preventing-proliferation-of-dbus-daemon-instances.html

In the case of Firefox, /usr/bin/firefox is a script, that, amongst other things, logs in as user "firefox", then runs /usr/bin/firefox.bin. Here is the latter:

#!/bin/sh
export $(dbus-launch) #if app needs to access dbus.
/usr/bin/firefox.bin0 $@
kill $DBUS_SESSION_BUS_PID

...the problem with this, and it seems only to break Firefox, Chromium is ok, is that running this a second time, when FF is already running, starts a second 'dbus-daemon'.

The solution is to run 'dbus-daemon' once-only. The script needs to detect if dbus-daemon is already running for that user. If already running, it still needs to export variables DBUS_SESSION_BUS_ADDRESS and DBUS_SESSION_BUS_PID, to satisfy some appimage and/or flatpak apps.

The fixed script is here:

https://github.com/bkauler/woofq/commit/aab112c551ed2b633348d16d096780dbafe798f6

And here:

https://github.com/bkauler/woofq/commit/d4e05f85bf85cc7dca6b518738feb24f581e71bc

Actually, FF is starting to look good again.    

Tags: easy