Skip to content

fix(engine): a render starts when an image, dialog or font never answers - #9151

Merged
miguel-heygen merged 7 commits into
mainfrom
fix/bounded-open-waits
Dec 2, 2026
Merged

miguel-heygen merged 7 commits into
mainfrom
fix/bounded-open-waits

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

Three waits between opening a page and its first frame had no limit of their own, so a page that never answered one held the render, with the browser idle, until the 300 s protocol limit ended it. Each now ends on its own:

  • Image decode. decodeAllImages waits at most 15 s, as background images already do. An image still decoding is named in a media_readiness_timeout warning and the render goes on.
  • Dialogs. Nothing answered alert, confirm or prompt, and an open dialog blocks every call to its page. They are now declined. A page asking to stay (beforeunload) is left.
  • Fonts. document.fonts.ready is waited on for at most 15 s; then the render goes on with the fonts it has, with a warning.

A shorter player-ready timeout shortens the image and font limits.

Why

One broken image, dialog or font face cost a person five minutes and the whole render. The error named a browser call, not the thing that was stuck.

Related work

#9147 also changes frameCapture.ts. Its hunk does not overlap this change; whichever lands second merges main. No issue.

How

  • The decode and font limits are timed in Node (settlesWithin), not by a page timer, because the page's own timers stop between frames under BeginFrame.
  • The images still decoding are kept on the page, so the warning can name them after the limit.
  • answerPageDialogs is one function: the engine attaches it to the two pages that load a film (the capture session and the static verification page), the CLI to every page of launchManagedBrowser. The other engine pages load only our own HTML.
  • recordBackgroundDecodeTimeouts and the image warning share one recorder.
  • With --no-best-effort these warnings fail the render, as the other readiness warnings do.

A behaviour change: fonts or images that need more than 15 s used to be waited for, up to the protocol limit. They are now captured as they stand, with the warning.

Test plan

  • Unit tests added/updated: pageOpenWaits.browser.test.ts (engine, 6 tests) and launch.dialogs.browser.test.ts (CLI, 4), both in real Chrome.
    • Fails without the fix, one part removed at a time: decode (Runtime.callFunctionOn timed out), the alert, confirm and prompt films, fonts (Runtime.evaluate timed out), and all 4 CLI tests.
    • A page whose images decode opens with no warning, with or without the fix.
    • The engine file passes 3 times in a row. Whole engine suite: 3820 passed, 6 skipped.
    • CLI src/browser, src/capture and the validate, layout, motionShot and snapshot tests: 1498 passed, 138 skipped, 1 failed. The failure, snapshotHdrFrame.test.ts, is a colour value (24 off, 8 allowed) and fails the same on this machine with main's launch.ts and frameCapture.ts.
  • Manual testing performed: the CLI built from this branch rendered four one-page films (decode never answers, alert at load, alert at 1.5 s, fonts never settle) in screenshot and in BeginFrame capture, with a 60 s protocol limit. All 8 gave the full 40 frames, in 2 to 24 s. With CLI 0.9.106 in screenshot capture, all four failed on a protocol timeout (20 s limit).
  • Documentation updated: none needed.
  • Comments follow CONTRIBUTING.md "Comments".

Not exercised: macOS, Windows, a hardware GPU, and distributed chunk rendering. The decode that never answers is forced by a script in the test page; eleven unusual real images (animated, truncated, very large, swapped while loading) all decoded on Linux, so no natural cause is claimed. Two waits on decode() keep no limit of their own: applyVideoMetadataHints (an inline SVG poster) and the late-image wait before a frame.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 286 (base branch 286), smooth 75 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)

@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

