Repository navigation
fix(browser): preserve the latest viewport after screenshot capture - #1416
Merged
Merged
Conversation
Coordinate screenshot capture with the pane that owns native bounds so Chromium cannot restore a stale viewport after a concurrent resize. Pin queued captures to their originating page and preserve caller errors.
Owner
|
Thanks for the detailed Chromium reproduction and the per-page capture design. Pinning queued captures to their original guest and restoring the latest bounds on both success and failure addresses the race at its source. The refreshed integration candidate passed the 12-iteration viewport E2E and all CI checks. Merged with appreciation for the thorough validation. |
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 and reproduction
When the embedded browser is resized during a screenshot, Chromium can finish
by restoring its capture-time viewport. The native view has already received
the new bounds, but the document keeps the old innerWidth/innerHeight.
On main
def015ebb, a local responsive page begins at 800 x 500. Starting afull-page capture and updating the browser hole before it completes leaves the
document at 800 x 500 instead of the requested 960 x 620 or 820 x 510. This was
reproduced in real Electron/Chromium across 12 alternating-size iterations,
covering both the screenshot API and raw Page.captureScreenshot.
Fix
native viewport; success or failure applies the latest visible bounds.
switching or closure cannot redirect it to a different page.
This does not reload a page, repeat a screenshot, add a timeout/retry policy,
change screenshot format, or alter CDP/URL/permission rules. No storage, provider,
MC or agent lifecycle changes are included.
Validation
points, failure recovery, concurrent requests/sibling pages, and tab closure.
node scripts/e2e-browser-capture-resize.mjspasses with real Chromium and alocal responsive page: 12/12 final viewports equal the latest requested size.
The PNG was visually inspected; the script retains its JSON/PNG/profile.
probe previously passed.
with Cargo 1.90.0. No Rust source is changed by either fix.
Environment: Windows, Node 24.19.0, Electron 43.6.0, Chromium 150.0.7871.250.
Current production sources are bundled for the probe; only compatible external
build tools/Electron are reused from an installed dependency tree.
Tested candidate: 4f68894.
Upstream base: 10e824e.
Limitations: packaged-app E2E and macOS/Linux native validation have not been
run. The probe drives the real host and browser hole but does not automate
the entire plugin toolbar. No live provider calls are required or claimed.
Review notes
Ownership stays in BrowserPane, which already controls native bounds and guest
lifetime. BrowserHost remains routing glue. Existing hidden/visible and
per-session/per-tab ownership remain intact. The caller receives errors even
though the internal queue tail allows a later independent capture to proceed.