Open AdrianGarside opened 11 months ago
Background video preventing PC from sleeping. You already have answered on your question.
Turning it off didn't change the behavior. Edit - retested that and it did actually fix it - just not always immediately.
But given I like to sit with my web dashboard showing I'm still interested if there's a way to have WebRTC never block the machine sleeping. Otherwise I'll have to remember to navigate away every time I leave my PC.
Rendering via WebRTC also adds audio even though the source rstp feed doesn't have that:
[DRIVER] Realtek High Definition Audio (HDAUDIO\FUNC_01&VEN_10EC&DEV_0B00&SUBSYS_1458A0CF&REV_1000\5&307ed9b2&0&0001) An audio stream is currently in use.
Looks like 'media: video' might have helped with that.
If I'm reading the docs right, 'EXECUTION' just means the process won't be suspend - not clear if it blocks sleep.
But audio playback definitely does. With audio disabled the listed blocker changed to: DISPLAY: [PROCESS] \Device\HarddiskVolume3\Program Files (x86)\Microsoft\Edge\Application\msedge.exe Video Wake Lock
'powercfg /requestsoverride PROCESS msedge.exe DISPLAY'
permanently blocks edge from preventing the display turning off/machine sleeping. Which is overkill but given I've had embedded web page ads cause the same problem I'm actually ok with this...
So fingers crossed 'EXECUTION' which seemingly can't be specified successfully as a requestoverride doesn't block display/sleep.
Edit: Spoke too soon - the DISPLAY block on Edge doesn't seem to work. It's still listed as a request and I think that means it's still blocking. Will have to wait until my machine should have turned off it's display to see.
'powercfg /requestsoverride PROCESS msedge.exe DISPLAY EXECUTION' was needed and worked. DISPLAY to allow the screen to turn off. EXECUTION to allow the machine to go to sleep. Possibly this will break some pages that expect to be able to do work while in the background to refresh content though :(
I don't know if the video playback tech in the browser used here lets you turn off the blocks for screen turn off / machine sleep? If not, this is probably the best I can get.
I know it's not the best solution, but MSE mode allows sleep, so I suggest you this configuration:
background: false
muted: true
mode: mse,hls,mjpeg
media: video,audio
I definitely need the background: true. It's the main thing mitigating the fact that Bambu Printer's stream is buggy. Only the first connection is (mostly) reliable. If that drops later the reconnect will almost certainly fail. So by keeping that initial connection permanently live regardless of being viewed it makes the stream mostly reliable. For the most part it now only stops working when I restart my production home assistant instance (which restarts webrtc/go2rtc) - I have to restart the printer after to get a working video stream again.
I just reconfigured to have go2rtc running in it's own docker so that I can restart my home assistant without breaking the video stream. But I haven't been able to work out from the documentation:
However, that permanently blocks my machine sleeping or the screen turning off when I view the dashboard, even if I then navigate away. I have to ctrl-F5 to release the lock:
'powercfg /requests' shows:
EXECUTION: [PROCESS] \Device\HarddiskVolume3\Program Files (x86)\Microsoft\Edge\Application\msedge.exe WebRTC has active PeerConnections
I have background: true set to get the much more responsive display and to mitigate reliability issues with the Bambu Lab X1 RTSP feed but removing that doesn't appear to change the behavior.
Repro: