Bug 455069

Summary: Firefox from FlatHub and distro packaging are not identified by the Task Manager as being the same application
Product: [Plasma] plasmashell Reporter: Hari Rana (TheEvilSkeleton) <theevilskeleton>
Component: generalAssignee: Plasma Bugs List <plasma-bugs-null>
Status: RESOLVED DOWNSTREAM    
Severity: normal CC: kde, nate, niccolo.venerandi
Priority: NOR    
Version First Reported In: 5.24.5   
Target Milestone: 1.0   
Platform: Flatpak   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Firefox Flatpak instance as a new icon
Video of the bug in action

Description Hari Rana (TheEvilSkeleton) 2022-06-09 05:11:45 UTC
Created attachment 149573 [details]
Firefox Flatpak instance as a new icon

SUMMARY
Application icon duplicates in panel when launching a Flatpak application while distribution package equivalent is also installed.

For example, if I have the Firefox flatpak (`org.mozilla.firefox` on Flathub), and `firefox` from the Arch Linux repositories, the problem occurs.

STEPS TO REPRODUCE
1. Install an application as a Flatpak (`org,mozilla.firefox` on Flathub for example) and its distribution package equivalent (`firefox` in Arch repositories for example)
2. Pin the Firefox Flatpak to task manager
3. Launch the Flatpak application from the task manager

OBSERVED RESULT
Firefox appears separately as an instance, with a duplicate icon.

EXPECTED RESULT
Plasma should reuse the Firefox icon from the task manager.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux (VM using GNOME Boxes)
(available in About System)
KDE Plasma Version: 5.24.5
KDE Frameworks Version: 5.94.0
Qt Version: 5.15.4

ADDITIONAL INFORMATION
I assume that Plasma thinks that it is running Firefox from the distribution repository instead. When I pin the duplicate icon to task manager, close Firefox and open the newly pinned icon, it launches Firefox from the distribution repository.
Comment 1 Nate Graham 2022-06-09 17:12:30 UTC
It can only do this when the apps can be identified as identical because they share an AppStream ID. I suspect that your two installed Firefox apps do not.

If you run `appstreamcli search firefox`, I suspect you will see something like this at the top:

Identifier: org.mozilla.firefox [desktop-application]
Name: Firefox
Summary: Fast, Private & Safe Web Browser
Bundle: flatpak:app/org.mozilla.firefox/x86_64/stable
Homepage: https://www.mozilla.org/firefox/
Icon: org.mozilla.firefox.png
---
Identifier: firefox.desktop [desktop-application]
Name: Firefox
Summary: Web Browser
Package: firefox
Homepage: https://www.mozilla.org
Icon: firefox.png

[output from my distro, Fedora 36]

That's what I'm talking about: one has the identifier "org.mozilla.firefox" and the other is "firefox.desktop". Because these are different, Plasma can't identify them as the same thing. This is a packaging issue that isn't KDE's fault, but it's not really fixable by either the FlatHub packagers (they intentionally used a different ID because their policies require a reverse-dns style) or Firefox (if they change the ID to match FlatHub's divergence from their upstream preferences, they'll be breaking compatibility with everything else).

This means the only way we can solve the issue is by adding a local workaround for the Task Manager. Fortunately a mechanism for this exists.
Comment 2 Hari Rana (TheEvilSkeleton) 2022-06-09 18:19:38 UTC
Created attachment 149583 [details]
Video of the bug in action

The icon I pinned to the Task Manager is the desktop entry for the Firefox Flatpak.
Comment 3 Hari Rana (TheEvilSkeleton) 2022-06-09 18:22:57 UTC
(In reply to Nate Graham from comment #1)
> It can only do this when the apps can be identified as identical because
> they share an AppStream ID. I suspect that your two installed Firefox apps
> do not.
> 
> If you run `appstreamcli search firefox`, I suspect you will see something
> like this at the top:
> 
> Identifier: org.mozilla.firefox [desktop-application]
> Name: Firefox
> Summary: Fast, Private & Safe Web Browser
> Bundle: flatpak:app/org.mozilla.firefox/x86_64/stable
> Homepage: https://www.mozilla.org/firefox/
> Icon: org.mozilla.firefox.png
> ---
> Identifier: firefox.desktop [desktop-application]
> Name: Firefox
> Summary: Web Browser
> Package: firefox
> Homepage: https://www.mozilla.org
> Icon: firefox.png
> 
> [output from my distro, Fedora 36]
> 
> That's what I'm talking about: one has the identifier "org.mozilla.firefox"
> and the other is "firefox.desktop". Because these are different, Plasma
> can't identify them as the same thing. This is a packaging issue that isn't
> KDE's fault, but it's not really fixable by either the FlatHub packagers
> (they intentionally used a different ID because their policies require a
> reverse-dns style) or Firefox (if they change the ID to match FlatHub's
> divergence from their upstream preferences, they'll be breaking
> compatibility with everything else).
> 
> This means the only way we can solve the issue is by adding a local
> workaround for the Task Manager. Fortunately a mechanism for this exists.

Thanks for the detailed explanation!

That's a bit odd. I was unable to reproduce it on Cinnamon or GNOME.

I just want to make sure that we are in the same page and not misunderstanding each other. I recorded a video and posted it here. Perhaps this could help understand better?
Comment 4 Nate Graham 2022-06-09 18:52:23 UTC
I guess they programmed their things differently to match on something else, or else they already added workarounds.

Can you search for "firefox" in Kickoff and confirm that you see two items, not one? Also, can you confirm that no matter which one you click on, the Flatpak version is launched?
Comment 5 Hari Rana (TheEvilSkeleton) 2022-06-09 19:24:35 UTC
(In reply to Nate Graham from comment #4)
> I guess they programmed their things differently to match on something else,
> or else they already added workarounds.
> 
> Can you search for "firefox" in Kickoff and confirm that you see two items,
> not one?

Yes, I can confirm. One is Firefox Flatpak, and the other one is Firefox from the Arch repos.

> Also, can you confirm that no matter which one you click on, the
> Flatpak version is launched?

When I click on the Firefox Flatpak entry, then Firefox Flatpak launches. Likewise, when I click on Firefox from the Arch repos, then Firefox from the Arch repos launches.
Comment 6 Nate Graham 2022-06-10 15:43:25 UTC
Thanks.

So we have a tricky problem, because the system is unable to de-duplicate the two Firefoxes and understand that they are the same app. Even if we put in a workaround for the Task Manager, it'll still show up twice in other places too.

I am unsure whether there is anything we can do about this in KDE. The ideal solution would be for the two packagers of Firefox to collaborate and work upstream to harmonize their packaging. I have my doubt that they will or even can though.

It's a long shot, but I would recommend that you ask the Firefox people to change Firefox's AppStream ID in their Linux packaging to match the one that the FlatHub people chose for Firefox when they packaged it for FlatHub. That's ultimately the best solution here that would fix all these problems. If they say no, then we're kind of stuck.