Linux: Mailspring fails to activate already-running instances

Description

The Mailspring “single instance” code on Linux is very unreliable. Launching Mailspring will sometimes bring up the existing instance (as intended). Other times, usually after a long wait (it seems), it will instead start a new instance, upon which further calls to the “mailspring” command will bring up that new instance, while the old one also runs in the background simultaneously. After enough time passes, even the new instance will be “forgotten” and the “mailspring” command will spawn yet another instance.

Screenshots

The first instance was the auto-started one at system startup. The second was created when I attempted to launch the Mailspring app.

To Reproduce…

Steps to reproduce the behavior:

  1. Install Fedora Workstation 36. You can use a virtual machine, I guess.
  2. Install the AppIndicators GNOME extension, so that you can see Mailspring’s tray icon.
  3. Install Mailspring from the native RPM installer on your website.
  4. Set Mailspring as GNOME’s default mail client.
  5. Bind the GNOME Settings: Keyboard: Launchers: Launch email client to a key, such as Super+E.
  6. Reboot the computer and let Mailspring launch at startup.
  7. Wait and just do other stuff for a few hours (I really don’t know how long it takes). Don’t open mailspring.
  8. When you finally press Super+E to launch your email client, it will open a new instance of Mailspring instead of activating the existing one. Closing the new instance and running the command again will yet again spawn a new instance. Same thing if you manually run “mailspring” command in a terminal.
  9. If you try to run further instances of Mailspring when the NEW one has spawned, that one will continue getting focus as intended, but if you wait long enough, even that one will be “forgotten” and extra/new instances will spawn instead.
  10. This issue never happens when a Mailspring instance is “fresh”. A fresh instance will always activate itself properly. But given some time, every new instance is forgotten in the end, and the duplicate issue appears.

Expected Behavior

More robust handling of multiple instances is needed.

I suspect that you had to do something sneaky since you’ve also got a Snap version (which I am not installing, it doesn’t belong outside Ubuntu and even there it’s an abomination). So you are probably using a method of checking instances which works inside containers such as Snap/Flatpak.

I am not sure, but I THINK the proper way to handle this is to register a dbus singleton instance of Mailspring, and then make the mailspring binary’s startup process attempt to “activate existing instance by sending it a message”, and if THAT fails THEN start a new instance of Mailspring, or QUIT if the existing instance responded.

I even suspect that you may be doing something like that already, but perhaps the dbus registration is being forgotten after a while.

Setup

  • OS and Version: Fedora Workstation 36, fully updated as of this writing
    • Installation Method: .rpm
  • Mailspring Version: 1.10.3-a476c230

I am also curious: Is there risk of database corruption when two instances run simultaneously like this? I get very worried about it.

I would add as well, this is currently breaking protocol handling. With a background instance (as per defaults), the newly launched copy that gets the URL just dies and never passes its URL to the running instance. So, the “activate existing instance” code needs to also pass arguments/URLs to the running instance.

1 Like

I stopped using the “launch email” keyboard shortcut due to this bug. Has anyone noticed if the bug still exists?

:frowning: These forums are dead. GitHub Issues was better.

1 Like

+1 on this issue. Unlike any other app I have to tippy toe around how I launch this one by only reopening a running instance through the app panel indicator. I can’t even click on a email link to write an email without it opening a new instance.

I still see this issue. I’m using Ubuntu 22.04, which already comes with the AppIndicators extension by default. I installed Mailspring from the official .deb.
This only happens after a good amount of time has passed between opening Mailspring and experiencing this bug.

For me, an easier way to reproduce this issue is just clicking on any mailto link on a website. Mailspring will take a long time to think and eventually open a second instance. Anything that requires your OS to open a mail client, either to send an email or whatever other task, will open a second instance.

It’s going to be almost two years since this was originally reported but we still see this issue.

1 Like

Thunderbird has finally gained a modern “Cards”-based interface with airy spacing in the user interface, so I am switching back to it today after almost 15 years without Thunderbird.

The screenshots on Flathub are outdated. I highly recommend anyone to try it out to see the latest design (with Dark theme and modern cards). Their official, recommended install method is Flathub:

Beware if you had Thunderbird previously installed. If so, it will be in “migrate mode” where parts or all of the UI is still using the old styles and old layout. You can manually switch over to Cards view and new layouts and compactness settings, but it takes a lot of effort to find all the settings that you’d need to switch (some of the settings are even hidden in the advanced Config Editor). So I recommend that you just wipe your old Thunderbird config and let it create a fresh one with the latest, modern layout.

It’s stunning nowadays. And the plugin ecosystem is fantastic. I can finally begin using mail aliases again, with the “automatically reply as alias” plugin:

With that plugin, I can receive emails at “anything-i-want @ mydomain”, which is configured to be forwarded to my true mailbox. So someone may email me at “someproject @ mydomain”. Then, when I reply to that email, that plugin makes my outgoing email send from the “someproject @ mydomain”, thus protecting my real inbox from spam. If I get spam, I simply disable a project alias and switch that site to another. It’s a system I used back in 2010 and I am so excited to finally have an enjoyable version of Thunderbird so I can get back to that safety.

I will miss the Mailspring interface for sure. It was a joy to use and still looks more beautiful than Thunderbird. But the gap is much smaller now, and I really can’t resist the huge plugin repository at Thunderbird anymore.

The only thing that bothered me about Thunderbird was the default zoom level, since I use a very large screen that needs 125% zoom in most apps. But luckily that can be set via Config Editor with the hidden setting “layout.css.devPixelsPerPx”, which scales both the text and all images (so it’s superior compared to just changing font size). I set it to 1.25 (which means 125%) and now the UI is perfectly enjoyable!

I hope this information helps someone else!

1 Like