Skip to content

fix(renderer): cap full-page screenshot height to avoid OOM#212

Merged
us merged 1 commit into
mainfrom
fix/screenshot-height-cap
Jul 6, 2026
Merged

fix(renderer): cap full-page screenshot height to avoid OOM#212
us merged 1 commit into
mainfrom
fix/screenshot-height-cap

Conversation

@us

@us us commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Closes us/crw-saas#161.

Full-page capture sent captureBeyondViewport:true with no clip, so Chrome rasterized the entire scroll height into one bitmap. On a tall, heavy page (~16k px) the transient render spiked past a 2GB Chrome and OOM-killed the renderer mid-capture, returning metadata with no screenshot.

Fix: measure the content box via Page.getLayoutMetrics and, when height exceeds SCREENSHOT_MAX_HEIGHT_PX (default 15000, env CRW_RENDERER__SCREENSHOT_MAX_HEIGHT_PX), send an explicit clip instead. Pages under the cap keep byte-identical output; getLayoutMetrics failure degrades to the prior behavior.

Verified: real-Chrome smoke against a 40000px page (getLayoutMetrics height > 15k, clipped capture returns a valid PNG); screenshot_clip unit test; full crw-renderer suite green.

Full-page capture sent captureBeyondViewport:true with no clip, so Chrome
rasterized the entire scroll height into one bitmap; a very tall page spiked
memory past a 2GB Chrome and OOM-killed the renderer mid-capture (#161).

Measure the content box via Page.getLayoutMetrics and, when height exceeds
SCREENSHOT_MAX_HEIGHT_PX (default 15000, env CRW_RENDERER__SCREENSHOT_MAX_HEIGHT_PX),
send an explicit clip instead. Pages under the cap keep byte-identical output;
getLayoutMetrics failure degrades to the prior behavior.

Fixes #161
@us us merged commit c5f555d into main Jul 6, 2026
5 checks passed
@us us deleted the fix/screenshot-height-cap branch July 6, 2026 20:29
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