Skip to content

Commit 74dc2bc

Browse files
authored
ci(gui): close the driven window when the walk ends instead of idling to the smoke deadline (#376)
* ci(gui): close the driven window when the walk ends The three injected drive legs waited out BDINFO_GUI_SMOKE_MS, a sleep the app starts at BOOT rather than at the end of the walk, so each leg burned roughly 100 s of pure sleep after its last assert. Inject the platform close gesture instead — WM_CLOSE, xdotool windowclose, System Events — and wait a 15 s grace. This needs no app code: exit_on_close_request is off and close_requests() is subscribed unconditionally, so the request routes through save-and-close and the process exits 0 once its last window is gone. The smoke deadline stays as the backstop with its original failure text, so a close that does not land costs exactly what it costs now. Each leg logs which path ended the app. The macOS gesture sits outside the geometry block, which that leg skips whenever Accessibility refuses the lookup. * docs(wasm): correct the published payload sizes The figures had drifted from the build they describe: the optimized .wasm is ~535 KB, not ~501 KB, and the shipped JS ~51 KB, not ~44 KB. The tracked wasm-size-budget.txt already recorded the larger figure, so the package README contradicted it. Name the optimization level the numbers are measured at, which is what makes them move.
1 parent ef3061a commit 74dc2bc

4 files changed

Lines changed: 94 additions & 12 deletions

File tree

‎.github/scripts/gui-drive-inject-linux.ps1‎

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,32 @@ $after = Get-FileHash (Join-Path $Gallery '04-settings-open.png') -ErrorAction S
100100
$landed = $before -and $after -and ($before.Hash -ne $after.Hash)
101101
Write-Host "==> settings-click pixel change: $landed"
102102

103-
Write-Host '==> waiting for the smoke-deadline exit'
104-
$exited = $proc.WaitForExit($SmokeMs)
103+
# End the app on the walk's clock, not the boot clock — the same change as the
104+
# Windows leg, with xdotool's windowclose as this platform's close gesture.
105+
# BDINFO_GUI_SMOKE_MS is a sleep the app starts at BOOT, so waiting it out
106+
# burns ~100 s of pure sleep after the walk has finished. No new debug hook is
107+
# needed: `exit_on_close_request` is false and `iced::window::close_requests()`
108+
# is subscribed unconditionally, so an OS close request routes CloseRequested
109+
# -> close_with_geometry -> SaveAndClose -> window::close and the process exits
110+
# 0 once its last window is gone. The smoke deadline stays as the BACKSTOP, so
111+
# a close that does not land costs exactly what it costs today.
112+
$CloseGraceMs = 15000
113+
Write-Host '==> asking the window to close (xdotool windowclose)'
114+
# Best-effort: a refused close must fall through to the backstop, not abort the
115+
# run. `$ErrorActionPreference = 'Stop'` plus PowerShell 7.4's native-command
116+
# error mapping would otherwise make a non-zero xdotool exit terminating here,
117+
# unlike the walk's own xdotool calls, where a failure genuinely is fatal.
118+
try { & xdotool windowclose $wid } catch { Write-Host "!! xdotool windowclose failed: $_" }
119+
$exited = $proc.WaitForExit($CloseGraceMs)
120+
if ($exited) {
121+
Write-Host '==> app ended by: the injected close'
122+
}
123+
else {
124+
Write-Host '!! the injected close did not land — falling back to the smoke deadline'
125+
Write-Host '==> waiting for the smoke-deadline exit'
126+
$exited = $proc.WaitForExit($SmokeMs)
127+
if ($exited) { Write-Host '==> app ended by: the smoke deadline' }
128+
}
105129
if (-not $exited) { Stop-Process -Id $proc.Id -Force; throw 'the app never hit its smoke deadline' }
106130
Write-Host ("==> app exit code {0}" -f $proc.ExitCode)
107131
# The app's per-launch diagnostics log rides along in the gallery.

‎.github/scripts/gui-drive-inject-macos.ps1‎

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,37 @@ else {
119119
if (-not $landed) { $failures += 'the Settings click changed no pixels (missed or blocked)' }
120120
}
121121

122-
Write-Host '==> waiting for the smoke-deadline exit'
123-
$exited = $proc.WaitForExit($SmokeMs)
122+
# End the app on the walk's clock, not the boot clock — the same change as the
123+
# other two legs, with System Events' close button as this platform's close
124+
# gesture. BDINFO_GUI_SMOKE_MS is a sleep the app starts at BOOT, so waiting it
125+
# out burns ~100 s of pure sleep after the walk has finished. No new debug hook
126+
# is needed: `exit_on_close_request` is false and
127+
# `iced::window::close_requests()` is subscribed unconditionally, so an OS
128+
# close request routes CloseRequested -> close_with_geometry -> SaveAndClose ->
129+
# window::close and the process exits 0 once its last window is gone.
130+
#
131+
# Deliberately OUTSIDE the `$geomOk` block above: that block is skipped
132+
# whenever the geometry lookup is refused, and this leg still wants its exit
133+
# shortened when the walk never ran. Best-effort throughout — Accessibility is
134+
# exactly what this leg exists to probe, so a refused close is expected here
135+
# and must fall through to the smoke deadline rather than fail the run.
136+
$CloseGraceMs = 15000
137+
Write-Host '==> asking the window to close (System Events)'
138+
try {
139+
& osascript -e 'tell application "System Events" to click button 1 of window 1 of (first process whose name is "bdinfo-rs-gui")' 2>&1 |
140+
ForEach-Object { Write-Host " $_" }
141+
}
142+
catch { Write-Host "!! the close gesture was refused: $_" }
143+
$exited = $proc.WaitForExit($CloseGraceMs)
144+
if ($exited) {
145+
Write-Host '==> app ended by: the injected close'
146+
}
147+
else {
148+
Write-Host '!! the injected close did not land — falling back to the smoke deadline'
149+
Write-Host '==> waiting for the smoke-deadline exit'
150+
$exited = $proc.WaitForExit($SmokeMs)
151+
if ($exited) { Write-Host '==> app ended by: the smoke deadline' }
152+
}
124153
if (-not $exited) { Stop-Process -Id $proc.Id -Force -ErrorAction SilentlyContinue }
125154
$code = if ($exited) { $proc.ExitCode } else { 'killed' }
126155
Write-Host "==> app exit code $code"

‎.github/scripts/gui-drive-inject-windows.ps1‎

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
# probe with a visible effect). PrintWindow screenshots after every event are
1414
# the evidence; one hard automated assert (the Settings click must change the
1515
# rendered pixels vs the shot before it) proves input actually reached the
16-
# app. The app exits by the BDINFO_GUI_SMOKE_MS deadline — exit 0 means the
17-
# event loop survived the whole injected walk.
16+
# app. The walk ends by injecting the platform's close gesture and the app
17+
# exits 0 through its own save-and-close path, with the BDINFO_GUI_SMOKE_MS
18+
# deadline kept as the backstop — exit 0 either way means the event loop
19+
# survived the whole injected walk.
1820
#
1921
# Every click re-verifies GetForegroundWindow() is still the app first —
2022
# injected input lands wherever the OS says focus is, never click blind.
@@ -410,8 +412,34 @@ $after = Get-FileHash (Join-Path $Gallery '04-settings-open.png') -ErrorAction S
410412
$landed = $before -and $after -and ($before.Hash -ne $after.Hash)
411413
Write-Host "==> settings-click pixel change: $landed"
412414

413-
Write-Host '==> waiting for the smoke-deadline exit'
414-
$exited = $proc.WaitForExit($SmokeMs)
415+
# End the app on the walk's clock, not the boot clock. BDINFO_GUI_SMOKE_MS is
416+
# a sleep the app starts at BOOT, so waiting it out burns ~100 s of pure sleep
417+
# after the walk has finished. The app is closable without any new debug hook:
418+
# `exit_on_close_request` is false and `iced::window::close_requests()` is
419+
# subscribed unconditionally, so an OS close request routes CloseRequested ->
420+
# close_with_geometry -> SaveAndClose -> window::close, and the process exits 0
421+
# once its last window is gone. WM_CLOSE is the same primitive Send-Click uses
422+
# on blocker windows above.
423+
#
424+
# The smoke deadline stays as the BACKSTOP: if the close does not land, this
425+
# falls through to the original wait and the original failure text, so a lost
426+
# close costs exactly what it costs today and reddens nothing new. Closing this
427+
# way also exercises the save-and-close path, which writes gui.conf into the
428+
# isolated config dir the walk provisioned — the log collection below reads the
429+
# same directory and is unaffected.
430+
$CloseGraceMs = 15000
431+
Write-Host '==> asking the window to close (WM_CLOSE)'
432+
[void][GuiInput]::PostMessage($hwnd, 0x0010, [IntPtr]::Zero, [IntPtr]::Zero)
433+
$exited = $proc.WaitForExit($CloseGraceMs)
434+
if ($exited) {
435+
Write-Host '==> app ended by: the injected close'
436+
}
437+
else {
438+
Write-Host '!! the injected close did not land — falling back to the smoke deadline'
439+
Write-Host '==> waiting for the smoke-deadline exit'
440+
$exited = $proc.WaitForExit($SmokeMs)
441+
if ($exited) { Write-Host '==> app ended by: the smoke deadline' }
442+
}
415443
if (-not $exited) { Stop-Process -Id $proc.Id -Force; throw 'the app never hit its smoke deadline' }
416444
Write-Host ("==> app exit code {0}" -f $proc.ExitCode)
417445
# The app's per-launch diagnostics log (it names the debug hooks the boot

‎crates/bdinfo-rs-wasm/web/README.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ Firefox.
2121
npm i @bdinfo-rs/wasm
2222
```
2323

24-
The published payload is **~501 KB of WebAssembly + ~44 KB of JS**. Only the
25-
main-thread entry you import (~9 KB) loads up front; the scan Worker (~3 KB)
26-
and the wasm-bindgen glue (~32 KB) that hosts the `.wasm` are fetched lazily
27-
inside the Worker, and nothing past the entry loads at all until the first scan.
24+
The published payload is **~535 KB of WebAssembly + ~51 KB of JS**, measured on
25+
the optimized build (`wasm-opt -Oz`). Only the main-thread entry you import
26+
(~12 KB) loads up front; the scan Worker (~4 KB) and the wasm-bindgen glue
27+
(~34 KB) that hosts the `.wasm` are fetched lazily inside the Worker, and
28+
nothing past the entry loads at all until the first scan.
2829

2930
## Usage
3031

0 commit comments

Comments
 (0)