Page 1 of 1

Possibly a bug - maybe it's by design?

Posted: Thu Jan 15, 2026 4:24 am
by escape75
Consider the following code,- it seems to prevent Windows from going to sleep:

Code: Select all


EnableExplicit

Enumeration 100
  #Window
  #WebView
EndEnumeration

OpenWindow(#Window, 100, 100, 400, 200, "Test", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
WebViewGadget(#WebView, 0, 0, 400, 200)
SetGadgetItemText(#WebView, #PB_WebView_HtmlCode, ~"<script>ctx = new AudioContext(); osc = ctx.createOscillator(); osc.type = 'sine'; osc.frequency.value = 1; osc.connect(ctx.destination);</script>")
WebViewExecuteScript(#WebView, ~"osc.start();")

Repeat
  Define Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow

If we don't execute WebViewExecuteScript() there's no issues ...

A similar "issue" also exists with PlaySound(#Sound, #PB_Sound_Loop) which inhibits Windows Sleep ...

EDIT:

I believe the issue is with my Realtek Audio driver and not any code or PB ...

powercfg -requests

SYSTEM:
[DRIVER] Realtek High Definition Audio
An audio stream is currently in use.