Skip to content

Hold the simulator's settled capture until an armed autopause lands - #1235

Merged
GLinnik21 merged 2 commits into
mainfrom
fix/sim-autopause-settle
Nov 4, 2026
Merged

GLinnik21 merged 2 commits into
mainfrom
fix/sim-autopause-settle

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

What failed

The macOS simulator's player screenshot scene was flaky: 4 to 5 of 10 runs failed, capturing a player with no picture and no pause.

Cause

The settle rule shot::settled_due = !busy && age >= 2000ms && quiet >= 1500ms holds the capture while ScreenshotArms::pending() is true, but pending() ignored the scene's autopause arm. autopause_arm cannot fire until 6 s after boot (on the Player route), and the scene's Pause lands about 14 s in. So a quiet 1.5 s while the player loads settled a frame with no picture and no pause.

Log signature: failing runs settled 2.0 to 3.5 s after the first frame with no simvideo: first picture and no autopause: Pause accepted; passing runs settled 13.7 to 16 s in with both.

Fix

  • ScreenshotArms gains a PauseDebt (Unread / Owed / Paid), counted in pending(). autopause_debt keeps it current from each_frame.
  • The debt is owed while the trigger is unread, while the arm has not armed itself (pause_tried unset), and while it is armed and waiting on its playhead. That mapping is a small pure function, pause_edges_left(pause_tried, script_armed).
  • A 60 s give-up (AUTOPAUSE_CEILING_MS, beside clockstop's) stops the hold so a scene whose playhead never arrives fails on its expect lines, with autopause: gave up; the pause never landed in the log, instead of on the driver's timeout. The module //! now says which two arms wait up to a minute rather than CEILING_MS.
  • Simulator only (hostsim); nothing changes on the television.

Evidence

  • Interleaved A/B with binaries on the internal SSD: pre-fix 6/10 and 5/10 on two trees; fixed 10/10, settling 13.7 to 18.6 s after the first frame with picture and Pause.
  • A full 17-scene tools/screenshots.py run exited 0.
  • The hostsim test for the held capture fails with the pending() clause removed.
  • make test-hostsim T=autopause: test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 1324 filtered out (the third is autopause_stays_owed_on_the_frames_before_its_arm_arms_itself).
  • That new test fails (not armed yet: the Pause is still to come, 2 passed, 1 failed) when !pause_tried is dropped from pause_edges_left, and passes with it restored.
  • bash ci/check-deps.sh: all gates green. python3 ci/check-module-layers.py: green.

Not covered

shot::tick reads LAST_CHANGE before that iteration's should_present records it, so "quiet" can span a long main-thread stall in scenes no arm holds (for example failure).

🤖 Generated with Claude Code

GLinnik21 and others added 2 commits November 4, 2026 21:42
The `player` screenshot scene failed two runs of three at 287f19a
(no `simvideo: first picture decoded`, no `autopause: Pause accepted`).
Its settled capture fired on a player that was still loading: the
capture's quiet is wall clock, `autopause` cannot even arm until six
seconds into the run, and on a busy host the debug simulator runs a
frame a second with a main-thread hang of seconds when Play starts, so
the first tick after the stall finds the screen unchanged for longer
than the quiet and photographs a picture-less, un-paused player.
`ScreenshotArms::pending` held the capture for every other armed edge
(libtype, libgrid, libshelf, libmenu, clockstop) but not this one.

`autopause` now owes the capture its Pause: the debt is read once, held
from the first frame (an unread trigger counts as owed, as an unread
`clockstop` does), and paid when the Pause lands. A 60 s ceiling stops a
Pause that never lands from holding the capture back for good; the arm
logs `autopause: gave up` and the scene fails on its `expect` lines.
The debt is kept current in `each_frame` before the arms that can return
early.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ceiling prose

The line that holds the frames before the arm arms itself was untested: both
tests passed edges_left in by hand, so dropping `!sc.pause_tried` reintroduced
the flake with both green. It is now a pure `pause_edges_left`, with a test
that fails without that clause.

The comment on `autopause_debt`'s call gave a false reason for its placement:
detail_arm, collection_arm and play_arm each set their latch before returning
false, so each returns false on at most one frame and that frame skips
`shot::tick` too. The module doc's "every arm gives up after CEILING_MS" now
names the two arms that wait up to a minute.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit 7ad737e into main Nov 4, 2026
20 checks passed
@GLinnik21
GLinnik21 deleted the fix/sim-autopause-settle branch November 4, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant