Thunderbird snap keeps asking to be the default email client

Bug #1903805 reported by Konstantin
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Mozilla Thunderbird
Fix Released
Unknown

Bug Description

Thunderbird snap 78.4.1 2020-11-09 (93)
running on Ubuntu 20.04.1 LTS

The latest version keeps asking at every start whether I want to "Use Thunderbird as the default client". I do. So I keep "Email" and "Always perform this check when starting Thunderbird" checked and click "Set as Default".
When I quit and restart Thunderbird I'm prompted the same question again.

I would expect Thunderbird to set itself as default and no longer ask this question.

Instead, Thunderbird either fails to set itself as default or it asks the question despite being the default (not sure how to distinguish).

Tags: snap
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you for your bug report, indeed that seems similar to https://bugzilla.mozilla.org/show_bug.cgi?id=512305

In fact the thunderbird code seems a copy and mention firefox.desktop but that isn't going to be right
https://sources.debian.org/src/thunderbird/1:78.4.1-1/browser/components/shell/nsGNOMEShellService.cpp/?hl=205#L205

Changed in thunderbird (Ubuntu):
importance: Undecided → High
status: New → Confirmed
tags: added: snap
Revision history for this message
In , Sebastien Bacher (seb128) wrote :

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:83.0) Gecko/20100101 Firefox/83.0

Steps to reproduce:

The bug was reported against the snap on https://bugs.launchpad.net/ubuntu/+source/thunderbird/+bug/1903805
' Thunderbird snap keeps asking to be the default email client '

The issue is similar to firefox bug 512305 , the approach for writing to ~/.local/share/applications directly isn't going to work for confined applications

Actual results:

Thunderbird changes the default mimetype association in its private snap directory

Expected results:

The default is changed in the real user directory. Calling xdg-settings is proxyed to snapd and leads to the correct result

Revision history for this message
In , Sebastien Bacher (seb128) wrote :

Created attachment 9191065
thunderbird-xdg-settings.patch

The attached patch is similar to what firefox has been doing in https://hg.mozilla.org/releases/mozilla-release/rev/74e95f9fb43e (the snap env detection has been updated to be similar to what firefox is currently doing which is a bit different from what first landed)

Revision history for this message
In , Rob Lemley (rjl-tbird) wrote :

It looks reasonable enough and applied cleanly to current Daily code. I started up a try (Daily version) build with it applied. Any chance of getting a proper patch with the a checkin comment and author information included?

Try build: https://treeherder.mozilla.org/jobs?repo=try-comm-central&selectedTaskRun=FlDpf85IR6C3AvUa4Cl4UQ.0&revision=8c6b6907e248c88ad5f0bcb3001d5d6c882a2d0c

Revision history for this message
In , Sebastien Bacher (seb128) wrote :

Thanks for the review, I'll update the patch in the next days as requested, I just need to figure out the proper mercurial workflow

Revision history for this message
In , Mkmelin+mozilla (mkmelin+mozilla) wrote :

Please see https://developer.thunderbird.net/thunderbird-development/fixing-a-bug

For patches, it's what `hg export` gives you, not `hg diff` (and do set your name/addr up in hg)

Revision history for this message
In , Sebastien Bacher (seb128) wrote :

Created attachment 9192263
Use xdg-settings in the snap to set default

Thanks for the pointer, I had read that documentation but got lost in the queues details. I've screwed my checkout but I'm adding one with the author/description at least, if that's not enough to commit let me know and I will try to do again a proper checkout to have the right commit id reference

Revision history for this message
In , Rob Lemley (rjl-tbird) wrote :

