fix(renderer): cap full-page screenshot height to avoid OOM#212
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes us/crw-saas#161.
Full-page capture sent
captureBeyondViewport:truewith 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.getLayoutMetricsand, when height exceedsSCREENSHOT_MAX_HEIGHT_PX(default 15000, envCRW_RENDERER__SCREENSHOT_MAX_HEIGHT_PX), send an explicitclipinstead. Pages under the cap keep byte-identical output;getLayoutMetricsfailure degrades to the prior behavior.Verified: real-Chrome smoke against a 40000px page (getLayoutMetrics height > 15k, clipped capture returns a valid PNG);
screenshot_clipunit test; full crw-renderer suite green.