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(window): pump hidden-window frames from the renderer on Windows background launches - #34197
When Orca is started hidden for automation on Windows (ORCA_BACKGROUND_LAUNCH=1), its window is never shown. Since #33799 removed the last always-running animation, that idle hidden window produced no frames, so a CDP screenshot waited forever. Now the page itself changes one pixel-dark shade for a single frame every 750 ms while hidden. That gives Windows a frame to capture, and nobody can see it.
What Changed
Before: on Windows, an idle hidden main window never produced a compositor frame, so Page.captureScreenshot hung, even though the renderer was otherwise alive (evaluate, rAF and screencast all worked).
Until then, the status-bar usage chip's endless pulse had been keeping frames coming.
After:
Main (createMainWindow): only on win32 with ORCA_BACKGROUND_LAUNCH=1, main adds a preload flag (--orca-hidden-window-frame-pump, via additionalArguments) to the never-shown main window. On that window's first show, main sends window:hidden-frame-pump-stop. It sends it again after any later reload, because the reloaded preload restarts the pump.
Preload (src/preload/hidden-window-frame-pump.ts): when the flag is present, every 750 ms it sets document.documentElement's inline background-color to rgb(1, 1, 1) inside one requestAnimationFrame and restores it on the next one.
The restore puts back the previous inline value and its !important priority exactly, or removes the property if there was none.
Flips never overlap.
Only main's stop message ends it. It doesn't react to visibilitychange, because Windows can report a never-shown window as visible after a desktop change, and stopping then would bring the hang back. A flip already in progress still restores.
Closing the window ends the renderer.
Flag-off: normal launches, macOS and Linux never get the flag, so no preload timer exists.
Why
The first version didn't work: a main-process webContents.invalidate() every 750 ms on Windows. On the Windows 11 machine (session 0, packaged CI build) it still timed out, the same as main. A never-shown window ignores a main-side invalidate.
What did work there: renderer-side damage. Flipping the root background for one frame inside rAF every 750 ms made captureScreenshot return in 2.0 s. This PR ships exactly that.
No better hook exists: a CDP screenshot request from an external debugger can't be seen by Orca, so a periodic one-frame flip is the only hook.
N/A (main break: hidden-window CDP validation required by AGENTS.md).
Visual Proof
N/A: there's no visible change. The flip happens only in windows that are never shown, lasts one frame and uses near-black.
Testing
On Windows 11 (session 0, packaged build, raw CDP, about 10–15 s idle):
with ORCA_BACKGROUND_LAUNCH=1, main and the earlier invalidate version time out;
the renderer-side flip returns in 2.0 s;
without the env var, everything returns in 0.1 s.
This branch is being re-verified on the same Windows machine before merge.
On macOS: the hang doesn't reproduce here. To check the wiring, I temporarily enabled the gate for darwin and built. Through CDP I saw the root style attribute gain background-color: rgb(1, 1, 1) and then return to its exact prior value, about every 750 ms, and the screenshot returned in 29 ms. The gate was then restored to win32 only.
Unit tests (21 across 4 files, including the createMainWindow suite):
Gate: on only for win32 with the env var; off for darwin, linux and without it.
Preload flag round-trip.
Main stop-on-show:
no stop while never shown, even across reloads;
stops on first show and again after a reload;
skips destroyed contents.
Preload installer: starts only with the flag and hands main the stop.
Preload pump:
flips one frame and removes what it added;
restores an existing inline value and priority exactly;
never overlaps;
stop cancels the interval but a flip already in progress still restores.
Other checks: oxlint, the ast-grep gates and the changed-code gate pass. pnpm tc reports only two errors already on main, in files this PR does not touch: agent-account-restart-startup.ts, fixed by #34203, and doc-preview-external-link-confirmation.test.ts.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
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
Who is affected: only hidden automation launches on Windows. In production, ORCA_BACKGROUND_LAUNCH=1 is set only by short-lived preflights that never create the main window. The orcad browser sidecar uses ORCA_ORCAD_SIDECAR instead and is deliberately out of scope. There's no SSH, mobile or wire impact.
Windows e2e runs: the hidden main window now paints one frame every 750 ms. A Windows spec that measures idle frames or watches root inline style mutations would see that.
Follow-up if needed: the hidden workspace window and dashboard popout aren't flagged. If a Windows harness needs screenshots of them, they need the same flag.
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)
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)
The main window enables the hidden-window frame pump only on Windows when ORCA_BACKGROUND_LAUNCH is "1". It passes a pump argument to the renderer while preserving the browser host ID argument. The preload flips the root background style on a 750 ms interval and restores the prior inline value and priority. The main window sends a stop signal on the first show event and after later load completions. Added tests cover the enablement conditions, style changes, stop behavior, and lifecycle events.
Priority: Normal
Merge Risk: Low · up to 1923c
A late window event could cause an error after close. Capture the web contents reference before merging, or accept this narrow lifecycle risk.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surv…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title follows the conventional commit style and names the main change: the renderer pumps hidden-window frames on Windows background launches. It matches the changeset, which adds a preload frame …
Description check
The description follows the repository template closely. It has an ELI5 section, a What Changed section with before and after behavior and mechanism, a Why section that explains the rejected invalidat…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title follows the conventional commit style and names the main change: the renderer pumps hidden-window frames on Windows background launches. It matches the changeset, which adds a preload frame pump gated to win32 with ORCA_BACKGROUND_LAUNCH=1 and wires main-process stop-on-show behavior. It is 87 characters, slightly long but still specific and readable.
Full details: Description check
Explanation
The description follows the repository template closely. It has an ELI5 section, a What Changed section with before and after behavior and mechanism, a Why section that explains the rejected invalidate approach, Testing with platforms covered (Windows 11, macOS) and unit test coverage, and Notes on affected users. Two gaps remain: the Linked Issue section reads 'N/A (main break...)' with no issue reference, although the template says an issue should always exist for outside contributors, and the AI Disclosure section is empty. The final pnpm checklist item is unchecked, and the Visual Proof section has an N/A reason. The description is mostly complete, so the check passes, but the missing linked issue should be addressed.
Full details: Docstring Coverage
Explanation
Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 10 functions across 8 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches: 💡 1
📝 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.
nwparker
changed the title
fix(window): repaint a never-shown background window on Windows so CDP screenshots return
fix(window): pump hidden-window frames from the renderer on Windows background launches
Oct 27, 2026
…P screenshots return
Windows composites nothing for an idle window that was never shown, so
Page.captureScreenshot under ORCA_BACKGROUND_LAUNCH=1 waited forever once the
status-bar usage chip stopped animating (#33799).
…ackground launches
Main-process webContents.invalidate() did not make a never-shown Windows window
produce a frame CDP can capture (verified on Windows 11). A one-frame root
background flip from the preload does, so main stamps a preload flag for
ORCA_BACKGROUND_LAUNCH=1 on win32 and tells the preload to stop on first show.
…ncluding after reloads
A never-shown Windows window can report visible after a desktop change, so the
preload no longer stops on visibilitychange; main re-sends the stop after any
reload once the window has been shown.
…ndow double supports it
createMainWindow suites simulate win32 under the runner's ORCA_BACKGROUND_LAUNCH=1,
so they install the pump stop; their window doubles implement on() but not once().
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: 960a0b5a-3fc9-4d5c-bdb5-08693ea26429
Commits
Reviewing files that changed from the base of the PR and between 7ab3ebb and 1923c10.
Files selected for processing: 2
src/main/window/hidden-window-frame-pump.test.ts
src/main/window/hidden-window-frame-pump.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
Capture webContents once in stopHiddenWindowFramePumpOnShow.
stop() reads window.webContents at call time. The BrowserWindow.webContents getter throws after the window closes, and the repository documents that late webContents events can still arrive. A did-finish-load that fires after close can therefore reach stop() and throw in the main process. Capturing the reference at install time avoids the getter. isDestroyed() on the captured object still returns true after close, so the guard skips the send. Reloads keep the same webContents object, so the first-show and reload behavior is unchanged.
🐛 Suggested fix
--- "a/src/main/window/hidden-window-frame-pump.ts"+++ "b/src/main/window/hidden-window-frame-pump.ts"@@ -10,22 +10,23 @@
}
/** The preload pumps from birth; stop it on first show and after any later reload restarts it. */
export function stopHiddenWindowFramePumpOnShow(window: FramePumpWindow): void {
let shown = false
+ const webContents = window.webContents
const stop = (): void => {
- if (window.webContents.isDestroyed?.() !== true) {- window.webContents.send(HIDDEN_WINDOW_FRAME_PUMP_STOP_CHANNEL)+ if (webContents.isDestroyed?.() !== true) {+ webContents.send(HIDDEN_WINDOW_FRAME_PUMP_STOP_CHANNEL)
}
}
window.on('show', () => {
if (!shown) {
shown = true
stop()
}
})
- window.webContents.on('did-finish-load', () => {+ webContents.on('did-finish-load', () => {
if (shown) {
stop()
}
})
}
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 Orca is started hidden for automation on Windows (
ORCA_BACKGROUND_LAUNCH=1), its window is never shown. Since #33799 removed the last always-running animation, that idle hidden window produced no frames, so a CDP screenshot waited forever. Now the page itself changes one pixel-dark shade for a single frame every 750 ms while hidden. That gives Windows a frame to capture, and nobody can see it.What Changed
Before: on Windows, an idle hidden main window never produced a compositor frame, so
Page.captureScreenshothung, even though the renderer was otherwise alive (evaluate, rAF and screencast all worked).After:
createMainWindow): only onwin32withORCA_BACKGROUND_LAUNCH=1, main adds a preload flag (--orca-hidden-window-frame-pump, viaadditionalArguments) to the never-shown main window. On that window's firstshow, main sendswindow:hidden-frame-pump-stop. It sends it again after any later reload, because the reloaded preload restarts the pump.src/preload/hidden-window-frame-pump.ts): when the flag is present, every 750 ms it setsdocument.documentElement's inlinebackground-colortorgb(1, 1, 1)inside onerequestAnimationFrameand restores it on the next one.!importantpriority exactly, or removes the property if there was none.visibilitychange, because Windows can report a never-shown window as visible after a desktop change, and stopping then would bring the hang back. A flip already in progress still restores.Why
webContents.invalidate()every 750 ms on Windows. On the Windows 11 machine (session 0, packaged CI build) it still timed out, the same as main. A never-shown window ignores a main-side invalidate.captureScreenshotreturn in 2.0 s. This PR ships exactly that.Linked Issue
N/A (main break: hidden-window CDP validation required by AGENTS.md).
Visual Proof
N/A: there's no visible change. The flip happens only in windows that are never shown, lasts one frame and uses near-black.
Testing
On Windows 11 (session 0, packaged build, raw CDP, about 10–15 s idle):
ORCA_BACKGROUND_LAUNCH=1, main and the earlier invalidate version time out;This branch is being re-verified on the same Windows machine before merge.
On macOS: the hang doesn't reproduce here. To check the wiring, I temporarily enabled the gate for darwin and built. Through CDP I saw the root
styleattribute gainbackground-color: rgb(1, 1, 1)and then return to its exact prior value, about every 750 ms, and the screenshot returned in 29 ms. The gate was then restored towin32only.Unit tests (21 across 4 files, including the
createMainWindowsuite):Other checks: oxlint, the ast-grep gates and the changed-code gate pass.
pnpm tcreports only two errors already on main, in files this PR does not touch:agent-account-restart-startup.ts, fixed by #34203, anddoc-preview-external-link-confirmation.test.ts.AI Disclosure
Review
Agent skill upstream boundary
Notes
ORCA_BACKGROUND_LAUNCH=1is set only by short-lived preflights that never create the main window. The orcad browser sidecar usesORCA_ORCAD_SIDECARinstead and is deliberately out of scope. There's no SSH, mobile or wire impact.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)