Repository navigation
Conversation
[Medium impact] The PR appears safe to merge; the previously reported test race is fixed. SummaryThe watcher reloads once more after a monitor recovers so running clients learn its size.
Reviews (3) · Last reviewed commit: "Label each stubbed reload with the width..." · Reviewed by Greptile |
| before=$(reloads) | ||
| printf '%s' '[{"name":"DP-1","width":2560,"height":1440,"disabled":false}]' >"$monitors_file" | ||
| await_reloads $((before + 1)) || fail "a mode that arrives on its own gets a reload after it" "$(<"$reload_log")" | ||
| sleep 0.6 | ||
| (( $(reloads) == before + 1 )) || fail "recovery stops after the reload for the size" "$(<"$reload_log")" |
There was a problem hiding this comment.
Recovery test can fail randomly
After before=$(reloads), the watcher can read the old 0x0 state before the test writes the recovered size. It then logs another recovery reload, followed by the required reload after recovery. The exact before + 1 check rejects this valid sequence, so a busy runner can fail even when recovery works.
Have the stub record the monitor size at each reload, then check for exactly one reload with the recovered size instead of counting all reloads after the snapshot.
There was a problem hiding this comment.
Fair: the loop can still reload once at 0x0 between the snapshot and the write. The stubbed hyprctl reload now logs the width the monitor had when it was asked for, and the case checks that exactly one reload was made at 2560 and that it was the last, however many came before at 0x0. Five runs out of five pass with four CPU hogs running beside the test; with the watcher reverted it still fails.
…w runner can shift
The KVM scenario writes the mode at an arbitrary moment. Landing between the watcher's 0x0 query and the reload it decided on, the write relabeled that recovery reload as made at 2560, so a slow runner saw two and failed a correct watcher. The stub now records what each `monitors all` query returned and logs the reload against that. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-Authored-By: Codex Medium <[email protected]> Co-Authored-By: muse-wonder via pi, thinking high <[email protected]>
|
I checked this against What was checked, on an Omarchy worker VM (Hyprland 0.57.0):
Fixed on your branch (228e400): the new KVM test could fail on a slow runner even when the watcher was right. The test writes the mode at an arbitrary moment. If that write landed between the watcher's 0x0 query and the reload it chose, the stub logged that recovery reload as made at 2560, and the test saw two. The stub now logs each reload at the width the watcher's last query returned. I proved this by slowing the reload guard and delaying the test's write: the old test failed three runs out of three and the fixed one passed three out of three. Second opinion: Codex Medium and muse-wonder (via pi, thinking high) reviewed the change. Both found the test race above, and both found nothing wrong with the fix in a second round. They agreed the watcher change is sound and proportionate, which I had concluded too; their independence from my reasoning is not guaranteed. They also raised three points that are not defects in this PR:
To test on the machine with the KVM (it replaces the watcher for this session only; logging out and back in restores the installed one): curl -fsSLo ~/omarchy-hyprland-monitor-watch https://raw.githubusercontent.com/Hamza0101/omarchy/228e400a4e0c99b01ea82c7342a08f1a21f410a7/bin/omarchy-hyprland-monitor-watch
chmod +x ~/omarchy-hyprland-monitor-watch
pkill -f bin/omarchy-hyprland-monitor-watch; setsid -f ~/omarchy-hyprland-monitor-watchThen switch the KVM away and back a few times with Nautilus open on that monitor. This waits on that confirmation from the reporter of #14422. After that it goes to the maintainer. |
Fixes #14422
When a monitor comes back through a KVM switch, Hyprland sometimes announces it at 0x0 and applies the real mode about half a second later. It sends the new
wl_output.modethen, but not a newzxdg_output_v1.logical_size: Hyprland re-sends that only onmonitor.layoutChangedandconfig.reloaded(src/protocols/XDGOutput.cpp). GTK clients that were already running keep the monitor at 0x0, take its scale as infinite, and Nautilus segfaults on its next icon redraw there. A manualhyprctl reloadclears it. That is #14422.recover_modeless()inbin/omarchy-hyprland-monitor-watchalready reloads while a monitor has no mode, but it stops as soon as every monitor reports one. Every reload it made was made at 0x0, so nothing re-sends the size once the mode is there. The loop now reloads once more when it sees the monitor recover, the step omarchybot proposed on the issue. A loop that never saw a modeless monitor doesn't, so theconfigreloadedthat final reload fires starts a loop that finds everything healthy and stops without reloading. The reload guard still holds it off during a package transaction. A healthy machine is never reloaded, as before.#15542 edits the same loop to skip internal panels; the two changes touch different lines and combine without conflict in meaning.
Reproduce on a VM
The 0x0-then-mode sequence comes from a KVM switch or a monitor that announces itself before its EDID; a VM's virtual output can't produce it on demand, so the recovery loop is exercised against a model of Hyprland instead:
With
bin/omarchy-hyprland-monitor-watchfromquattroit fails ata recovered monitor gets one more reload so clients see its size; on this branch all 16 checks pass.Validation
test/shell.d/monitor-modeless-test.sh: the startup scenario now expects one more reload once the monitor reports its mode and none after, and a new scenario has the mode arrive on its own after a reload made at 0x0, the KVM case, and expects exactly one reload made at the recovered size, and nothing after it. The stubbedhyprctlrecords the width at each reload, so a slow runner adding one more reload at 0x0 can't break the count. The scenario that follows startup waits for the new loop's first reload rather than the second overall. In an Arch container the file passes five runs out of five (16 checks) with four CPU hogs running beside it. With the watcher reverted it fails ata recovered monitor gets one more reload so clients see its size.monitor-recovery-test.shpasses.bash -nandgit diff --checkpass. The 0x0-then-mode sequence needs real hardware or a KVM; it was not reproduced, and this was not run on an Omarchy install.Human check
Switch a KVM away and back with Nautilus open on that monitor. After the switch,
journalctl --user -b | grep 'scale > 0'should stay quiet, and Nautilus should keep running.