The description above is for the first head, 3cc6e7f. At 6201f54, read this instead: the dialog part is gone (#9152) and the limit is 45 s, not 15 s.

What

Three waits between opening a page and its first frame had no limit of their own, so a page that never answered one held the render, with the browser idle, until the 300 s protocol limit ended it. Each now ends on its own:

  • Image decode. decodeAllImages waits at most 15 s, as background images already do. An image still decoding is named in a media_readiness_timeout warning and the render goes on.
  • Dialogs. Nothing answered alert, confirm or prompt, and an open dialog blocks every call to its page. They are now declined. A page asking to stay (beforeunload) is left.
  • Fonts. document.fonts.ready is waited on for at most 15 s; then the render goes on with the fonts it has, with a warning.

A shorter player-ready timeout shortens the image and font limits.

Why

One broken image, dialog or font face cost a person five minutes and the whole render. The error named a browser call, not the thing that was stuck.

Related work

#9147 also changes frameCapture.ts. Its hunk does not overlap this change; whichever lands second merges main. No issue.

How

  • The decode and font limits are timed in Node (settlesWithin), not by a page timer, because the page's own timers stop between frames under BeginFrame.
  • The images still decoding are kept on the page, so the warning can name them after the limit.
  • answerPageDialogs is one function: the engine attaches it to the two pages that load a film (the capture session and the static verification page), the CLI to every page of launchManagedBrowser. The other engine pages load only our own HTML.
  • recordBackgroundDecodeTimeouts and the image warning share one recorder.
  • With --no-best-effort these warnings fail the render, as the other readiness warnings do.

A behaviour change: fonts or images that need more than 15 s used to be waited for, up to the protocol limit. They are now captured as they stand, with the warning.

Test plan

  • Unit tests added/updated: pageOpenWaits.browser.test.ts (engine, 6 tests) and launch.dialogs.browser.test.ts (CLI, 4), both in real Chrome.
    • Fails without the fix, one part removed at a time: decode (Runtime.callFunctionOn timed out), the alert, confirm and prompt films, fonts (Runtime.evaluate timed out), and all 4 CLI tests.
    • A page whose images decode opens with no warning, with or without the fix.
    • The engine file passes 3 times in a row. Whole engine suite: 3820 passed, 6 skipped.
    • CLI src/browser, src/capture and the validate, layout, motionShot and snapshot tests: 1498 passed, 138 skipped, 1 failed. The failure, snapshotHdrFrame.test.ts, is a colour value (24 off, 8 allowed) and fails the same on this machine with main's launch.ts and frameCapture.ts.
  • Manual testing performed: the CLI built from this branch rendered four one-page films (decode never answers, alert at load, alert at 1.5 s, fonts never settle) in screenshot and in BeginFrame capture, with a 60 s protocol limit. All 8 gave the full 40 frames, in 2 to 24 s. With CLI 0.9.106 in screenshot capture, all four failed on a protocol timeout (20 s limit).
  • Documentation updated: none needed.
  • Comments follow CONTRIBUTING.md "Comments".

Not exercised: macOS, Windows, a hardware GPU, and distributed chunk rendering. The decode that never answers is forced by a script in the test page; eleven unusual real images (animated, truncated, very large, swapped while loading) all decoded on Linux, so no natural cause is claimed. Two waits on decode() keep no limit of their own: applyVideoMetadataHints (an inline SVG poster) and the late-image wait before a frame.

@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

This replaces the description and my earlier comment, for head 1154b22.

What it does now. A font or picture that has not settled by the page's ready limit (playerReadyTimeout, 45 s by default, which loading images and videos already have) stops the render and names it: "The font X didn't load, so the export stopped." or "The picture X didn't load, so the export stopped." With no name to give: "A font didn't load, so the export stopped." It follows ImageMissingFromFrameError: stop rather than make a video missing something. No warning, and nothing is drawn in the wrong typeface.

What changes for a film that renders today. Under 45 s, nothing: a font arriving after 20 s gives frames identical to before. A font or image that needs 45 to 300 s used to be waited for; its render now fails, named. One that never settles used to fail at 300 s with a browser call's name.

  • PageNotReadyError is exported by the engine. The probe stage leaves its words as they are, without "Preparing the render stopped while ...".
  • The limits are timed in Node, and so is asking the page for the name (5 s), so a page that no longer answers still ends.
  • The static verification page stops the same way, which fails the still-frame check closed.
  • Snapshot, through waitForImagesReady, warns about an image still decoding and takes the still.
  • The error is not in the distributed non-retryable lists: a retry may find the network faster.

Tests. pageOpenWaits.browser.test.ts (6, real Chrome, 3 passes in a row) and one in probeStage.test.ts. With main's frameCapture.ts the four stop-and-name tests fail. Each of these turns a test red: reading the wrong font state, giving a data URL as a name, not stopping on an image, the probe adding its words, a font limit of 100 ms. Engine suite 3820 passed. CLI src/capture and snapshot: 901 passed, 1 failed; producer's unit lanes: 6 failed. Those 7 (snapshotHdrFrame, artifactTransaction and five in videoAudioProbe) fail the same on this machine with main's sources.

Rendered, CLI built from this head's sources, Linux: a font answered after 20 s, as @font-face and added by script: 22 s, frames identical to before. A font answered after 100 s, both ways, and a decode that never answers, each in screenshot and in BeginFrame capture: all six exit 1 in 46 to 52 s with the words above and no file.

Not exercised: macOS, Windows, a hardware GPU, distributed chunks, a render that skips the probe.

@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

Correction to the description above: it describes an earlier version of this change. What the diff does at 6776f07:

  • The three waits a render makes while a page opens now have a time limit: decoding its images, document.fonts.ready, and the wait for pictures still decoding. On main none of them has one, so a page whose image or font never answers keeps the render waiting forever.
  • A font or picture still missing when the limit passes stops the render with a new PageNotReadyError that names it ("font" or "picture" and which one). It does not continue with a warning, and there is no dialog handling.
  • PageNotReadyError is exported from the engine. The producer's probe step passes it through as it is, so the person sees the name of what was missing.
  • The CLI's single-frame capture still reports images that never loaded as a warning.
  • The page reads that name the missing font or picture are limited too (5 s).

main is merged in. Locally at that head, the 44 frame-capture test files (465 tests) and the new pageOpenWaits.browser.test.ts (6 tests) pass.

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approve at 6776f07.

The PR description is older than the diff, so I judged the change against your comment of 1154b22 ("With main's frameCapture.ts the four stop-and-name tests fail") and the correction comment for this head. Since 1154b22 the only commit is a merge of main. git show --remerge-diff is empty, so no conflict was resolved by hand, and the PR's own hunks and pageOpenWaits.browser.test.ts are unchanged since then. That makes the earlier fails-without line apply to this head.

The limit. It is playerReadyTimeout, 45 s by default and settable with PRODUCER_PLAYER_READY_TIMEOUT_MS. Images and videos that are still loading already get this same limit. The font wait starts when the image and video waits start, which is after pollHfReady and the sub-timeline wait, so a font has been loading for longer than 45 s by the time it can be stopped. The decode wait gets its own 45 s, starting after pollImagesReady, so a slow load does not eat into it. The limits are timed in Node (settlesWithin). On a busy machine a Node timer fires late, never early, so a slow asset that is otherwise fine gets at least the full limit. The 5 s asks that name the missing item are timed the same way, so a page that has stopped answering still ends.

Error class. classifyCaptureFailure has no pattern that matches "didn't load", so the error is classed unknown, the same as ImageMissingFromFrameError. On main the same render ended as a protocol_timeout 300 s in. Two things follow from unknown:

  • isFatalCaptureFailure is true, so the pool stops at once.
  • The error is not in the distributed non-retryable lists, so a chunk is retried at step level. That matches what you intended.

A font host that never answers is a problem with the network or the host, and a missing file fails fast, so a content kind would not fit either. Nit: a named kind, or an authoring pattern for the font and picture case, would keep these out of the unknown bucket on dashboards. It does not block.

Smaller notes, not blocking

  • When the page stops answering, decodeAllImages returns [""], and the error becomes "A picture didn't load". A page that is hung, for example by a script loop, would be reported as a missing picture. That is still better than the 300 s browser-call error, but the wording is a guess there.
  • In the CLI's single-frame capture, that same [""] case prints the unloaded-images warning with an empty source list.

Need ✓ (a render waiting 300 s for one asset that never answers) · Size ✓ · Reuse ✓ (the existing ready limit, and the same stop-and-name shape as ImageMissingFromFrameError) · Simpler ✓ · Structure ✓
Risk: a font or image that takes 45 to 300 s used to render and now fails, with its name in the error. That is the trade the PR describes.

Review by Rames

@miguel-heygen
miguel-heygen added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit f5b16b2 Dec 2, 2026
105 checks passed
@miguel-heygen
miguel-heygen deleted the fix/bounded-open-waits branch December 2, 2026 21:34
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.

2 participants