Bug 439347 - PlasmaPA-VolumeMeter streams are not freeing and consumes CPU all time
Summary: PlasmaPA-VolumeMeter streams are not freeing and consumes CPU all time
Status: RESOLVED FIXED
Alias: None
Product: plasma-pa
Classification: Plasma
Component: applet (show other bugs)
Version: 5.22.2
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: David Rosca
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-30 19:56 UTC by serfreeman1337
Modified: 2021-07-02 14:42 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.22.3


Attachments
Video demonstration (3.49 MB, video/webm)
2021-06-30 19:56 UTC, serfreeman1337
Details

Note You need to log in before you can comment on or make changes to this bug.
Description serfreeman1337 2021-06-30 19:56:39 UTC
Created attachment 139767 [details]
Video demonstration

"Audio Volume" applet creates double stream for volume meters on the first launch, but only frees one. This leads to CPU consumption and can be solved by "pulseaudio -k" command. Video attached.

STEPS TO REPRODUCE
1. Disable "Audio Volume" entry in the System Tray Settings.
2. Logout and Login.
3. Open "PulseAudio Volume Control" and switch to "Recoring" tab.
4. Re-enable "Audio Volume" entry in the System Tray Settings.
5. Open on close "Audio applet".

OBSERVED RESULT
Double stream per device. 

EXPECTED RESULT
One stream per device. 

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Kubuntu 21:04
(available in About System)
KDE Plasma Version: 5.22.2
KDE Frameworks Version: 5.83.0
Qt Version: 5.15.2
Comment 1 David Edmundson 2021-06-30 23:31:19 UTC
I have a couple of observations without any concrete answers.

1) On startup there's a "preloading" path that happens a few seconds after boot, which effectively loads the fullscreen representation of each window.

For some (broken) reason this leads to target

```
VolumeMonitor {
  id: meter
  target: parent.visible ? model.PulseObject : null
}
```

getting set and immediately unset. 
parent.visible should be false throughout preloading, 

2) That doesn't fully explain the end result. It does get unset, our cleanup method does get called and that does unref the stream. That works fine in all future invocations, just not the first one.
Comment 2 Bug Janitor Service 2021-07-02 14:13:22 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-pa/-/merge_requests/73
Comment 3 David Redondo 2021-07-02 14:42:27 UTC
Git commit 5a0d555fa98ebf09bb81aebdd43713b2c9cb922d by David Redondo.
Committed on 02/07/2021 at 14:41.
Pushed by davidre into branch 'master'.

Always disconnect streams

When the stream creation is not finished, disconnecting will fail.
We have to defer disconnecting until the stream is ready.
Setting the callbacks to nullptr was treating a symptom, if the
stream is freed they are also unset.
FIXED-IN:5.22.3

M  +11   -1    src/volumemonitor.cpp

https://invent.kde.org/plasma/plasma-pa/commit/5a0d555fa98ebf09bb81aebdd43713b2c9cb922d
Comment 4 David Redondo 2021-07-02 14:42:55 UTC
Git commit 5644f4e7a4c22432d0c09be00eb56713d06c5c67 by David Redondo.
Committed on 02/07/2021 at 14:42.
Pushed by davidre into branch 'Plasma/5.22'.

Always disconnect streams

When the stream creation is not finished, disconnecting will fail.
We have to defer disconnecting until the stream is ready.
Setting the callbacks to nullptr was treating a symptom, if the
stream is freed they are also unset.
FIXED-IN:5.22.3


(cherry picked from commit 5a0d555fa98ebf09bb81aebdd43713b2c9cb922d)

M  +11   -1    src/volumemonitor.cpp

https://invent.kde.org/plasma/plasma-pa/commit/5644f4e7a4c22432d0c09be00eb56713d06c5c67