Skip to content

fix(producer): a BeginFrame capture that draws no first frame in 20 s switches to screenshot - #6701

Merged
miguel-heygen merged 2 commits into
mainfrom
fix/beginframe-first-frame-deadline
Oct 29, 2026
Merged

miguel-heygen merged 2 commits into
mainfrom
fix/beginframe-first-frame-deadline

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Description

A local hyperframes render on a Linux host with software GL (Docker, CI, no GPU) can sit at frame 0 for minutes. Four recent reports on 0.8.214, all in Docker: capture stayed at framesCompleted=0 for 120 to 240 s with captureMode=beginframe, then the automatic screenshot fallback rendered the film correctly, or the person gave up and reran with --no-browser-gpu.

Local "auto" GPU opts out of the software-GPU screenshot clamp on purpose (#3927: BeginFrame on SwiftShader captured a 15 s card in 15.7 s against 19.0 s by screenshot), so these hosts run BeginFrame. On some of them BeginFrame never delivers its first frame. The only way out was the 60 s no-progress guard, and only once it armed, before the render retried on a fresh screenshot session.

A BeginFrame capture that draws no first frame in 20 s now gives up and takes that same screenshot retry. Once a frame is drawn, the usual 60 s no-progress budget applies. BeginFrame stays the default, so hosts where it works keep its speed, and a host where it hangs loses about 20 s instead of minutes. Both stall watchdogs in the streaming capture stage use it: the single-session loop, and the parallel one (two of the reports used --workers 2 and --workers 4).

The 20 s deadline is a new engine config field, beginFrameFirstFrameDeadlineMs, unset by default. Only the CLI's local render sets it, together with the existing local-auto opt-out from the screenshot clamp. No environment variable reads it.

The cloud render path is unchanged. The cloud producer builds its own engine config and never sets the field. With the field unset, stallBudgetMs returns the stall budget exactly as before, and the existing parallel BeginFrame stall tests, which set no deadline, pass unchanged.

handleRenderError was over the complexity limit, so any change to render.ts failed the pre-commit check. Its four Chrome-launch detectors moved into chromeLaunchFailure, with the same order and the same messages; render.launchFailure.test.ts covers it.

Testing

fails without the fix: in captureStreamingStage.test.ts, gives up on frame 0 at the first-frame deadline, not the ten-minute stall budget and gives up on a parallel BeginFrame capture at the first-frame deadline both hang until bun's 5 s test timeout on main. In render.test.ts, forwards browserGpuMode='auto' into producer config fails on main because the deadline is missing from the config.

  • captureStreamingStage.test.ts: 30 passed, 3 runs in a row; leaves a screenshot capture on the stall budget shows a screenshot session keeps the full budget.
  • render.test.ts: 113 passed; the --resolution case asserts no deadline is passed.
  • tsc --noEmit for engine, producer and CLI: clean. Fallow and the comment ratchet: clean.

What I did NOT exercise

The BeginFrame hang itself. Four renders in Docker on a Linux box all progressed (same CLI, auto resolved to SwiftShader), so the deadline is tested against a simulated hang, not a real one. Why BeginFrame never answers on the reporters' hosts is still unknown.

@github-actions

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 141 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (0)

Unstable (2)

  • seqplainkeys-none-px-r0-root-z100: tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo false, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true
  • seqplainkeys-none-pct-r0-root-z100: tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo false, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true / tracking 0.06, pressJump 0, drop 0, reload 0, render 0.03, renderKey -, undo true, teleport true

@heygengenesis heygengenesis Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE · 0 blockers · 0 important · 0 nits · head 8c46b848

The deadline only applies while beginframe sits at frame 0. Both stall errors it raises are already in shouldRetryViaPinnedFallback, so they retry on a screenshot session. With the field unset, stallBudgetMs gives back the same budget as before. Only the CLI's local-auto branch sets the field. All runs are green. Windows engine-cli hit its 16-minute step deadline on attempt 1 with no failing test, and passed when rerun.

Scope

I read the engine, producer and CLI diffs. The 10 compiled.html files are LFS-pointer churn. I checked that chromeLaunchFailure keeps the old detector order and titles. Not covered, by the body's own scope: the disk and segmented capture stages still use the plain stall budget, and the parallel watchdog arms only at frame_capture, as before.

@miguel-heygen
miguel-heygen added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit a5496b1 Oct 29, 2026
132 of 134 checks passed
@miguel-heygen
miguel-heygen deleted the fix/beginframe-first-frame-deadline branch October 29, 2026 01:11
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