Open Bug 1665986 Opened 5 years ago Updated 2 days ago

playing background audio doesn't request wakelock on linux

Categories

(Core :: Audio/Video: Playback, defect, P3)

defect

Tracking

()

People

(Reporter: alwu, Unassigned, NeedInfo)

References

(Blocks 1 open bug)

Details

When playing audio on background, the wakelock state is locked-background. However, on linux, we didn't request wakelock for locked-background [1].

Therefore, on linux we didn't prevent computer from sleeping when playing audio from background tab.

[1] https://searchfox.org/mozilla-central/rev/d410917833190ee08a62b38f8f9de65cea1e661b/widget/gtk/WakeLockListener.cpp#491-497

+1 on:
mozilla-flatpak - 1.0
129.0 (64bit)

KDE Plasma 6.1.3 - Framework 6.4.0 - Qt 6.7.2
Fedora 40

Flags: needinfo?(stransky)

Alastor, so do you suggest to add locked-background to wakelock? Do I understand correctly that we want to dim screen but prevent power management to turn computer to sleep, right?

(In reply to Martin Stránský [:stransky] (ni? me) (PTO, back on Feb 17) from comment #2)

Alastor, so do you suggest to add locked-background to wakelock? Do I understand correctly that we want to dim screen but prevent power management to turn computer to sleep, right?

Hello Martin,

Found this issue because I see the exact same behaviour (Firefox on Manjaro Linux). I don't know anything about this "wakelock" thing, but basically the behaviour you describe is the wanted one indeed: listening to an audio stream should prevent the computer to go to sleep. Not sure about dimming the screen, as someone watching a video stream surely would prefer their screen not to get dimmed.

Cheers,

--
Aurélien

I can confirm the same behaviour with Firefox, I believe this bug has existed since around 2018 when there was a re-write of the wake lock system and the audio part for Linux was accidentally omitted.

I have tried other browsers and the only one to implement this correctly that I can see is Google Chrome & Chromium, MS Edge doesn't work from the Flatpak Repo, neither does Opera or Brave this. Edge does work if you use the .deb from Microsoft.

Martin, the behaviours that you listed I.E when playing audio only, the screen should be allowed to dim/sleep/lock etc, yes, but the PC should not go to sleep.

In KDE Plasma 6 (Fedora 41) this is what the wake-locks look like when running:
busctl --user call org.kde.Solid.PowerManagement.PolicyAgent /org/kde/Solid/PowerManagement/PolicyAgent org.kde.Solid.PowerManagement.PolicyAgent ListInhibitions

Chrome
Playing Video
a(ss) 3 "/usr/bin/google-chrome-stable" "Video Wake Lock" "/usr/bin/google-chrome-stable" "Playing audio" "/usr/bin/google-chrome-stable" "Video Wake Lock"
Playing Audio
a(ss) 1 "/usr/bin/google-chrome-stable" "Playing audio"

Firefox
Playing Video
a(ss) 1 "org.mozilla.firefox" "video-playing"
Playing Audio
a(ss) 0

Is there any chance of getting this fixed? It's been a problem for 5 years! I've taken ago at fixing it myself, but not being a developer I've had very limited success. I'm currently using 2 browsers because of this bug :( I know it probably affects 5 people on the whole planet but it's the only thing preventing me using Firefox on all my devices. I'm happy to attempt to fix it with some guidance?

Hello,

I have a simple fix for this, but it implements the same logic for audio as video, which isn't quite what you'd want. However, not being experience in C++ and having to learn as I go, I don't see how the current code will allow for it. Can someone with a little more C++ knowledge take a look over the WakeLockListener.cpp file and see if you think that the logic for both inhibiting sleep and screen saver is there? From looking at the logs and code I can see that the wakelock type is being set to "FreeDesktopScreensaver" but I can't see how it has decided that is the correct wakelock to use or how to code around it. Any help would be awesome!

You need to log in before you can comment on or make changes to this bug.