Bug 465393

Summary: mute icon on task bar appears on wrong applications
Product: [Plasma] plasmashell Reporter: Alexis Murzeau <amubtdx>
Component: Task Manager and Icons-Only Task Manager widgetsAssignee: Plasma Bugs List <plasma-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: nate, qydwhotmail
Priority: NOR    
Version First Reported In: 5.26.90   
Target Milestone: 1.0   
Platform: Debian unstable   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 5.27
Sentry Crash Report:
Attachments: plasma-desktop-5.26.5_no_duplicate_icons.png
plasma-desktop-5.26.90_duplicate_icons.png

Description Alexis Murzeau 2023-02-06 22:13:40 UTC
SUMMARY


STEPS TO REPRODUCE
1. Install plasma-desktop 5.26.90
2. Open an application that plays audio and other applications to fill up the task bar with several applications


OBSERVED RESULT

The mute icon appears on unrelated applications and/or pinned applications.
See screenshots in attachment.

EXPECTED RESULT

The mute icon should appear only on applications that plays audio (as it was in 5.26.5)

SOFTWARE/OS VERSIONS
Operating System: Debian GNU/Linux 
KDE Plasma Version: 5.26.90
KDE Frameworks Version: 5.102.0
Qt Version: 5.15.8
Kernel Version: 6.1.0-3-amd64 (64-bit)
Graphics Platform: X11
Processors: 12 × AMD Ryzen 5 3600 6-Core Processor
Memory: 15.6 Gio of RAM
Graphics Processor: AMD Radeon RX 580 Series
Manufacturer: Micro-Star International Co., Ltd
Product Name: MS-7B86
System Version: 4.0

ADDITIONAL INFORMATION

I've tried to downgrade only plasma-desktop to 5.26.5 and the issue doesn't appear anymore. So it was introduced in plasma-desktop, between 5.26.5 and 5.26.90.
Comment 1 Alexis Murzeau 2023-02-06 22:14:57 UTC
Created attachment 156011 [details]
plasma-desktop-5.26.5_no_duplicate_icons.png
Comment 2 Alexis Murzeau 2023-02-06 22:20:46 UTC
Created attachment 156012 [details]
plasma-desktop-5.26.90_duplicate_icons.png

I've added 2 screenshots. The difference between the two are:
- Opened some applications including Spotify, foobar2000 and gitk
- Spotify is the only application playing music
- Upgraded plasma-desktop from 5.26.5 to 5.26.90
- Run `plasmashell --replace` in a terminal

The first icon is a non-running, pinned, application.

When clicking on one of the mute buttons, Spotify is muted and all mute buttons become "unmute" buttons (their icon changed).

I'm using pulseaudio and jackd only (no pipewire).
Comment 3 Alexis Murzeau 2023-02-06 22:41:39 UTC
I found that the issue is related to this line of code:
https://invent.kde.org/plasma/plasma-desktop/-/blob/1988f0756ec9b61d6eff6eae14c1023502d7f701/applets/taskmanager/package/contents/ui/Task.qml#L233

var streams = pa.streamsForAppId(task.appId);

Some applications like the first pinned application icon, foobar2000 and gitk in the screenshots don't have a task.appId (using console.log() I found that the string was empty).
I guess that when appId is an empty string, pa.streamsForAppId will return all streams, that would explain why it shows a mute icon on them.

Adding a if(task.appId) around that line of code fixes the issue:
--- /usr/share/plasma/plasmoids/org.kde.plasma.taskmanager/contents/ui/Task.qml.bak     2023-01-19 12:40:03.000000000 +0100
+++ /usr/share/plasma/plasmoids/org.kde.plasma.taskmanager/contents/ui/Task.qml 2023-02-06 23:41:02.020817778 +0100
@@ -230,7 +230,10 @@
 
         // Check appid first for app using portal
         // https://docs.pipewire.org/page_portal.html
-        var streams = pa.streamsForAppId(task.appId);
+        var streams = [];
+        if(task.appId) {
+            pa.streamsForAppId(task.appId);
+        }
         if (!streams.length) {
             streams = pa.streamsForPid(task.pid);
             if (streams.length) {
Comment 4 Fushan Wen 2023-02-07 05:00:33 UTC
appId shouldn't be empty. If it's empty there is a bug in libtaskmanager.
Comment 5 Alexis Murzeau 2023-02-07 19:08:41 UTC
I've tried the linked commit (c27fb3c0d25a0ad7af44acd1d9e957cdaae8802e) on plasma-workspace and confirm that this fixes the issue.
Thanks :)