Open bug report

0.8.1: saver exits near display-off without restoring brightness (left at 0 after 'BACKLIGHT: dimmed 51 -> 0')

John Lauer ·

adom-screensaver 0.8.1 (signed, Valid) · Windows 11 Home 22631 · Dell XPS 15 9510 (Intel UHD, 3456x2160 OLED) · on AC the whole time, no sleep, no dock change

Related to #1, but this is a separate path. Here 0.8.1 sets the brightness to 0 itself, and the saver then disappears without putting it back. There was no sleep and no monitor change.

What I did

Fresh deploy of the 0.8.1 dist/win files to %LOCALAPPDATA%\adom-screensaver. Saver timeout set to 120 s, monitor-timeout-ac set to 10 min, adom-stayawake.exe running. Then I left the laptop completely idle for about 11.5 minutes while a full-screen recording ran.

Expected

When the saver ends for any reason (wake, display-off, crash), the panel brightness goes back to what it was before the dim.

What happened

wv.log (complete from saver start; nothing was written after the last line):

13:56:04.608 MAIN mode=/s args=/s
...
13:56:17.737 WIKI: run done, 0 reused (delta-skip), 150 fetched, 150 total
13:57:12.037 HB: power=plugged in off=412 rested=False slides=150 cacheKB=123067
...
14:01:05.538 DIM: AC -> backlight to 0 + content near-black, display stays ON
14:01:05.675 BACKLIGHT: dimmed 51 -> 0
14:01:06.587 DIM: handing off to lightweight GDI dim logo + disposing WebView2 (frees Chromium for the night)
14:01:12.578 HB: power=plugged in off=172 rested=True slides=150 cacheKB=123068
14:02:12.665 HB: power=plugged in off=111 rested=True slides=150 cacheKB=123068
14:03:12.662 HB: power=plugged in off=51 rested=True slides=150 cacheKB=123068

The heartbeat stops after 14:03:12, about 50 s before the off= countdown reached 0. When I checked a few minutes later:

  • No adom-screensaver process was running (adom-stayawake was still running).
  • WmiMonitorBrightness.CurrentBrightness = 0.
  • Nobody had touched the keyboard or mouse.

So the saver exited at or near the display-off mark with no exit, wake or REST line in wv.log, and the backlight stayed at 0. A user coming back would see what looks like a dead screen until they press brightness-up. I restored it by hand with WmiSetBrightness(51).

Suggested fix

  • Persist the pre-dim brightness (51 here) to disk when BACKLIGHT: dimmed happens.
  • Have adom-stayawake (which is always running) restore it if the saver process goes away while brightness is still at the dimmed value. That also covers a crash, which the saver's own exit path can't.
  • Log something on every exit path so a silent exit shows up in wv.log.

Good news from the same run

A full-screen native recording (Hydrogen / Adom Bridge, DXGI) ran through all of it at a steady 30 fps. It captured the live desktop for the whole 11.5 min, and neither the billboard nor the dim logo appears in it. Without the saver, the same test on this laptop records pure black from the moment the Windows display-off timeout fires. So the "dim but stay ON" design is exactly what makes unattended screen recording possible, which is worth keeping.

2 Replies

John Lauer ·

Correction, after reading hotkey.log (adom-stayawake) and the source in adom-screensaver-dev:

I was wrong that the user would be stuck at brightness 0. The helper's safety net works. RestoreBacklightIfStranded only acts once the user is back (idle ≤ 12 s, 8 s poll), and it did:

14:04:02.222 WATCHDOG: blocked by [an app is holding it on] (elevated=False)
14:14:10.199 DISPLAY-OFF: panel powered off, saver is NOT running at this instant
14:18:42.178 DISPLAY-ON: panel powered back on (saver not up)
14:18:42.226 BACKLIGHT safety-restore -> 51

I read 0 only because I checked while nobody was at the machine. Leaving it at 0 until the user returns is the right call: restoring early would light a static desktop all night.

The real bug is the saver dying without a log at ~9:45 idle. Per the comment in Main, no EXIT/CRASH line means it was killed externally. On this machine, Windows' "Dim display after" (SUB_VIDEO 17aaa29b-8b43-4b94-aafe-35f64daaf1ee) is 585 s on AC. The saver's last heartbeat was 14:03:12 and it was gone by the 14:04:02 watchdog tick. Idle started at about 13:54:04, so the dim fired at about 14:03:49, inside that window. The hypothesis: Windows ends the screensaver when it dims the display (GUID_CONSOLE_DISPLAY_STATE = 2). WatchSaverVsDisplay only watches the on→off edge, so it can't see a kill on the dim edge.

A second clue: the display then stayed on until 14:14:10 (10 min after about 14:04), so something reset the display idle timer at about the moment the saver died.

A next step that would prove or disprove it: log the dim edge (Data == 2) in WatchSaverVsDisplay alongside on/off, and re-run with "Dim display after" set to 0 to see if the saver then survives past 10 min.

John Lauer ·

Root cause found. My dim-display theory above was wrong.

I re-ran the test for 26 minutes with Windows "Dim display after" set to 0 (never). Polling every minute (idle seconds, saver process, brightness):

16:18:52 idle=586 saver=True  bright=0
16:19:53 idle=648 saver=False bright=0   <- gone right at the 600 s "turn off display" mark

wv.log has its last heartbeat at 16:18:37 and no EXIT/CRASH line. hotkey.log then shows DISPLAY-OFF at 16:29:31, one more display timeout later. A DXGI full-screen recording froze on that frame: the taskbar clock reads 10:29 for the last 6 minutes of the take.

Why: the AC rest path says "display stays ON", but nothing ever requests it. SetThreadExecutionState(ES_DISPLAY_REQUIRED) is only called in StartWake and ExternalWake. Not sending SC_MONITORPOWER isn't enough: Windows' own "turn off display after" timer still fires, Windows ends the screensaver at that mark, and the panel goes off one timeout later. On Modern Standby that also lets the machine doze, which is the opposite of what the AC dim is for.

Fix (compiles clean with csc, C# 5; not signed, so not deployed): in the AC branch of the rest block in OnStatusTick, hold ES_CONTINUOUS | ES_DISPLAY_REQUIRED on the UI thread (skipped for PreviewDim). Release it with ES_CONTINUOUS if the machine goes onto battery during the dim. It's a 3-hunk patch: a new displayHeld field, the hold after DimBacklight(), and the release before the battery monitor-off block. Holding the display on is burn-in safe because by then the backlight is 0 and the content is a ~5% drifting logo.

Workaround until a signed build ships: set monitor-timeout-ac 0. The saver's own RestAfterSec (300 s) still dims, Windows never fires display-off, and the saver stays up all night.

(Scope is AC only. The window between the saver starting and its rest is still exposed if the Windows display-off timeout is shorter than saver-start + RestAfterSec.)

Log in to reply.