Use captureBeyondViewport for full-page screenshots instead of window resize#580
Merged
route merged 2 commits intorubycdp:mainfrom Apr 22, 2026
Merged
Conversation
Replaces the window-resize hack in capture_screenshot with CDP's native captureBeyondViewport: true flag on Page.captureScreenshot. The previous approach called Browser.setWindowBounds to put the window into windowState: "fullscreen" before capture and back to "normal" in an ensure block. On macOS Chrome this triggers *native* fullscreen, moving the window to its own Space and stealing focus from the user's foreground app on every full-page screenshot. captureBeyondViewport has been stable in Chrome since v81 and is the same flag Playwright and puppeteer use for their fullPage path. Output is pixel-identical, one CDP round-trip instead of three, no window-state mutation. Also implicitly fixes rubycdp#178 — huge pages that returned blank under the resize approach (because the window can't grow past the display size) now render correctly, since the native path has no viewport ceiling.
Member
|
Very nice! Mind adding changelog entry? And we are good to go! |
Contributor
Author
|
No problem! Done ✅ |
Member
|
Thank you so much! |
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.
Problem
Page#screenshot(full: true)resizes the window to fullscreen and back (maybe_resize_fullscreen). On macOS Chrome this triggers native fullscreen so the window steals focus from whatever app you're in if you're working while letting an agent run a task on your browser (this is how I found the issue).Fix
Pass
captureBeyondViewport: truetoPage.captureScreenshotand drop the resize. CDP-native since Chrome 81; same flag Playwright and puppeteer use for full-page screenshots. Output is the same, one CDP round-trip instead of three, no window-state mutation.