I built a Snap package with this applied (Thunderbird Daily) and it didn't work. I'll try applying it to 78.6 tomorrow and see if it fares better. (Using Ubuntu's snap sources and a build I ran on try-c-c.)

xdg-settings reports that Thunderbird is the default mail client, but I keep getting the popup when I start it. I checked for the SNAP_NAME environment variable on the process and it is set to "thunderbird".

Test system is Ubuntu LTS (20.04.1).

Revision history for this message
In , Mkmelin+mozilla (mkmelin+mozilla) wrote :

Comment on attachment 9192263
Use xdg-settings in the snap to set default

Review of attachment 9192263:
-----------------------------------------------------------------

::: mail/components/shell/nsGNOMEShellService.cpp
@@ +241,5 @@
> + }
> + if (strcmp(output, "thunderbird.desktop\n") == 0) {
> + g_free(output);
> + return true;
> + }

This part doesn't seem to follow what firefox currently has..?

Revision history for this message
In , Sebastien Bacher (seb128) wrote :

(In reply to Magnus Melin [:mkmelin] from comment #7)
> Comment on attachment 9192263
> Use xdg-settings in the snap to set default
>
> Review of attachment 9192263:
> -----------------------------------------------------------------
>
> ::: mail/components/shell/nsGNOMEShellService.cpp
> @@ +241,5 @@
> > + }
> > + if (strcmp(output, "thunderbird.desktop\n") == 0) {
> > + g_free(output);
> > + return true;
> > + }
>
> This part doesn't seem to follow what firefox currently has..?

That's because firefox uses
{"xdg-settings", "check", "default-web-browser",
                           "firefox.desktop", nullptr};

there is no equivalent for other protocols so the thunderbird patch was written using
{"xdg-settings", "get", "default-url-scheme-handler",
                             aProtocols[i], nullptr};

the firefox command returns a yes/no answer to the question "is firefox.desktop the default web browser", where the thunderbird one returns a string answer to the question "what .desktop is the default for the url scheme"

Revision history for this message
In , Sebastien Bacher (seb128) wrote :

