Repository navigation
fix(browser): enable offscreen painting for headless pages - #26139
oliver-mee wants to merge 6 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/browser/offscreen-browser-backend-lifecycle.test.ts (1)
105-126: 🎯 Functional Correctness | 🔵 Trivial | 🏗️ Heavy liftAssert rendered pixels in the offscreen regression test.
The lifecycle test checks mocked window preferences and cleanup, but it does not capture a screenshot. The screenshot tests use mocked capture results. These tests can pass when a backend-created hidden page produces an empty frame. Add a focused test that loads fixture content through the offscreen backend and asserts that the captured frame contains non-empty pixels.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
8c95fb20-f55d-4f30-b53b-5450cb6fe68c
📒 Files selected for processing (2)
src/main/browser/offscreen-browser-backend-lifecycle.test.tssrc/main/browser/offscreen-browser-backend.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
|
Thanks for the pixel-test suggestion. Added a real Electron regression in d3ad571. It bundles the actual backend, creates a hidden page with synthetic red/cyan content, captures it through CDP and checks substantial red and cyan pixel areas, dimensions and cleanup. Only profile metadata and guest registration are fixture substitutes; BrowserWindow, rendering and capture are real. It passes on macOS and Linux ARM64. Disabling the preference makes the Linux control fail at the fixture deadline. All 30 focused tests, lint and Node typecheck pass on the contribution checkout. This adds current-backend coverage rather than relying only on the earlier application screenshots. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
4e680fca-699a-4e6f-a866-72317477670a
📒 Files selected for processing (1)
src/main/browser/offscreen-browser-backend-capture.electron.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
|
The three workflows for the current head, bc6df3e, have no jobs and explicitly say they are awaiting maintainer approval. For example: https://github.com/stablyai/orca/actions/runs/37597302995 Could a maintainer approve the workflows on this existing PR? The real Electron regression and focused checks are recorded above; the full upstream matrix has not run. No replacement PR is needed to address the approval gate. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
0ba89b14-a03c-46fa-9e76-64c32f840b28
📒 Files selected for processing: 3
src/main/browser/offscreen-browser-backend-capture.electron.test.tssrc/main/browser/offscreen-browser-backend-lifecycle.test.tssrc/main/browser/offscreen-browser-backend.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
|
Thanks for this, and for the careful A/B runs. They're why we're confident in the fix. Your branch needed a rebase onto the moved backend file, so #42676 carries your commits over from fresh main, with you as their author. It adds one thing on top: |
|
Thanks @oliver-mee. Your commits landed in #42676, which adds |
ELI5
A browser page on a headless server can load correctly but return an empty screenshot. The backend now uses Electron's offscreen rendering instead of relying on a hidden desktop window to paint.
What Changed
Enable
webPreferences.offscreen: truewhen creating server-owned browser windows. Add a lifecycle regression checking that offscreen rendering stays hidden and retains the profile partition, sandbox, context isolation and disabled Node integration, then destroys the owned window on close.Why
Hiding a normal window is not the same as offscreen rendering. Enabling the rendering mode at creation fixes the producer rather than rejecting valid blank pages, showing windows, waking a monitor or enlarging empty output.
Linked Issue
Fixes #26138
Visual Proof
Same synthetic HTTP fixture on Linux ARM64. The failed capture is natively 1x1; the successful capture is 1280x800. No private page contents or account data are shown.
Testing
On submitted head
d234ee14c, refreshed against upstreamba6599eab: all 32 focused tests pass on macOS, including the real backend-owned hidden Electron page capture. The fixture verifies coloured pixels, dimensions and destruction/retirement. Node typecheck with--compiler=native, scoped Oxlint and whitespace checks pass. The capture harness now imports the current process-host API and handles a page that finished loading before listener registration.Earlier fix-disabled regression evidence on upstream
385fe8abremains historical negative-control evidence, not a new negative control on the refreshed head.Real application evidence uses the earlier rebuilt source branch at 4de9f9f8 with this preference added. On Linux ARM64/Electron 43.7.5, disabling only the compiled preference gives four one-colour 1x1 failures out of five fresh runs; restoring it gives three passing runs with detailed 1280x800 captures, reload and full-page capture. An initial additional control passed, confirming intermittency. Earlier repeated macOS application scenarios also passed with the preference enabled.
These are source-build tests, not signed/package installation tests. The earlier application branch also contained independent cookie-diagnostic and keyboard-admission changes; its control alters only the rendering preference. The latest macOS Electron fixture runs directly from this submitted head. Windows, remote streaming/reconnection, GPU memory under many tabs and the full repository matrix are not claimed.
AI Disclosure
OpenAI GPT-6.1 Sol assisted implementation, testing and preparation.
Review
Self-review: one Electron preference in the existing headless backend, no desktop-webview conversion. The execution host retains page/profile ownership for local and SSH/remote use; no new wire fields or capabilities. Sandbox and isolation remain enabled. No agent, integration or Git provider behavior changes. Offscreen painting can change CPU/GPU use and scheduling, so sustained multi-tab resource testing remains a limitation. Synthetic screenshots demonstrate correct output; legitimate blank pages remain allowed.
Agent skill upstream boundary
Notes
Upstream validation for
d234ee14ceis waiting for maintainer approval: PR Checks. Focused local evidence above remains unchanged; no substantive current-head CI pass is claimed.Related #24761 is opt-in high-density rendering and leaves the default path unchanged. This fixes default headless painting at the existing viewport size; it introduces no density option. If that PR lands, its explicit offscreen options should override this default. #14987's close-cleanup changes are separate. No install, service restart or account-profile mutation performed.
X/Twitter handle: not supplied.
Checklist
pnpm lint,pnpm typecheck,pnpm test, andpnpm buildmatrix (focused checks above; CI required)🤖 Generated with GPT-6.1 Sol
🧑💻 Ideated, directed and reviewed by a human, @oliver-mee