You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(browser): keep screenshots from drawing shifted by the page's scroll offset - #38827
When an agent took a screenshot of a page in Orca's browser after scrolling, the picture came out pushed down by however far the page was scrolled. Past one screen of scrolling it was just a blank page. Now the screenshot shows what's actually on screen at any scroll position.
Files
Added
Deleted
Net
Test
0
0
0
0
Prod
1
$\color{#1a7f37}{\Huge{\mathbf{+}}}$12
$\color{#cf222e}{\Huge{\mathbf{−}}}$9
$\color{#1a7f37}{\Huge{\mathbf{+}}}$3
What Changed
Before:orca screenshot of a scrolled page drew the page shifted down by scrollY, with blank background above it. At scrollY 2000 on a 1300 px viewport the whole image was the background colour. Scroll 0 looked right.
After: the capture matches the viewport at scroll 0, 300 and 2000. That holds on a background tab and on the visible tab, and also right after an orca full-screenshot of the same tab.
Mechanism (src/main/browser/cdp/commands/cdp-screenshot.ts): a paint-held guest only answers a pending Page.captureScreenshot once a later capture request arrives. That's why #22534 follows each capture with cheap probe captures at 250, 750, 1750 and 3750 ms. The frame a probe draws answers the pending capture too.
The probe carried a 1×1 clip at (0,0). In Chromium, a clip is drawn under a viewport-offset override, so the frame it produced, and with it the real screenshot it answered, came out shifted by the scroll offset. Probes now carry no clip.
A probe sent while a clipped or captureBeyondViewport capture is pending (full-page, or agent-browser's selector captures) re-applies that capture's emulation when it ends. Every later screenshot of that tab is then shifted until the app restarts. Those captures now get one probe sent just before them and none after. Their own emulation change draws the frame they need.
Why
Measured live in a hidden dev build, using the issue's bands.html. I compared probe variants in the same build through a runtime switch:
Probe
orca screenshot at scroll 300 / 2000
1×1 clip (main)
shifted / blank
no clip
correct / correct
Full-page capture followed by…
Later orca screenshot
any overlapping probe (clip, no clip, or the same params)
shifted for the rest of the session
a probe sent just before it, none after
correct; full-page answered in ~185 ms, 9/9 fresh background tabs
Alternatives I tried and dropped:
Probe until the page draws, then send the capture alone. A lone capture still waited for a later request. It hung 4–8 s and hit the deadline.
webContents.invalidate() instead of probe captures. It had no effect on a pending capture.
Probes that copy the capture's own clip/beyond-viewport params. They still left the emulation stuck.
A clip at the current scroll offset. It needs a layout read per probe, races with scrolling, and still breaks full-page.
orca full-screenshot still repeats the first viewport down the image. That's #25272: it happens with no probe in flight at all, so this PR doesn't change it.
Visual Proof
orca screenshot of the issue's bands.html, BEFORE (main, left) and AFTER (this branch, right). The red bar is position: fixed and belongs at the top.
Scroll 300:
Scroll 2000:
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
macOS, hidden dev build (ORCA_BACKGROUND_LAUNCH=1), driven by the installed orca CLI as the issue describes: tab create, then eval scrollTo(0,Y) and screenshot for Y in 0, 300, 2000. I checked the centre column of each PNG:
main: bar at rows 302–336 with white above at 300; all white at 2000.
this branch: bar at rows 0–36 every time, with the bands that are on screen below it. That holds on fresh background tabs, on the visible restored tab, and with full-screenshot run before each screenshot.
cdp-screenshot.test.ts (SSH admission) passes, as do cdp-bridge-integration.test.ts, cdp-ws-proxy.test.ts and cdp-ws-proxy-host-admission.test.ts. No new unit test: the bug lives in how Chromium draws a frame under another capture's emulation, which a mocked debugger can't reproduce. Asserting the probe params would only pin a constant.
Risk
The riskiest part is the full-page and clipped capture path, which now relies on a single leading probe instead of retries.
If that frame were missed: a full-page capture would time out at 8 s with "did not draw a frame" instead of succeeding. Measured: 9/9 fresh background tabs answered in ~185 ms.
Cost: each full-page or clipped capture sends one extra viewport JPEG at quality 1, about 20 ms.
What stays the same: viewport captures keep their probe schedule; only the probe's clip is gone.
Scope: main process only, with no wire or settings change. A plain revert backs it out.
Level: Low
AI Disclosure
Review
Claude review: one round, no P0/P1/P2. These P3s are left as follow-ups:
A clipped capture that times out stays pending inside Chromium, so a later capture could still overlap it. This was already possible before the change and is rarer now.
The mobile screencast's fallback capture uses a (0,0) clip and isn't serialised with agent captures. Unmeasured; it would be a separate PR.
An SSH-host refusal on a clipped capture now surfaces at the 8 s deadline instead of at the 250 ms probe. Nothing leaks: the admission check still runs on the result.
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Platforms: the capture path is shared by macOS, Linux and Windows. Only macOS was run.
SSH: page-admission checks are unchanged. Each probe and capture still goes through assertRemoteCliPageAccess and readRemoteCliAdmittedPage.
Mobile: not touched.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
captureUntilDrawn now uses a full-frame JPEG probe without a 1×1 clip. Requests with clip or captureBeyondViewport send one immediate probe. Other requests retain delayed probes. The probe schedule is cleared when capture settles.
Severity of issue fixed: Medium
Merge Risk: Moderate · up to fb345
Clipped or full-page screenshots taken while device emulation is active may come out with incorrect pixels. The common non-emulated viewport case is fixed. Resolve or explicitly accept the emulation case before merging.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
The title clearly describes the screenshot scroll-offset fix.
Description check
The description covers the required sections, including the change, issue, visual proof, testing, and risks. The full lint, typecheck, test, and build checklist remains unchecked.
Linked Issues check
[#38485] Viewport probes no longer use a clip. Clipped and beyond-viewport captures use a leading probe to avoid leaving emulation active. The author reports correct viewport content at scroll positio…
Out of Scope Changes check
[#38485] The probe changes address the viewport shift and prevent clipped or full-page captures from causing later viewport shifts. The related #25272 full-page rendering defect is outside this issue'…
Docstring Coverage
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Linked Issues check
Explanation
[#38485] Viewport probes no longer use a clip. Clipped and beyond-viewport captures use a leading probe to avoid leaving emulation active. The author reports correct viewport content at scroll positions 0, 300, and 2000, including on the visible tab. The existing SSH admission and bridge tests reportedly pass. No automated rendering regression test was added; the author explains that a mocked debugger cannot reproduce the Chromium behavior.
Full details: Out of Scope Changes check
Explanation
[#38485] The probe changes address the viewport shift and prevent clipped or full-page captures from causing later viewport shifts. The related #25272 full-page rendering defect is outside this issue's scope.
Full details: Docstring Coverage
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.
Finishing Touches
Generate docstrings
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 08121d6c-869c-4af5-b4f4-f61b0922994b
Commits
Reviewing files that changed from the base of the PR and between 62eab0c and fb345df.
Files selected for processing: 1
src/main/browser/cdp/commands/cdp-screenshot.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
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
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.
ELI5
When an agent took a screenshot of a page in Orca's browser after scrolling, the picture came out pushed down by however far the page was scrolled. Past one screen of scrolling it was just a blank page. Now the screenshot shows what's actually on screen at any scroll position.
What Changed
Before:
orca screenshotof a scrolled page drew the page shifted down byscrollY, with blank background above it. AtscrollY2000 on a 1300 px viewport the whole image was the background colour. Scroll 0 looked right.After: the capture matches the viewport at scroll 0, 300 and 2000. That holds on a background tab and on the visible tab, and also right after an
orca full-screenshotof the same tab.Mechanism (
src/main/browser/cdp/commands/cdp-screenshot.ts): a paint-held guest only answers a pendingPage.captureScreenshotonce a later capture request arrives. That's why #22534 follows each capture with cheap probe captures at 250, 750, 1750 and 3750 ms. The frame a probe draws answers the pending capture too.clipat (0,0). In Chromium, a clip is drawn under a viewport-offset override, so the frame it produced, and with it the real screenshot it answered, came out shifted by the scroll offset. Probes now carry no clip.captureBeyondViewportcapture is pending (full-page, or agent-browser's selector captures) re-applies that capture's emulation when it ends. Every later screenshot of that tab is then shifted until the app restarts. Those captures now get one probe sent just before them and none after. Their own emulation change draws the frame they need.Why
Measured live in a hidden dev build, using the issue's
bands.html. I compared probe variants in the same build through a runtime switch:orca screenshotat scroll 300 / 2000orca screenshotAlternatives I tried and dropped:
webContents.invalidate()instead of probe captures. It had no effect on a pending capture.Linked Issue
Fixes #38485
STA-13939
orca full-screenshotstill repeats the first viewport down the image. That's #25272: it happens with no probe in flight at all, so this PR doesn't change it.Visual Proof
orca screenshotof the issue'sbands.html, BEFORE (main, left) and AFTER (this branch, right). The red bar isposition: fixedand belongs at the top.Scroll 300:
Scroll 2000:
Testing
macOS, hidden dev build (
ORCA_BACKGROUND_LAUNCH=1), driven by the installedorcaCLI as the issue describes:tab create, theneval scrollTo(0,Y)andscreenshotfor Y in 0, 300, 2000. I checked the centre column of each PNG:full-screenshotrun before eachscreenshot.cdp-screenshot.test.ts(SSH admission) passes, as docdp-bridge-integration.test.ts,cdp-ws-proxy.test.tsandcdp-ws-proxy-host-admission.test.ts. No new unit test: the bug lives in how Chromium draws a frame under another capture's emulation, which a mocked debugger can't reproduce. Asserting the probe params would only pin a constant.Risk
The riskiest part is the full-page and clipped capture path, which now relies on a single leading probe instead of retries.
Level: Low
AI Disclosure
Review
Claude review: one round, no P0/P1/P2. These P3s are left as follow-ups:
Agent skill upstream boundary
Notes
assertRemoteCliPageAccessandreadRemoteCliAdmittedPage.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)