Repository navigation
Improve Windows terminal performance: retain WebGL contexts, warm first ConPTY - #7085
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:
📝 WalkthroughWalkthroughChangesThis PR adds Windows-specific repro and benchmark tooling, plus main-process PTY and ConPTY updates and renderer WebGL retention changes. New scripts reproduce a terminal-activation hang across WSL and GPU modes and benchmark terminal interaction latency, with JSON outputs and recorded results. The main process now records PTY spawn timing, warms ConPTY on daemon startup, enables ConPTY DLL mode for Windows PTY spawns, and deduplicates PTY exit delivery. The renderer now retains suspended WebGL contexts on Windows, refreshes retained panes on resume, and releases WebGL resources through shared disposal logic. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 8
🧹 Nitpick comments (1)
src/renderer/src/lib/pane-manager/pane-webgl-renderer.ts (1)
18-28: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winAvoid relying on xterm-addon-webgl private renderer fields.
releaseXtermWebglContextreaches into_renderer._gl/_renderer._canvas, so an addon shape change turns this into a silent no-op because thecatchswallows the failure. Add a small runtime warning or fallback when those internals are absent so the context-release workaround doesn’t fail quietly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 341919c1-6938-4120-bf64-6c9b623bc2e3
📒 Files selected for processing (27)
config/scripts/repro-windows-apphang-terminal-activation.mjsconfig/scripts/windows-apphang-repro/apphang-report-summary.mjsconfig/scripts/windows-apphang-repro/electron-dev-session.mjsconfig/scripts/windows-apphang-repro/repro-timing.mjsconfig/scripts/windows-apphang-repro/terminal-activation-scenario.mjsconfig/scripts/windows-apphang-repro/wsl-workspace-fixture.mjsnotes/windows-perf-progress.mdsrc/main/daemon/daemon-entry.tssrc/main/daemon/windows-conpty-warmup.test.tssrc/main/daemon/windows-conpty-warmup.tssrc/main/ipc/pty-spawn-timing.tssrc/main/ipc/pty.test.tssrc/main/ipc/pty.tssrc/main/providers/local-pty-utils-windows-fallback.test.tssrc/main/providers/local-pty-utils.tssrc/renderer/src/lib/pane-manager/pane-lifecycle.tssrc/renderer/src/lib/pane-manager/pane-manager.tssrc/renderer/src/lib/pane-manager/pane-rendering-control.tssrc/renderer/src/lib/pane-manager/pane-webgl-context-retention.test.tssrc/renderer/src/lib/pane-manager/pane-webgl-context-retention.tssrc/renderer/src/lib/pane-manager/pane-webgl-refresh-lifecycle.test.tssrc/renderer/src/lib/pane-manager/pane-webgl-renderer.tstools/benchmarks/results/terminal-perf-baseline-2026-07-02T07-23-46-933Z.jsontools/benchmarks/results/terminal-perf-fix-a-b-2026-07-02T07-46-58-178Z.jsontools/benchmarks/results/terminal-perf-fix-abd-2026-07-02T07-51-00-936Z.jsontools/benchmarks/results/terminal-perf-fix-abdf-2026-07-02T07-59-11-820Z.jsontools/benchmarks/terminal-perf-bench.mjs
| export function createPtySpawnTiming(): PtySpawnTiming { | ||
| if (!process.env.ORCA_PTY_SPAWN_TIMING) { | ||
| return noopTiming | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Truthiness check accepts ORCA_PTY_SPAWN_TIMING=0 as enabled.
Any non-empty string enables timing, including "0"/"false", contradicting the documented =1 contract.
🔧 Proposed fix
export function createPtySpawnTiming(): PtySpawnTiming {
- if (!process.env.ORCA_PTY_SPAWN_TIMING) {
+ if (process.env.ORCA_PTY_SPAWN_TIMING !== '1') {
return noopTiming
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export function createPtySpawnTiming(): PtySpawnTiming { | |
| if (!process.env.ORCA_PTY_SPAWN_TIMING) { | |
| return noopTiming | |
| } | |
| export function createPtySpawnTiming(): PtySpawnTiming { | |
| if (process.env.ORCA_PTY_SPAWN_TIMING !== '1') { | |
| return noopTiming | |
| } |
e5abd97 to
c6a77ab
Compare
|
Addressed all 8 review comments in c6a77aba6 (branch also rebased onto latest main):
One transient-failure branch in controller |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
src/main/ipc/pty.test.ts (1)
2389-2391: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winPossible flakiness: double
Promise.resolve()vs.setImmediatepattern used elsewhere.The line-range summary explains that a sibling test (Line 2334-2336) needed to switch from a single microtask flush to
setImmediatebecause kill's shutdown now runs through the exit-detection wrapper, which adds async hops; a single microtask flush is no longer enough. This new test relies on exactly twoawait Promise.resolve()calls, which is fragile if the number of async hops in the kill/shutdown/dedup chain changes again (e.g.shutdownProviderAndDetectExit'stry/finallyplus the.then()callback inkill()). Consider usingawait new Promise((resolve) => setImmediate(resolve))here as well for consistency and robustness.Suggested fix
expect(controller.kill('local-pty')).toBe(true) - await Promise.resolve() - await Promise.resolve() + await new Promise((resolve) => setImmediate(resolve))
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: d9cd742b-89fa-4504-b652-79099d4d4c32
📥 Commits
Reviewing files that changed from the base of the PR and between e5abd97 and c6a77aba61703e09836b08c4e6330278aa0c104e.
📒 Files selected for processing (27)
config/scripts/repro-windows-apphang-terminal-activation.mjsconfig/scripts/windows-apphang-repro/apphang-report-summary.mjsconfig/scripts/windows-apphang-repro/electron-dev-session.mjsconfig/scripts/windows-apphang-repro/repro-timing.mjsconfig/scripts/windows-apphang-repro/terminal-activation-scenario.mjsconfig/scripts/windows-apphang-repro/wsl-workspace-fixture.mjsnotes/windows-perf-progress.mdsrc/main/daemon/daemon-entry.tssrc/main/daemon/windows-conpty-warmup.test.tssrc/main/daemon/windows-conpty-warmup.tssrc/main/ipc/pty-spawn-timing.tssrc/main/ipc/pty.test.tssrc/main/ipc/pty.tssrc/main/providers/local-pty-utils-windows-fallback.test.tssrc/main/providers/local-pty-utils.tssrc/renderer/src/lib/pane-manager/pane-lifecycle.tssrc/renderer/src/lib/pane-manager/pane-manager.tssrc/renderer/src/lib/pane-manager/pane-rendering-control.tssrc/renderer/src/lib/pane-manager/pane-webgl-context-retention.test.tssrc/renderer/src/lib/pane-manager/pane-webgl-context-retention.tssrc/renderer/src/lib/pane-manager/pane-webgl-refresh-lifecycle.test.tssrc/renderer/src/lib/pane-manager/pane-webgl-renderer.tstools/benchmarks/results/terminal-perf-baseline-2026-07-02T07-23-46-933Z.jsontools/benchmarks/results/terminal-perf-fix-a-b-2026-07-02T07-46-58-178Z.jsontools/benchmarks/results/terminal-perf-fix-abd-2026-07-02T07-51-00-936Z.jsontools/benchmarks/results/terminal-perf-fix-abdf-2026-07-02T07-59-11-820Z.jsontools/benchmarks/terminal-perf-bench.mjs
✅ Files skipped from review due to trivial changes (2)
- src/main/providers/local-pty-utils-windows-fallback.test.ts
- tools/benchmarks/results/terminal-perf-baseline-2026-07-02T07-23-46-933Z.json
🚧 Files skipped from review as they are similar to previous changes (18)
- src/renderer/src/lib/pane-manager/pane-webgl-refresh-lifecycle.test.ts
- src/renderer/src/lib/pane-manager/pane-lifecycle.ts
- src/main/providers/local-pty-utils.ts
- src/main/ipc/pty-spawn-timing.ts
- src/renderer/src/lib/pane-manager/pane-manager.ts
- src/main/daemon/windows-conpty-warmup.test.ts
- src/main/daemon/windows-conpty-warmup.ts
- config/scripts/windows-apphang-repro/apphang-report-summary.mjs
- src/renderer/src/lib/pane-manager/pane-rendering-control.ts
- src/renderer/src/lib/pane-manager/pane-webgl-context-retention.ts
- src/main/daemon/daemon-entry.ts
- tools/benchmarks/terminal-perf-bench.mjs
- src/renderer/src/lib/pane-manager/pane-webgl-renderer.ts
- config/scripts/windows-apphang-repro/electron-dev-session.mjs
- config/scripts/windows-apphang-repro/terminal-activation-scenario.mjs
- config/scripts/windows-apphang-repro/wsl-workspace-fixture.mjs
- src/renderer/src/lib/pane-manager/pane-webgl-context-retention.test.ts
- src/main/ipc/pty.ts
| args.deadPtyReactivate = false | ||
| continue | ||
| } | ||
| const [name, value] = arg.split('=', 2) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Locate the target file and inspect the relevant section.
git ls-files 'config/scripts/repro-windows-apphang-terminal-activation.mjs'
wc -l config/scripts/repro-windows-apphang-terminal-activation.mjs
cat -n config/scripts/repro-windows-apphang-terminal-activation.mjs | sed -n '1,130p'
# Probe the actual split semantics on representative inputs.
node - <<'JS'
const samples = [
'--report=C:\\path\\run=1.json',
'--distro=foo=bar',
'--name=value',
'--flag'
];
for (const arg of samples) {
const [name, value] = arg.split('=', 2);
const eqIndex = arg.indexOf('=');
const value2 = eqIndex === -1 ? undefined : arg.slice(eqIndex + 1);
console.log({ arg, splitName: name, splitValue: value, firstEqValue: value2 });
}
JSRepository: stablyai/orca
Length of output: 5940
arg.split('=', 2) truncates values containing =.
String.prototype.split(separator, limit) drops the remainder once the limit is reached, so --report=C:\path\run=1.json or --distro=foo=bar loses everything after the first = in the value. Split on the first = instead.
| "worktreeId": "62e7f2fd-6fb6-446e-bded-2866c26a968e::C:/Users/jinwo/AppData/Local/Temp/orca-termperf-rrZN7p/repo", | ||
| "ptyId": "62e7f2fd-6fb6-446e-bded-2866c26a968e::C:/Users/jinwo/AppData/Local/Temp/orca-termperf-rrZN7p/repo@@588e69ce", | ||
| "activationMs": 240, | ||
| "ptyBindMs": 247, | ||
| "paintSettleMs": 254 | ||
| }, | ||
| { | ||
| "index": 1, | ||
| "worktreeId": "62e7f2fd-6fb6-446e-bded-2866c26a968e::C:/Users/jinwo/AppData/Local/Temp/orca-termperf-rrZN7p/wt-one", | ||
| "ptyId": "62e7f2fd-6fb6-446e-bded-2866c26a968e::C:/Users/jinwo/AppData/Local/Temp/orca-termperf-rrZN7p/wt-one@@407494c8", | ||
| "activationMs": 423, | ||
| "ptyBindMs": 573, | ||
| "paintSettleMs": 584 | ||
| }, | ||
| { | ||
| "index": 2, | ||
| "worktreeId": "62e7f2fd-6fb6-446e-bded-2866c26a968e::C:/Users/jinwo/AppData/Local/Temp/orca-termperf-rrZN7p/wt-two", | ||
| "ptyId": "62e7f2fd-6fb6-446e-bded-2866c26a968e::C:/Users/jinwo/AppData/Local/Temp/orca-termperf-rrZN7p/wt-two@@5d681b07", |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Redact machine-specific paths before committing benchmark artifacts.
This file embeds C:/Users/jinwo/... in sample data and logs, which leaks a local username/temp workspace layout and makes the artifact non-portable. Please normalize or redact these values across the whole file.
| "worktreeId": "f5b2567a-69b4-41a3-ba29-8c4bd357042d::C:/Users/jinwo/AppData/Local/Temp/orca-termperf-J3tKUm/repo", | ||
| "ptyId": "f5b2567a-69b4-41a3-ba29-8c4bd357042d::C:/Users/jinwo/AppData/Local/Temp/orca-termperf-J3tKUm/repo@@14096c3d", | ||
| "activationMs": 281, | ||
| "ptyBindMs": 283, | ||
| "paintSettleMs": 293 | ||
| }, | ||
| { | ||
| "index": 1, | ||
| "worktreeId": "f5b2567a-69b4-41a3-ba29-8c4bd357042d::C:/Users/jinwo/AppData/Local/Temp/orca-termperf-J3tKUm/wt-one", | ||
| "ptyId": "f5b2567a-69b4-41a3-ba29-8c4bd357042d::C:/Users/jinwo/AppData/Local/Temp/orca-termperf-J3tKUm/wt-one@@0b21e66f", | ||
| "activationMs": 344, | ||
| "ptyBindMs": 524, | ||
| "paintSettleMs": 538 | ||
| }, | ||
| { | ||
| "index": 2, | ||
| "worktreeId": "f5b2567a-69b4-41a3-ba29-8c4bd357042d::C:/Users/jinwo/AppData/Local/Temp/orca-termperf-J3tKUm/wt-two", | ||
| "ptyId": "f5b2567a-69b4-41a3-ba29-8c4bd357042d::C:/Users/jinwo/AppData/Local/Temp/orca-termperf-J3tKUm/wt-two@@e63f448f", |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Redact machine-specific paths before committing benchmark artifacts.
This file embeds C:/Users/jinwo/... in sample data and logs, which leaks a local username/temp workspace layout and makes the artifact non-portable. Please normalize or redact these values across the whole file.
| "worktreeId": "cd78ddb3-9689-4d21-b87b-8e38f92d2e7b::C:/Users/jinwo/AppData/Local/Temp/orca-termperf-IyoYoT/repo", | ||
| "ptyId": "cd78ddb3-9689-4d21-b87b-8e38f92d2e7b::C:/Users/jinwo/AppData/Local/Temp/orca-termperf-IyoYoT/repo@@5810ae88", | ||
| "activationMs": 217, | ||
| "ptyBindMs": 219, | ||
| "paintSettleMs": 233 | ||
| }, | ||
| { | ||
| "index": 1, | ||
| "worktreeId": "cd78ddb3-9689-4d21-b87b-8e38f92d2e7b::C:/Users/jinwo/AppData/Local/Temp/orca-termperf-IyoYoT/wt-one", | ||
| "ptyId": "cd78ddb3-9689-4d21-b87b-8e38f92d2e7b::C:/Users/jinwo/AppData/Local/Temp/orca-termperf-IyoYoT/wt-one@@c450cf26", | ||
| "activationMs": 480, | ||
| "ptyBindMs": 575, | ||
| "paintSettleMs": 601 | ||
| }, | ||
| { | ||
| "index": 2, | ||
| "worktreeId": "cd78ddb3-9689-4d21-b87b-8e38f92d2e7b::C:/Users/jinwo/AppData/Local/Temp/orca-termperf-IyoYoT/wt-two", | ||
| "ptyId": "cd78ddb3-9689-4d21-b87b-8e38f92d2e7b::C:/Users/jinwo/AppData/Local/Temp/orca-termperf-IyoYoT/wt-two@@ae6fdb06", |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Redact machine-specific paths before committing benchmark artifacts.
This file embeds C:/Users/jinwo/... in sample data and logs, which leaks a local username/temp workspace layout and makes the artifact non-portable. Please normalize or redact these values across the whole file.
Workspace switches disposed every hidden pane's WebGL context and recreated it on return - ~5ms on macOS but 100-500ms per pane on Windows (ANGLE -> D3D11), paid synchronously on the switch path. The dispose-on-hide policy guarded Chromium's old 16-context budget, which #7064 raised to 128. Suspended panes now keep their live contexts in an LRU (cap 16, evicted panes disposed); resume repaints retained panes instead of recreating contexts. Atlas recovery bursts skip suspended panes so recovery cost scales with visible panes, not total pane count across workspaces.
The daemon spawn path already passes useConptyDll: true (bundled modern ConPTY); LocalPtyProvider spawns - degraded mode and fresh-local routing - silently ran on the legacy system ConPTY, which the daemon path's own comment blames for full-width TUI scrollback corruption.
The first ConPTY spawn in the daemon process pays one-time costs (conpty native module load, bundled conpty.dll + OpenConsole.exe first launch, Defender scans) measured at ~2.7s inside provider.spawn on a dev profile vs ~70ms warm - previously paid by the user's first terminal. A throwaway cmd.exe /c exit spawn at daemon boot absorbs it off the interaction path.
ORCA_PTY_SPAWN_TIMING=1 logs one line per spawn attributing latency to startup barrier, Claude auth prep, buildPtyHostEnv, options assembly, and provider spawn - the split that separated renderer-side cost from daemon cost in the terminal perf investigation.
CDP-driven harness measuring tab creation, tab switching, and workspace switching against the real dev app with renderer-clock phase timings (store -> PTY bind -> first output -> paint settle), longtask counts, and WebGL context diagnostics. Reuses the windows-apphang-repro session helpers; records ORCA_PTY_SPAWN_TIMING attribution when enabled.
Documents the cold-restore spawn fan-out point (renderer connect layer), the daemon-init barrier's effect on an immediate first terminal, the uncached in-daemon Windows shell resolution, and residual tab-switch costs, so the follow-up work starts from measured locations.
Context re-creation is ~5ms on macOS/Linux GL, so retention buys no perceptible switch latency there while still costing hidden-pane GPU memory and a new lifecycle to reason about. Only Windows (ANGLE -> D3D11, 100-500ms per pane) retains; other platforms keep the long-proven dispose-on-hide behavior.
- Runtime controller kill/stopAndWait now use the same synthetic-exit detection as the renderer pty:kill handler, so providers that emit their own exit during shutdown no longer double-fire runtime.onPtyExit, and silent shutdowns now notify the renderer on these paths too. - Repro harness: reset the renderer drift probe per activation cycle (cumulative drift misattributed startup stalls to later cycles), classify harness failures as inconclusive harnessError instead of reproduced, opt the disposable profile out of telemetry, and build the dev-runner path with path.join. - Benchmark: exclude timed-out samples from percentile stats, initialize the report before launch, and keep a stopDevApp failure from skipping report write and temp-dir cleanup. - ORCA_PTY_SPAWN_TIMING now treats 0/false as disabled.
Reported real-world usage runs 10+ worktrees with ~2 terminals each, so a cap of 16 evicts inside the active switching set and returns to those worktrees pay the context rebuild the retention exists to avoid. 32 covers ~10-16 worktrees x 2 panes (~100-250MB worst-case hidden framebuffers) while staying far under the 128 context budget.
08614c0 to
37f7051
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (3)
tools/benchmarks/results/terminal-perf-fix-a-b-2026-07-02T07-46-58-178Z.json (1)
285-377: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick winRedact machine-specific paths before committing benchmark artifacts.
This artifact still embeds
C:/Users/jinwo/...in IDs and logs, which leaks a local username/temp layout and makes the report non-portable. Please normalize or redact these values throughout the file.tools/benchmarks/results/terminal-perf-fix-abd-2026-07-02T07-51-00-936Z.json (1)
285-377: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick winRedact machine-specific paths before committing benchmark artifacts.
This artifact still embeds
C:/Users/jinwo/...in IDs and logs, which leaks a local username/temp layout and makes the report non-portable. Please normalize or redact these values throughout the file.tools/benchmarks/results/terminal-perf-fix-abdf-2026-07-02T07-59-11-820Z.json (1)
285-377: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick winRedact machine-specific paths before committing benchmark artifacts.
This artifact still embeds
C:/Users/jinwo/...in IDs and logs, which leaks a local username/temp layout and makes the report non-portable. Please normalize or redact these values throughout the file.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 86a1be97-8329-498e-9aa7-d29e503e5cf8
📥 Commits
Reviewing files that changed from the base of the PR and between 08614c018b05615367df6f84154de639e04b8ea4 and 37f7051.
📒 Files selected for processing (27)
config/scripts/repro-windows-apphang-terminal-activation.mjsconfig/scripts/windows-apphang-repro/apphang-report-summary.mjsconfig/scripts/windows-apphang-repro/electron-dev-session.mjsconfig/scripts/windows-apphang-repro/repro-timing.mjsconfig/scripts/windows-apphang-repro/terminal-activation-scenario.mjsconfig/scripts/windows-apphang-repro/wsl-workspace-fixture.mjsnotes/windows-perf-progress.mdsrc/main/daemon/daemon-entry.tssrc/main/daemon/windows-conpty-warmup.test.tssrc/main/daemon/windows-conpty-warmup.tssrc/main/ipc/pty-spawn-timing.tssrc/main/ipc/pty.test.tssrc/main/ipc/pty.tssrc/main/providers/local-pty-utils-windows-fallback.test.tssrc/main/providers/local-pty-utils.tssrc/renderer/src/lib/pane-manager/pane-lifecycle.tssrc/renderer/src/lib/pane-manager/pane-manager.tssrc/renderer/src/lib/pane-manager/pane-rendering-control.tssrc/renderer/src/lib/pane-manager/pane-webgl-context-retention.test.tssrc/renderer/src/lib/pane-manager/pane-webgl-context-retention.tssrc/renderer/src/lib/pane-manager/pane-webgl-refresh-lifecycle.test.tssrc/renderer/src/lib/pane-manager/pane-webgl-renderer.tstools/benchmarks/results/terminal-perf-baseline-2026-07-02T07-23-46-933Z.jsontools/benchmarks/results/terminal-perf-fix-a-b-2026-07-02T07-46-58-178Z.jsontools/benchmarks/results/terminal-perf-fix-abd-2026-07-02T07-51-00-936Z.jsontools/benchmarks/results/terminal-perf-fix-abdf-2026-07-02T07-59-11-820Z.jsontools/benchmarks/terminal-perf-bench.mjs
✅ Files skipped from review due to trivial changes (1)
- tools/benchmarks/results/terminal-perf-baseline-2026-07-02T07-23-46-933Z.json
🚧 Files skipped from review as they are similar to previous changes (21)
- src/renderer/src/lib/pane-manager/pane-manager.ts
- src/main/daemon/daemon-entry.ts
- src/main/ipc/pty-spawn-timing.ts
- src/main/daemon/windows-conpty-warmup.ts
- src/renderer/src/lib/pane-manager/pane-webgl-context-retention.ts
- src/main/providers/local-pty-utils.ts
- src/renderer/src/lib/pane-manager/pane-lifecycle.ts
- src/main/daemon/windows-conpty-warmup.test.ts
- src/main/providers/local-pty-utils-windows-fallback.test.ts
- tools/benchmarks/terminal-perf-bench.mjs
- src/renderer/src/lib/pane-manager/pane-webgl-renderer.ts
- src/renderer/src/lib/pane-manager/pane-webgl-refresh-lifecycle.test.ts
- config/scripts/windows-apphang-repro/repro-timing.mjs
- config/scripts/repro-windows-apphang-terminal-activation.mjs
- src/renderer/src/lib/pane-manager/pane-rendering-control.ts
- config/scripts/windows-apphang-repro/electron-dev-session.mjs
- config/scripts/windows-apphang-repro/wsl-workspace-fixture.mjs
- config/scripts/windows-apphang-repro/terminal-activation-scenario.mjs
- src/renderer/src/lib/pane-manager/pane-webgl-context-retention.test.ts
- src/main/ipc/pty.test.ts
- src/main/ipc/pty.ts
Summary
Windows terminal interactions (workspace switching, terminal creation, tab switching) are noticeably slower than macOS, and #6874-style hangs were reported around terminal activation. This PR benchmarks the gaps, fixes the highest-impact Windows-specific costs, and supersedes #7080 (its commits are merged in here).
No WebGL disabling anywhere — every fix keeps GPU rendering and addresses the actual waste.
What's included
From #7080 (merged in, unchanged): eager WebGL context release on pane disposal,
pty:killsynthesizingpty:exitwhen provider shutdown is silent (stale-terminal recovery), and the Windows/WSL AppHang repro harness.New in this branch:
Retain terminal WebGL contexts across workspace hide/show (
pane-webgl-context-retention.ts)Workspace switches disposed every hidden pane's WebGL context and recreated it on return — ~5ms on macOS but 100–500ms per pane on Windows (ANGLE → D3D11), paid synchronously on the switch path (the old code comment admitted this). The dispose-on-hide policy guarded Chromium's 16-context budget, which Raise WebGL terminal context budget and recover from context loss #7064 raised to 128, so the premise is stale. Suspended panes now keep live contexts in an LRU (cap 32, sized for ~10–16 worktrees × ~2 terminals hot sets; evictions disposed through the Fix terminal activation WebGL cleanup and stale PTY recovery #7080 release path); resume repaints instead of recreating. Atlas-recovery bursts now skip suspended panes, so recovery cost scales with visible panes instead of total panes across all workspaces. Retention is gated to Windows (runtime platform check): context creation is ~5ms on macOS/Linux GL, so those platforms keep the long-proven dispose-on-hide behavior and pay no retention GPU-memory cost. The atlas-recovery scoping applies on all platforms.
Bundled ConPTY for LocalPtyProvider spawns (
local-pty-utils.ts)The daemon spawn path passes
useConptyDll: true; degraded-mode/fresh-local spawns silently ran on the legacy system ConPTY (which the daemon path's own comment blames for full-width TUI scrollback corruption). Now consistent.Warm the daemon's first ConPTY at boot (
windows-conpty-warmup.ts)The first ConPTY spawn in the daemon pays one-time costs (conpty native module load, bundled conpty.dll + OpenConsole.exe first launch, Defender scans): measured 2.75s inside
provider.spawnvs ~70ms warm — previously paid by the user's first terminal. A throwawaycmd.exe /c exitat daemon boot absorbs it.Measurement infrastructure
tools/benchmarks/terminal-perf-bench.mjs: CDP-driven benchmark of tab-create / tab-switch / workspace-switch with renderer-clock phase timings (store → PTY bind → first output → paint settle), longtask counts, WebGL context diagnostics.ORCA_PTY_SPAWN_TIMING=1: one log line perpty:spawnattributing latency to barrier/auth/host-env/provider phases (pty-spawn-timing.ts).Measurements (Windows 11, dev build, JSON reports in tools/benchmarks/results/)
provider_spawn(cold daemon)¹ The benchmark opens a terminal ~1s after app-ready, so the real spawn still queues behind the in-flight warm-up; with a realistic gap the cost is fully absorbed. Workspace-switch gains scale with panes-per-worktree and GPU slowness; the fixture is 1 pane/worktree on a fast GPU.
Spawn-phase attribution also shows steady-state tab-create (~500ms) is dominated by renderer-side work (xterm open + WebGL context creation for the new pane), not the PTY path — see follow-ups.
Follow-ups (documented in notes/windows-perf-progress.md)
Verification
pnpm exec vitest runon pane-manager (317), terminal-pane (1421), providers + daemon suites, focused pty kill/exit tests — all pass.pnpm run typecheck,oxlinton changed files — clean.src/main/ipc/pty.test.ts, 1 WSL env-import test inpty-subprocess.test.ts.Supersedes #7080. Refs #6874.