(In reply to Rob Lemley [:rjl] from comment #6)
> I built a Snap package with this applied (Thunderbird Daily) and it didn't work. I'll try applying it to 78.6 tomorrow and see if it fares better. (Using Ubuntu's snap sources and a build I ran on try-c-c.)
>
> xdg-settings reports that Thunderbird is the default mail client, but I keep getting the popup when I start it. I checked for the SNAP_NAME environment variable on the process and it is set to "thunderbird".
>
> Test system is Ubuntu LTS (20.04.1).

Thanks Rob, how did you build the snap? The current snap in the store is using the upstream binary builds and not building from source.

I didn't have a chance to test in a real snap environment but I did check using 'SNAP_NAME=thunderbird thunderbird' non confined with a local build, there might be a difference in behaviour. Also under what desktop environment did you try?

Checking a bit manually in the thunderbird snap env though there seems to be an issue with the snapd wrapper and subcommands so that might need to be resolved first for the patch to work correctly.

Revision history for this message
In , Rob Lemley (rjl-tbird) wrote :

The build was done on our try server, so configuration wise, it's the same as the release builds.

The Snap I built on an Ubuntu 20.04.1 VM. The snapcraft.yaml and such I just downloaded from Launchpad. I replaced the download URL with the tar file from try (and removed the langpacks) and built. I did wind up using LXC instead of Multipass. The only other difference would be the version; this was Thunderbird 85.0a1 instead of 78.x.
The test environment was the same VM using GNOME desktop. New VM, nothing changed other than apt install-ing the latest updates.

I did the same with 78.6.0-pre + this patch to see if that made a difference; same result.

Revision history for this message
In , Sebastien Bacher (seb128) wrote :

Thanks Rob for the details!

Is the download URL you used public or could you share your .snap? It would make easier for me to test the end result as well in a real configuration.

I believe the patch isn't going to work correctly until the snapd xdg-settings wrapper gets a fix for not handling subcommand arguments correctly. I'm going to work on a patch for that and will comment here once it's up, ideally I would like to test things together with the fixed snapd and a patch thunderbird snap to ensure things indeed work correctly.

Revision history for this message
In , Rob Lemley (rjl-tbird) wrote :

Created attachment 9192675
snapcraft.yaml

Here's the link to the build in Treeherder: https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=8defd41a707df3ae6eb2ab6deaa25cdadf253cb1

And the actual tar file: https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/fXLwVrFfSPGdrnboBE9JaA/runs/0/artifacts/public/build/target.tar.bz2
(You find that by clicking on "B" next to Linux x64 opt, then in the pane that pops up click "Artifacts" and within that you'll find the link to "target.tar.bz2". The debug build is there as wel if it's helpful.)

I've attached my modified snapcraft.yaml file. Everything else was the same as in Launchpad.

Revision history for this message
In , Sebastien Bacher (seb128) wrote :

@Rob, Thanks for the details that should help me testing.

I've reported the snapd issue now with a patch,
https://github.com/snapcore/core18/pull/175

The change is going to be needed for xdg-settings to do the right thing and the thunderbird patch to be functional

Revision history for this message
In , Rob Lemley (rjl-tbird) wrote :

I see the patch to snapd in comment 13 was merged, so I updated the test VM I have with latest/candidate and confirmed that the test Snap I built and tested in comment 10, there is no longer a prompt to set the default mail client.

Revision history for this message
In , Rob Lemley (rjl-tbird) wrote :

Comment on attachment 9192263
Use xdg-settings in the snap to set default

Tested locally on a snap built with this patch and an updated snapd with fixes (esr78). Let's get this landed into comm-central, and I'll request uplift to beta and then to esr78.

Revision history for this message
In , Pulsebot (pulsebot) wrote :

Pushed by <email address hidden>:
https://hg.mozilla.org/comm-central/rev/5fb1b586974d
set the default handler in the snap using xdg-settings. r=rjl

Revision history for this message
In , Rob Lemley (rjl-tbird) wrote :

Comment on attachment 9192263
Use xdg-settings in the snap to set default

[Approval Request Comment]
Regression caused by (bug #):
User impact if declined: Users that use Canonical's Thunderbird Snap package get a popup asking to make Thunderbird the default mail client even if it already is
Testing completed (on c-c, etc.): This fix was originally tested by myself on c-esr78, details are described above. The code itself is based on what Firefox has had for some time to set the default browser when running as a Snap. The basic structure of the change has been battle tested, even if this specific implementation has not. Testing does require that our Thunderbird builds get turned into a Snap package, so I plan to verify nightly and beta pretty quickly.
Risk to taking this patch (and alternatives if risky):
It's possible that this could break default mail client settings for non-snap users, but as noted above this has been on Firefox for some time.

Assuming there are no regressions on nightly, I'd like to fast track this and get it in to 78.6.1 since the fix is specific to the Snap build that Canonical does and they only build for release versions.

Revision history for this message
In , Vseerror (vseerror) wrote :

Comment on attachment 9192263
Use xdg-settings in the snap to set default

[Triage Comment]
Approved for beta

Revision history for this message
In , Rob Lemley (rjl-tbird) wrote :
Revision history for this message
In , Vseerror (vseerror) wrote :

Comment on attachment 9192263
Use xdg-settings in the snap to set default

[Triage Comment]
Approved for esr78

Revision history for this message
In , Rob Lemley (rjl-tbird) wrote :
Revision history for this message
In , Sebastien Bacher (seb128) wrote :

Thanks, I've tested using thunderbord 78.6.1 and the core18 snap from the candidate channel and clicking 'set default' correctly trigger the portal prompt and success in setting the default

Changed in thunderbird (Ubuntu):
status: Confirmed → Fix Committed
Revision history for this message
Sebastien Bacher (seb128) wrote :

The issue is fixed now in thunderbird 78.6.1 (but it requires the core18 snap from the candidate channel)

Changed in thunderbird:
status: Unknown → Fix Released
Mathew Hodson (mhodson)
no longer affects: thunderbird (Ubuntu)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.