Repository navigation
console-tui: the first frame is painted before anything is probed - #1323
Conversation
Cycle 31's take stick (`666c8ab5`) reddened one scrape row per boot, a different row each time: `U2 tty1 … tty1-screen-empty` on one of two identical boots and `U2 menu …` on the other, while `U2 console quiet`/`screen`/`tty1 owner` passed in both. The mechanism is in this crate: `main` built its first `App` from a synchronous `Facts::collect()`, which waits on lemond's three HTTP endpoints (2 s timeout each while the payload starts), on `llama-server --list-devices` and on `ps`/`netstat`. A scrape that arrived inside that window read a blank screen. `Facts::idle()` is what a screen can be painted from without asking anything that has to wait: release, mode, hostname, uptime, Secure Boot, the addresses, the key hint and the max temperature (file reads plus one `ip`). `main` paints that frame first; the collector thread's first result replaces it on the loop's first pass. The idle frame does not assert what it has not asked: the status row reads `STARTING - the probes have not answered yet` (and the wide layout's single STARTING panel), and the log pane says it is reading, instead of `LEMONADE DOWN` / `DATA not mounted` / `amdxdna absent` about a box that is merely still coming up - the same rule as the `web UI http://-:13305` row this console stopped printing before a lease (engine#1040). Measured (two builds identical except this change, both with the probe pointed at a stub that takes 3 s, i.e. a boot-time payload that has not answered; pty, 80x25, first frame = first write of >= 200 bytes, 5 runs interleaved, cache removed before each run): 3086/3111/3211 ms before, 26/55/467 ms after (the outlier is load 45 on a shared box). At a fixed 0.6 s window the old binary has written 14 bytes (the alternate-screen escape, no frame) and the new one a full 80x25 frame. The collected frame is untouched: both committed snapshots byte-identical, all eight gate strings and the nine actions on 80x25 and 240x67 with the static binary. Fixes #1322
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 5bb117384796cd7610ee6ddf6a1378efb81cf02f. The right fix for #1322, at the right size: paint from file reads first, and let the collector replace it.
Checked
Facts::idle()really is non-blocking. Every helper it calls is a/procor/sysread:uptime_sreads/proc/uptime,secure_bootreads efivars from sysfs (nomokutil),max_tempreads hwmon, andapi_keyreads the conf file. The only process is the oneipinips(). Nothing waits on lemond,llama-serverorps/netstat.- It is painted first.
main.rsbuilds the firstAppfromFacts::idle(), and the loop drains the collector withrx.try_recv()(non-blocking,:272) beforeterm.draw(:302). So the first draw is the idle frame, and the collector's first result replaces it on a later pass. - The idle frame states nothing unasked: the
STARTINGpanel, theSTARTING - the probes have not answered yetcompact row, and the "reading the Lemonade log …" log line. The test asserts the absence ofDOWN/DATA not mounted/amdxdna absent/no HRX deviceat 80x25 and 240x67, plus the nine action rows and the header (the two gate rows). cargo test --offline --release(underthermal-run.sh) → 68 passed, 0 failed, including both new tests. The existing snapshot tests pass unchanged.- Mutation: with
main.rsreverted toApp::new(Facts::collect()),main_paints_an_idle_frame_before_the_first_collectfails. Restored, it passes. The source-text guard is unusual, but it is the only thing that can see this regression without a boot, as its comment says.
Nit: that test's comment cites engine#1318, an MTP PR. It should be #1322.
Not re-run: the pty first-frame A/B (3086-3211 ms → 26-467 ms with a 3 s probe stub). It is the author's harness, and the code path above makes the result follow.
|
Correction to the artifact hash in the body: Measured both ways on this box, same rustc (
So the 24 bytes are formatting, not toolchain, not path (pi-os3 also built twice in different-length paths and got the Nothing else in that message changes: no gate file is in this diff ( For the record, the durable fix for this class is that |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 5bb11738.
Built and ran it (thermal-run, this head):
cargo test 68 passed; 0 failed (the body's number, exactly)
cargo clippy --all-targets 0 diagnostics
cargo fmt --check clean
tools/copyright.py --check rc 0
diff 4 files, +133/-6 README.md, src/facts.rs, src/main.rs, src/ui.rs
snapshot/golden fixtures touched by this PR: 0
The "snapshots byte-identical" claim holds structurally, not just by the test passing: no snapshot or golden file is in the
diff at all, so every rendered-frame test is comparing against unchanged bytes and they are green. That is the right order for
this change — an idle first frame must be indistinguishable once the probes answer, and the way it could go wrong is a
snapshot quietly updated to match a new verdict.
The mechanism is the one line the body says, and both halves of it are right: App::new(Facts::idle()) paints before
anything waits, and the collector thread's first result replaces those facts on the loop's first pass (idle: false from
collect()), so the screen is idle-built only until the payload actually answers. The other half is the part that makes it
correct rather than merely fast: the idle frame says STARTING - the probes have not answered yet instead of
LEMONADE DOWN / DATA not mounted / amdxdna absent, which would be a lie about a box that is still starting — the same
rule as the web UI http://-:13305 fix (engine#1040), and it is what the two new tests pin.
The measured pair (3086/3111/3211 ms before → 26/55/467 ms after, and 14 bytes written inside a 0.6 s window on the old binary)
is yours: it needs the 3 s stub and a pty harness. It is the right instrument for a boot-time flake — a stub that takes exactly
as long as the payload does at boot is what the row was falling into — and reporting min/median/max with the 467 ms outlier
attributed to load 45 is more useful than a best-case number would have been. The cached-probe trap you hit on the first
attempt (120 s result cache → 60 ms readings) is worth knowing: it is the same class as everything else this cycle, where the
instrument quietly answered from a previous run.
This closes the c31 finding in the right place: the row was red because the screen was blank, and the fix is to paint
immediately, not to make the scraper wait longer.
|
CI on Head unchanged since pi-os3 measured it, so |
|
Follow-up at So I could not reproduce the cause line directly — One thing to fix before the merge, though: the body still carries the stale hash. It reads and the correction lives only in a comment. The body is what the release hand-off and the next reader quote — this cycle has Agreed on the durable fix: |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 3922009302038e98c21a5a99f0f54e7e66065d92. Main merges only since my READY at 5bb11738: no non-merge commit of its own, and the PR's own +/- lines against its merge-base are identical (hash 3cf29071fb6b). The review at 5bb11738 stands.
PR Reviewer Guide 🔍(Review updated until commit 69f416b)Here are some key observations to aid the review process:
|
|
Persistent review updated to latest commit 69f416b |
Fixes #1322
Root cause
main.rsbuilt its firstAppfrom a synchronousFacts::collect(), andcollect()waits on lemond's three HTTPendpoints (2 s timeout each while the payload is still starting), on
llama-server --list-devices(472 ms on the c31 boardonce settled, "seconds" by the code's own comment) and on
ps/netstat. At boot, while Lemonade is coming up, that isenough for a scrape of tty1 to read a blank screen. Cycle 31's take stick showed it as one red row per boot, a different
row each time —
U2 tty1 … tty1-screen-emptyon one of two runs of identical bytes,U2 menu … tty1-nothingon the other— while
U2 console quiet/screen/tty1 ownerpassed in both.The change (4 files, +133/−6)
src/facts.rsFacts::idle()— release, mode, hostname, uptime, Secure Boot, addresses, key hint, max temperature. File reads plus oneip; nothing that waits on another process.Factsgainsidle: bool(false fromcollect(), true fromidle()).src/main.rsApp::new(Facts::idle())instead ofApp::new(Facts::collect()). The collector thread is unchanged and its first result replaces these facts on the loop's first pass, so the screen is truthful as soon as the payload answers.src/ui.rsSTARTING - the probes have not answered yet, and the log pane says it is reading — instead ofLEMONADE DOWN/DATA not mounted/amdxdna absentabout a box that is merely still starting (the same rule asweb UI http://-:13305, engine#1040). Two tests.README.mdMeasured
Two builds identical except this change (
diff -rof the two trees = my patch and nothing else), each with the GPU probepointed at a stub that takes 3 s — a boot-time payload that has not answered yet, which is the condition the row fell
into. pty at 80x25,
TERM=linux; "first frame" = first write of ≥ 200 bytes after the alternate screen is entered; 5 runsinterleaved, and the probe's 120 s result cache unlinked before every run (my first attempt forgot that and read 60 ms
for four of the five "before" runs — the number below is with it cold):
main(before)At a fixed 0.6 s window the old binary has written 14 bytes (the alternate-screen escape sequence, no frame); the new
one has written a complete 80x25 frame:
Nothing the gates read moved. Static artifact (
build-static.sh,cadd055a25e9ded6, 1,598,144 B, noPT_INTERP), realptys at 80x25 and 240x67: all eight gate strings (
CONNECT,web UI http://,api http://,ssh root@,Lemonade Mobile,Show the API key,Reboot / power off,1-9 actions) and all nine numbered actions; and both committed snapshotsbyte-identical — the collected screen is exactly what it was, only the first ~a second is new.
Tests
cargo test68/68 (two new),cargo clippy --all-targets -- -D warningsclean,cargo fmt --checkclean,tools/copyright.py --checkrc 0.the_first_frame_is_the_menu_before_any_proberendersApp::new(Facts::idle())at 80x25 and 240x67 and requires: anon-blank frame, the header, both labels
U2 menugreps, exactly nine actions,STARTINGpresent and none ofDOWN/DATA not mounted/amdxdna absent/no HRX device.main_paints_an_idle_frame_before_the_first_collect— the frame test cannot see when the frame is painted, and thisregression is silent (every frame test passes, the screen is just late), so it reads
src/main.rsand fails if the firstAppis built from anything butFacts::idle(). PuttingFacts::collect()back turns it red (main() no longer paints the first frame from Facts::idle()), measured, then restored.Not in this PR
The harness half — a scrape row could settle-and-retry, since content was there 0 s after shell-ready — is pi-release's call
on
vm-check.sh, and this PR does not touch a gate file. No image build, no board run, no device ticket;:18097andnpu-serve-keeperuntouched.