Open Bug 1874529 Opened 2 years ago Updated 1 years ago

Windows Display Blanking Stops Firefox Playing Audio

Categories

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

Firefox 121
defect

Tracking

()

UNCONFIRMED

People

(Reporter: helpfulhacker, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0

Steps to reproduce:

  1. Set Windows to turn off screen after 1 minute
  2. Connect PC by an hdmi cable to a TV with a soundbar/receiver
  3. Play an audio mp3 file or a spotify podcast (then don't touch kbd/mouse)
  4. When Windows turns off the display the audio stops (can't be heard)

Actual results:

Audio became silent when the screen blanked.

Two TV's exhibit this issue with Win10&Win11. One has a soundbar connected to the TV's digital optical audio out. The other has a receiver connected to the TV's eARC hdmi port.

In both cases when the screen goes black, the sound stops.

Expected results:

The screen should stay on so audio can keep playing (if so configured).

Firefox does not make a DISPLAY power request when playing audio only. This makes sense only if the sound isn't produced by or dependent on the the display.

The current "Media Player" from Microsoft Store (not the old Windows Media Player") does make a DISPLAY power request seen with "powercfg /requests" when playing an audio file.

Idea:
Have a setting or at least an about:config boolean "Keep display on when playing audio". If true, firefox does a DISPLAY power request while playing audio (like Media Player).

The Bugbug bot thinks this bug should belong to the 'Core::Widget: Win32' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Widget: Win32
Product: Firefox → Core

On the same PC I tested Ubuntu 23.10 which provides firefox 121.0 (64-bit). Same bug. If I set ubuntu to screen blank after 1 minute I can watch any length youtube video and it will blank 1 minute after the video ends.

If I listen to spotify it will blank 1 minute into the audio and become silent. Moving the mouse will show the lock screen and bring back audio for 1 minute.

Note:
ubuntu is configured to use Xorg instead of wayland in case that matters.

Conclusion:
Sorry Bugbug bot, the same behavior happens on linux so it's not Windows specific. Whatever firefox does on linux to keep the display on during videos should also optionally be done when playing audio only (if so configured).

Sorry Bugbug bot, the same behavior happens on linux so it's not Windows specific.

Noted! Recategorizing accordingly.

Component: Widget: Win32 → Audio/Video: Playback

Attached a zipped powershell script that works around this problem. It polls power requests and when it finds a firefox non-display request it makes a display power request. When firefox removes its non-display request the script removes its display power request.

I run this as a high privilege scheduled task.

powershell.exe -WindowStyle Hidden -executionpolicy remotesigned -File C:\MyPath\audioawake.ps1

When the script sees this:
[PROCESS] \Device\HarddiskVolume3\Program Files\Mozilla Firefox\firefox.exe
non-display request

Within a minute you should see this:
DISPLAY:
[PROCESS] \Device\HarddiskVolume3\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

It's a hack but better than having the audio cut out.

Blocks: media-triage
Flags: needinfo?(alwu)

Hello, would you mind to follow this instruction to help us capture debug log? But int step2, please fill MediaControl:5,WinWakeLock:5 into New Log Modules and click Set Log Module.

Then you can go to reproduce the issue. After the issue is reproduced, keep following step5 to upload the profiled result.

(In reply to sinbad_4273 from comment #2)

On the same PC I tested Ubuntu 23.10 which provides firefox 121.0 (64-bit). Same bug. If I set ubuntu to screen blank after 1 minute I can watch any length youtube video and it will blank 1 minute after the video ends.

If I listen to spotify it will blank 1 minute into the audio and become silent. Moving the mouse will show the lock screen and bring back audio for 1 minute.

In this case, only one screen is in use, right? So what you said is that the audio would be paused when the screen enters sleep mode? Could you try to disable the preference media.hardwaremediakeys.enabled to see if it helps? Maybe your Linux system incorrectly sends pause event to Firefox when the screen enters the sleep mode.

Thanks!

Flags: needinfo?(alwu) → needinfo?(sinbad_4273)
No longer blocks: media-triage

I never said "pause". FF is not pausing. FF isn't keeping the hdmi display on while playing audio only.

New test:

  • I set Windows Screen to turn off after 1 min
  • I played an mp3 audio file in FF
  • After 1 min the player said 1 min and the screen blanked and audio became silent
  • Waited one min in silence with screen black
  • Moved the mouse and the image & sound returned
  • player said 2 min and counting (give or take 1-2 seconds for TV to power back on)

Play an audio file in on Windows and FF makes an EXECUTION power request so the PC stays powered on and FF silently plays audio to a TV that's no longer on.
DISPLAY:
None.

EXECUTION:
[PROCESS] \Device\HarddiskVolume3\Program Files\Mozilla Firefox\firefox.exe
non-display request

Play an audio file in "Media Player" and it does a DISPLAY power request and the display with audio stays on
DISPLAY:
[PROCESS] \Device\HarddiskVolume3\Program Files\WindowsApps\Microsoft.ZuneMusic_11.2310.8.0_x64__8wekyb3d8bbwe\Microsoft.Media.Player.exe
Windows Runtime Package: Microsoft.ZuneMusic_8wekyb3d8bbwe

There is no linux drive connected to this PC so testing on linux is much more work.

Steps to reproduce on Windows:

  • Play an mp3 audio file
  • powercfg /requests (requires admin command prompt)

Result: There is no DISPLAY power request keeping the display on and playing audio. Any setup where audio depends on the DISPLAY being powered on will fail when the screen blanks.

Flags: needinfo?(sinbad_4273)

Both TV's exhibiting the problem use hdmi for audio + video (one ATI one nvidia graphics).

Tried a Windows 10 Pro PC (intel on-board graphics) connected by DisplayPort to an ASUS VP278QGL monitor with built-in speakers. An audio cable from the motherboard's audio out to the asus monitor's audio-in port. When FF is playing an audio file and Windows turns off the screen, audio stops.

This is to be expected for any setup where audio is dependent on the the TV/monitor being powered on.

That is why "Windows Media" does a DISPLAY power request when playing audio and FF needs to have an option to do that too.

Setting media.hardwaremediakeys.enabled to false made no difference on Windows. Should I try linux?

Note that on a laptop, "Windows Media" player does not make a DISPLAY power request when playing audio only as it probably knows the built-in laptop speakers don't need screen power to function. Users would complain if the screen refused to blank for no good reason while playing audio. Having an about:config setting allowing user configuration is a safer/simpler solution than auto-detection.

Severity: -- → S3

For Windows the problem is in nsAppShell.cpp in the line shown below:

const bool isNonDisplayLock = aTopic.EqualsASCII("audio-playing");

If audio is playing, it is assumed that we always need a non display power lock. This assumption is false whenever the display is itself producing the audio or feeding the audio signal to the audio device.

I haven't looked at the code on linux but it is likely making the same false assumption about display wake locks for audio.

The user needs a way to configure/tweak this behavior.

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

Attachment

General

Created:
Updated:
Size: