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): render serve pages offscreen so headless screenshots show the page - #42676
On a headless Linux server, orca serve browser pages loaded fine, but their screenshots came back as a 1x1 image or a frame of one solid colour. Server pages now render offscreen, so they draw without a window on screen. Captures show the page again, and an animated page costs less than before.
Files
Added
Deleted
Net
Test
1
$\color{#1a7f37}{\Huge{\mathbf{+}}}$2
0
$\color{#1a7f37}{\Huge{\mathbf{+}}}$2
Prod
2
$\color{#1a7f37}{\Huge{\mathbf{+}}}$8
$\color{#cf222e}{\Huge{\mathbf{−}}}$3
$\color{#1a7f37}{\Huge{\mathbf{+}}}$5
What Changed
@oliver-mee's fix: serve pages (OffscreenBrowserBackend) are created with webPreferences.offscreen: true.
On top: webContents.stopPainting() right after creation. Nothing in Orca reads Electron's offscreen paint frames, because CDP captures and screencasts copy straight from the compositor. Left on, Electron copies every animation frame into the main process.
An offscreen page reports getType() === 'offscreen', so the extension observer (browser-extension-startup.ts) now accepts that type too. Without it, serve pages with extensions enabled would lose webNavigation events and DNR frame state. The trusted-renderer checks that require 'window' keep excluding serve pages, as they should.
Their real-Electron capture test is removed. CI doesn't run it (.electron.test.ts files are listed in the workflow), and on macOS it passes with or without the fix. Their lifecycle test that asserted the preference was a constant check, and it was dropped when the file moved.
Why
A hidden native window on a headless X display has no surface to present to. Reporters saw XGetWindowAttributes failed from the software presenter, and the page's layers were never drawn into what the capture reads. Three reporters measured the same result on 1.4.219 to 1.4.247: offscreen rendering fixed every capture, and a plain hidden window did not.
Offscreen rendering is the root fix: the page no longer depends on a native window to draw. Mapping the window with showInactive() also worked on a private Xvfb, but that would pop real windows onto any desktop that runs orca serve.
Measured on macOS, 5 hidden serve-style windows each showing a CSS + requestAnimationFrame animation, averaged over 20 s:
With painting stopped, Page.captureScreenshot, CDP mouse clicks and text input, and Page.startScreencast frames all still work. The stopped state also survives cross-site navigations (new renderer processes), reloads and a renderer crash.
N/A. There's no UI change. The capture evidence is the reporters' before/after images in #26139 and #26138, plus the measurements above.
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
I wrote a Linux e2e (real orca serve on Xvfb, browser.tabCreate, then pixel checks on browser.screenshot and browser.fullScreenshot) and ran it on Ubuntu through the E2E workflow. With this change it passed (run), so offscreen pages with painting stopped capture correctly on Linux. On origin/main it also passed, 10 of 10 captures right after load (run), so CI's Xvfb doesn't reproduce the reporters' failure. Because a test that passes without the fix proves nothing, it isn't included.
A standalone Electron 43.8.7 harness on macOS measured the cost table above. It also checked captures, input, screencast frames and that the paint state survives navigation.
offscreen-browser-backend-lifecycle.test.ts still passes. Its mock gained stopPainting.
Risk
Serve pages now render offscreen on every platform. On a macOS or Windows orca serve, pages render at device scale factor 1 instead of the display's scale. orca screenshot already returns CSS pixels, so only orca full-screenshot on such a host gets lower resolution. Phone screencasts are scaled to the phone either way. Offscreen windows can also deliver the very first CDP click after a cold load slightly late: 1 of 9 local runs missed a click right after load, and none did with a short settle. Desktop <webview> tabs are untouched. To back it out, revert the PR.
Level: Medium
AI Disclosure
Review
Two review-loop rounds. In round 1, Codex found that the extension observer rejected the new offscreen type (fixed). Round 2 came back clean from both reviewers. They checked every getType() branch, the capture and screencast routes, agent input, popups (which inherit only security preferences, not offscreen) and the lifecycle.
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
SSH / remote: serve hosts own their pages, so the same backend serves remote clients and phones. No wire change.
Mobile: phone screencasts of serve pages still get frames with painting stopped (checked with Page.startScreencast).
The offscreen browser backend now enables offscreen rendering for its hidden browser windows and calls stopPainting() after window creation. The lifecycle test double adds a no-op stopPainting() method. The browser extension startup observer now accepts offscreen contents alongside webview and window contents. Existing filters remain unchanged.
Severity of issue fixed: Medium
Merge Risk: Low · up to b672d
Serve pages now render offscreen to fix blank Linux screenshots. External CDP clients that use synthetic scroll gestures on serve tabs may find them failing or ineffective. Orca's own input is unaffected. The risk is narrow and bounded, so follow-up is advisable.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: serve pages now render offscreen so headless screenshots show the page. It follows the conventional commit form and matches the objectives and the offscreen backend, e…
Description check
The description follows the template closely. It has ELI5, What Changed, Why, Linked Issue (Fixes #26138), Visual Proof marked N/A with a reason, Testing with checkboxes and detail, Risk with a level …
Linked Issues check
Directly linked issue #26138 requires genuine offscreen rendering for default headless server pages, while keeping hidden windows, the profile partition, sandbox, context isolation, and disabled Node …
Out of Scope Changes check
All changed files relate to the offscreen serve-page fix for #26138. The offscreen-browser-backend.ts change adds the offscreen preference and stopPainting() to the same window creation path. The brow…
Full details: Title check
Explanation
The title names the main change: serve pages now render offscreen so headless screenshots show the page. It follows the conventional commit form and matches the objectives and the offscreen backend, extension observer, and test changes in the summary. It is a single, specific sentence with no file lists or vague terms.
Full details: Description check
Explanation
The description follows the template closely. It has ELI5, What Changed, Why, Linked Issue (Fixes #26138), Visual Proof marked N/A with a reason, Testing with checkboxes and detail, Risk with a level and a backout plan, AI Disclosure, Review, the upstream boundary checkbox, Notes, and Checklist. The Risk section names the riskiest parts (device scale factor on macOS/Windows, first CDP click timing). The AI Disclosure section is left empty, which the template allows for maintainers, but the author's team status is not stated. The Notes section does not explicitly say that security, cross-platform, mobile, and performance concerns were checked, though it covers SSH, mobile, and cross-platform points. These are minor gaps.
Full details: Linked Issues check
Explanation
Directly linked issue #26138 requires genuine offscreen rendering for default headless server pages, while keeping hidden windows, the profile partition, sandbox, context isolation, and disabled Node integration. The diff to src/main/browser/backends/offscreen-browser-backend.ts adds offscreen: true to the BrowserWindow webPreferences. The existing partition, sandbox: true, contextIsolation: true, and nodeIntegration: false entries appear unchanged in the same hunk. The PR does not change the hidden-window path. The PR also calls webContents.stopPainting() after creation. That call does not conflict with the issue. The extension observer change in src/main/browser/extensions/browser-extension-startup.ts accepts the new 'offscreen' type so serve pages keep extension events. The reproduction and the capture evidence in the PR description support the fix. Limit: the PR removes the real-Electron capture test and the lifecycle test that asserted the preference. No automated test in the reviewed diff now checks the offscreen preference. The issue does not list a test as an explicit acceptance criterion, so this does not fail the requirement.
Full details: Out of Scope Changes check
Explanation
All changed files relate to the offscreen serve-page fix for #26138. The offscreen-browser-backend.ts change adds the offscreen preference and stopPainting() to the same window creation path. The browser-extension-startup.ts change is needed because an offscreen page reports getType() === 'offscreen'. Without it, serve pages lose extension observation. The lifecycle test file change only adds a no-op stopPainting mock method so the existing test still runs. The stopPainting() call is justified in the PR as a memory and CPU cost reduction for the new offscreen mode. It is a direct consequence of the offscreen change, not unrelated work. The trusted-renderer checks that require 'window' are not changed.
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 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.
Carries over #26139 by @oliver-mee.
ELI5
On a headless Linux server,
orca servebrowser pages loaded fine, but their screenshots came back as a 1x1 image or a frame of one solid colour. Server pages now render offscreen, so they draw without a window on screen. Captures show the page again, and an animated page costs less than before.What Changed
OffscreenBrowserBackend) are created withwebPreferences.offscreen: true.webContents.stopPainting()right after creation. Nothing in Orca reads Electron's offscreenpaintframes, because CDP captures and screencasts copy straight from the compositor. Left on, Electron copies every animation frame into the main process.getType() === 'offscreen', so the extension observer (browser-extension-startup.ts) now accepts that type too. Without it, serve pages with extensions enabled would losewebNavigationevents and DNR frame state. The trusted-renderer checks that require'window'keep excluding serve pages, as they should..electron.test.tsfiles are listed in the workflow), and on macOS it passes with or without the fix. Their lifecycle test that asserted the preference was a constant check, and it was dropped when the file moved.Why
A hidden native window on a headless X display has no surface to present to. Reporters saw
XGetWindowAttributes failedfrom the software presenter, and the page's layers were never drawn into what the capture reads. Three reporters measured the same result on 1.4.219 to 1.4.247: offscreen rendering fixed every capture, and a plain hidden window did not.Offscreen rendering is the root fix: the page no longer depends on a native window to draw. Mapping the window with
showInactive()also worked on a private Xvfb, but that would pop real windows onto any desktop that runsorca serve.Measured on macOS, 5 hidden serve-style windows each showing a CSS +
requestAnimationFrameanimation, averaged over 20 s:stopPainting()(this PR)With painting stopped,
Page.captureScreenshot, CDP mouse clicks and text input, andPage.startScreencastframes all still work. The stopped state also survives cross-site navigations (new renderer processes), reloads and a renderer crash.Linked Issue
Fixes #26138
Visual Proof
N/A. There's no UI change. The capture evidence is the reporters' before/after images in #26139 and #26138, plus the measurements above.
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
I wrote a Linux e2e (real
orca serveon Xvfb,browser.tabCreate, then pixel checks onbrowser.screenshotandbrowser.fullScreenshot) and ran it on Ubuntu through the E2E workflow. With this change it passed (run), so offscreen pages with painting stopped capture correctly on Linux. Onorigin/mainit also passed, 10 of 10 captures right after load (run), so CI's Xvfb doesn't reproduce the reporters' failure. Because a test that passes without the fix proves nothing, it isn't included.A standalone Electron 43.8.7 harness on macOS measured the cost table above. It also checked captures, input, screencast frames and that the paint state survives navigation.
offscreen-browser-backend-lifecycle.test.tsstill passes. Its mock gainedstopPainting.Risk
Serve pages now render offscreen on every platform. On a macOS or Windows
orca serve, pages render at device scale factor 1 instead of the display's scale.orca screenshotalready returns CSS pixels, so onlyorca full-screenshoton such a host gets lower resolution. Phone screencasts are scaled to the phone either way. Offscreen windows can also deliver the very first CDP click after a cold load slightly late: 1 of 9 local runs missed a click right after load, and none did with a short settle. Desktop<webview>tabs are untouched. To back it out, revert the PR.Level: Medium
AI Disclosure
Review
Two
review-looprounds. In round 1, Codex found that the extension observer rejected the newoffscreentype (fixed). Round 2 came back clean from both reviewers. They checked everygetType()branch, the capture and screencast routes, agent input, popups (which inherit only security preferences, notoffscreen) and the lifecycle.Agent skill upstream boundary
Notes
Page.startScreencast).deviceScaleFactoroption on top of this.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)