fix(engine): prevent CDP screenshot viewport edge bleed#1037
Closed
miguel-heygen wants to merge 1 commit into
Closed
fix(engine): prevent CDP screenshot viewport edge bleed#1037miguel-heygen wants to merge 1 commit into
miguel-heygen wants to merge 1 commit into
Conversation
Change captureBeyondViewport from false to true in pageScreenshotCapture. The explicit clip rect already constrains output to exact viewport dimensions, making the additional viewport-boundary clipping from captureBeyondViewport:false redundant. Under compositor load (especially multi-worker parallelism), Chrome occasionally rounds the viewport boundary inward by 1-2px before applying the clip, exposing the body background at the bottom/right edge of the captured frame. With captureBeyondViewport:true, Chrome skips the viewport-boundary pre-clip and uses only the explicit clip rect, eliminating the intermittent edge bleed. Add viewport-edge-bleed regression test: a magenta body background with dark grid cells filling 1920×1080 edge-to-edge. Any background bleed at the edges drops PSNR sharply against the golden baseline.
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.
Summary
Fixes an intermittent rendering artifact where 1-2px of body background bleeds through at the bottom/right edge of captured frames.
Root cause:
pageScreenshotCapture()inscreenshotService.tspassescaptureBeyondViewport: falseto Chrome's CDPPage.captureScreenshot. This adds a viewport-boundary pre-clip before the explicit clip rect is applied. Under compositor load (especially multi-worker parallelism), Chrome occasionally rounds that viewport boundary inward by 1-2px, exposing the body background at the edges.Fix: Change
captureBeyondViewporttotrue. The explicit clip rect{x:0, y:0, width, height, scale:dpr}already constrains output to exact viewport dimensions — the redundant viewport boundary clip was only causing problems.Changes
packages/engine/src/services/screenshotService.ts:captureBeyondViewport: false→trueinpageScreenshotCapture()viewport-edge-bleed: magenta body background with dark grid cells edge-to-edge. Any background bleed drops PSNR sharply.Test plan
bun run --cwd packages/producer docker:test viewport-edge-bleed