Skip to content

fix(windows): make the GPU fallback actually remove the GPU child, and stop WSL latching absent - #11295

Merged
OrcaWin merged 4 commits into
mainfrom
OrcaWin/crash-win-07-28
Jul 31, 2026
Merged

OrcaWin merged 4 commits into
mainfrom
OrcaWin/crash-win-07-28

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Jul 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • After three crash-shaped Windows GPU-child failures in 30 seconds, Orca now asks before restarting in Safe Graphics Mode. The marker is written only after the user chooses the restart; Keep Running and prompt failures leave graphics settings unchanged.
  • Safe Graphics Mode uses --disable-gpu, --disable-software-rasterizer, and --in-process-gpu. This removes the GPU child and disables WebGL/SwiftShader, so terminals use their existing DOM renderer fallback instead of moving untrusted WebGL parsing into Orca's privileged main process.
  • WSL empty and failed distro probes now retry with bounded exponential backoff, ignore out-of-order stale results, and reconcile negative availability with successful distro discovery.
  • Long-lived local Windows UI consumers refresh negative/empty WSL capability state every 30 seconds until WSL and a user distro are both visible, so provisioning can recover without a remount or app restart.

Screenshots

No renderer layout changed. The native warning dialog now says Restart in Safe Graphics Mode and explains that hardware acceleration and WebGL are disabled for this Orca version and that terminals/3D content may render more slowly.

Testing

  • Windows 11, repo Electron 43.1.0 native probe:
    • baseline: GPU children=1, WebGL2=true
    • shipped fallback (disableHardwareAcceleration + --disable-gpu): GPU children=1, WebGL2=true
    • Safe Graphics Mode: GPU children=0, WebGL2=false
  • Native host WSL edge case reproduced: wsl.exe --status exits 0 while wsl.exe --list --quiet exits 0 with no user distro and NUL-padded output.
  • pnpm run typecheck — pass for node, CLI, and web projects.
  • Changed-file oxlint/type-aware lint — pass.
  • Max-lines ratchet — pass with no new bypasses.
  • Focused GPU, fallback-marker, prompt, WSL, capability-refresh, and terminal DOM-fallback suites — 9 files / 138 tests passed.
  • Full GitHub PR checks are required again for review commit e4ca7f7f7 before merge.

AI Review Report

Three independent review lenses covered GPU/Electron behavior and user awareness, WSL cache/concurrency semantics, and Windows validation/CI coverage. Findings fixed in the review commit:

  • hidden GPU fallback after Keep Running or a failed dialog;
  • SwiftShader/WebGL parsing moved into the privileged main process;
  • repeated distro-list failures bypassing backoff and concurrent failures shortening it;
  • older non-empty async distro results overwriting newer lifetime-stable results;
  • parallel availability/list probes publishing false with a newly discovered distro;
  • pull-only WSL TTLs leaving a long-lived TabBar stale indefinitely;
  • missing assertion for the switch list returned to crash breadcrumbs.

Cross-platform review: GPU fallback remains Windows desktop-only and is skipped for serve mode. WSL cache state remains owned by the process/host that executes WSL; SSH and folder-workspace routing are unchanged. Local automatic refresh is not installed for SSH-owned capability targets.

Security Audit

Safe Graphics Mode deliberately disables SwiftShader/WebGL because --in-process-gpu collapses the GPU-process boundary. This removes the largest renderer-controlled shader parsing surface from the privileged main process. Sandboxed browser guests remain sandboxed, and WebGL is unavailable globally in this rare post-crash mode.

Residual trade-off: Viz/software compositing still runs in-process, so a persistent compositor fault can terminate the main process. The mode is Windows-only, requires a matching build-scoped marker after explicit user consent, and automatically resets on an Orca or Electron version change.

Notes

The original production defect is verified: app.disableHardwareAcceleration() plus --disable-gpu changes the backend but does not remove Chromium's GPU child. The added in-process switch is therefore required to address process-targeted driver/DLL failures; disabling the software rasterizer keeps that emergency fallback conservative.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Windows GPU fallback now applies platform-specific switches through a reusable helper, records applied switches in crash breadcrumbs, and persists fallback state after restart selection. WSL distro and availability detection add shared parsing, retry backoff, concurrent-probe protection, structured cache handling, and expanded tests. Renderer terminal capability reads reconcile contradictory WSL results and periodically refresh eligible local consumers. Documentation updates describe the revised WSL cache semantics.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the two primary fixes: removing the GPU child in Windows fallback and preventing WSL from latching absent.
Description check ✅ Passed The description covers the required summary, screenshots note, testing, AI review, security audit, and platform-specific notes with relevant implementation details.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
src/main/wsl.ts (2)

327-333: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Narrow by discriminant instead of casting.

The cast assumes the remaining variant is the failure shape, but { available: false, unsupported: true } also reaches here when the platform re-check flips to win32. It happens to work (Date.now() - undefined is NaN, so freshness is false and a real probe runs), yet the correctness rests on NaN comparison semantics rather than the type.

♻️ Suggested narrowing
 function isWslAvailabilityCacheFresh(cache: WslAvailabilityCache): boolean {
   if (isPermanentWslAvailabilityCache(cache)) {
     return true
   }
-  const failed = cache as { cachedAt: number; retryable: boolean; failures: number }
-  return Date.now() - failed.cachedAt < wslAvailabilityRetryDelayMs(failed)
+  if (!('cachedAt' in cache)) {
+    return false
+  }
+  return Date.now() - cache.cachedAt < wslAvailabilityRetryDelayMs(cache)
 }

188-191: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Distro-list failures bypass the backoff that empty results get. Both catch paths arm a flat WSL_DISTRO_LIST_RETRY_DELAY_MS window and leave wslDistroListEmptyStreak untouched, so a persistently wedged wsl.exe is re-spawned every 15s for the whole session — the exact cost the empty-result doubling and wslAvailabilityRetryDelayMs were introduced to bound. Route both through the same streak/backoff arithmetic.

  • src/main/wsl.ts#L188-L191: replace the flat Date.now() + WSL_DISTRO_LIST_RETRY_DELAY_MS assignment with a shared helper that advances the streak and applies the capped doubling (this path is the blocking execFileSync on the main process, so it matters most).
  • src/main/wsl.ts#L211-L214: call the same helper instead of duplicating the flat-window assignment.
src/main/wsl.test.ts (1)

383-423: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract the repeated timeout-error fixture.

The spawnSync ETIMEDOUT object and its explanatory comment are duplicated four times in this suite (Lines 385-392, 409-416, 440-447, 493-499). A single wslProbeTimeoutError() factory keeps the shape in one place.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fec71321-3147-4ec1-b393-916da4761faf

📥 Commits

Reviewing files that changed from the base of the PR and between aeeae53 and e2002c4.

📒 Files selected for processing (6)
  • docs/agent-status-over-wsl.md
  • src/main/index.ts
  • src/main/startup/gpu-fallback-switches.test.ts
  • src/main/startup/gpu-fallback-switches.ts
  • src/main/wsl.test.ts
  • src/main/wsl.ts

Comment thread docs/agent-status-over-wsl.md Resolved
Comment thread src/main/wsl.ts
Comment on lines 188 to 191
} catch {
wslDistroListFailedUntilMs = Date.now() + WSL_DISTRO_LIST_FAILURE_TTL_MS
return []
wslDistroListRetryAfterMs = Date.now() + WSL_DISTRO_LIST_RETRY_DELAY_MS
return wslDistroCache ?? []
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Catch block can truncate a longer backoff window set by cacheWslDistroList

When listWslDistrosAsync is called concurrently without in-flight deduplication (acknowledged follow-up), the async catch path always writes Date.now() + WSL_DISTRO_LIST_RETRY_DELAY_MS (15 s) to wslDistroListRetryAfterMs, regardless of what value cacheWslDistroList may have just written. If the empty-streak backoff has grown beyond 15 s (e.g., wslDistroListEmptyStreak = 3 → 60 s window) and one concurrent probe resolves with an empty list while a sibling throws, the sibling's catch will overwrite the longer window with 15 s, causing an earlier re-probe than the backoff table prescribes. The practical effect is one extra blocking wsl.exe --list call on docker-desktop-only machines; the distro data itself remains correct. The same race exists in listWslDistros's catch block at line 189.

@greptile-apps

greptile-apps Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR fixes two independent Windows-only bugs: the GPU child process was not actually removed by the previous fallback (only its backend changed), and WSL availability/distro state was latched permanently on first failure, hiding WSL from the terminal picker after provisioning or a cold boot.

  • GPU Safe Graphics Mode: writeGpuFallbackMarker is moved to after user consent, so "Keep Running" and dialog errors leave graphics settings unchanged. Three new command-line switches (--disable-gpu, --disable-software-rasterizer, --in-process-gpu) replace the single old one; the last is the only switch that actually removes Chromium's GPU child process (confirmed by measurement on Electron 43.1.0).
  • WSL cache overhaul: Both the distro-list and availability caches now use bounded exponential backoff (15 s → 5 min and 45 s → 30 min) instead of process-lifetime latching. Probe sequence numbers prevent out-of-order async results from overwriting a newer non-empty list. A successful distro discovery clears a stale availability failure so getWslRepairReason doesn't report wsl-unavailable over a working WSL.
  • Renderer refresh: Long-lived local UI consumers gain a 30-second polling interval that fires until both wslAvailable and a non-empty distro list are confirmed, covering mid-session provisioning without a restart.

Confidence Score: 5/5

Safe to merge — both the GPU fallback and WSL cache fixes address real, measured production defects with targeted, well-tested changes.

The GPU fallback marker-ordering fix is structurally correct: marker write is gated behind explicit user consent and a successful file write, so neither Keep Running nor a dialog error can silently engage Safe Graphics Mode. The WSL cache refactor sequence-number scheme for out-of-order async probe results, the armWslDistroListRetry early-return guard preventing concurrent catches from shortening a longer backoff window, and dropStaleWslAvailabilityFailure clearing the availability latch on successful distro discovery all hold up under the test matrix of 138 cases. No logic errors or correctness gaps were found.

Files Needing Attention: No files require special attention. src/main/wsl.ts is the most intricate file (sequence numbers + two independent backoff tables) but is backed by the most thorough tests.

Important Files Changed

Filename Overview
src/main/wsl.ts Major refactor: distro-list and availability caches now use bounded exponential backoff instead of process-lifetime latching. Sequence numbers prevent out-of-order async probes from overwriting newer non-empty results. dropStaleWslAvailabilityFailure correctly reconciles a stale availability failure when a distro list succeeds.
src/main/index.ts Correct fix: writeGpuFallbackMarker now called only after user explicitly chooses restart, preventing the marker from being written on Keep Running or dialog errors. GPU fallback switches extracted to applyGpuFallbackCommandLineSwitches and applied switch names recorded in the crash breadcrumb.
src/main/startup/gpu-fallback-switches.ts New file extracting the three GPU fallback switches into a testable unit; Windows-only guard is correct. Return value enables the breadcrumb in index.ts.
src/renderer/src/lib/windows-terminal-capabilities.ts Adds a 30-second periodic refresh interval to the local-only path that fires until both wslAvailable and wslDistros.length > 0 are satisfied; interval is correctly cleared on unmount. SSH and remote targets are excluded.
src/renderer/src/lib/windows-terminal-capability-read.ts Adds reconcileWslAvailability to handle the race where the parallel availability probe read a stale negative while the distro probe succeeded; re-probes only when !available && distros.length > 0.
src/main/wsl-distro-retry.ts Tiny helper for the exponential-backoff formula (15s x 2^(streak-1), capped at 5 min). Extracted for testability.
src/main/wsl-distro-list-output.ts Extracted parseWslDistros (NUL-stripping + line splitting) and filterUserWslDistros (docker-desktop exclusion) from wsl.ts for independent testing.
src/main/crash-reporting/gpu-fallback-restart-prompt.ts Dialog text updated to Restart in Safe Graphics Mode with accurate description of what the mode disables; matched by the test.

Reviews (3): Last reviewed commit: "fix(wsl): make capability refresh cleanu..." | Re-trigger Greptile

OrcaWin added 2 commits July 29, 2026 17:36
…d stop WSL latching absent

Three Windows crash/regression fixes from shipped 1.4.156/1.4.158/1.4.159 crash reports.

GPU fallback (cluster D, 14 reports, exit 0x80000003 STATUS_BREAKPOINT):
the software-rendering fallback called disableHardwareAcceleration() plus
--disable-gpu, neither of which removes the GPU child process — Chromium still
spawns it to host Viz and merely drops the backend to software GL. Measured on
Windows 11 / Electron 43.1.0: gpuProcessCount stays 1. So a GPU process being
killed by a bad driver or an injected DLL kept dying after the fallback engaged,
on every launch, for the life of that build (the marker is sticky per version).
The crash tails show exactly this: gpu_fallback_applied followed by another GPU
crash 1.3s later. --in-process-gpu is the only switch that drops the child count
to 0; --disable-software-rasterizer is deliberately excluded because it also
kills SwiftShader, which would drop every terminal to the DOM renderer.

WSL distro list: a successful-but-empty `wsl --list --quiet` was cached for the
process lifetime. `wsl --install` reports zero distros while one is still
provisioning, so an early probe latched "no WSL" until restart — WSL appeared
during setup and then vanished from the terminal picker. Empty results now
re-probe on an exponential window (15s doubling to a 5min cap) while staying
readable, so a missing distro is still visible to isKnownMissingDistro.

WSL availability: isWslAvailable() latched false on any failure via a bare catch,
so one slow wsl.exe activation disabled WSL for the whole session. Failures are
now classified — a numeric exit status or ENOENT is answer-shaped and holds for
10min, anything else (timeout, spawn failure) retries after 45s — and both back
off per consecutive failure, mirroring isPwshAvailable.

Windows-only: every changed path is behind an existing process.platform check,
so macOS and Linux behaviour is unchanged.
…t succeeds

The distro-list and availability caches expire independently, and
getWslRepairReason checks availability first. So a definitive availability
failure (numeric exit status or ENOENT) held for 10-30min would keep reporting
`wsl-unavailable` even after `wsl --list --quiet` successfully returned a
distro — i.e. over a WSL that demonstrably just answered. That is the same
latch class this branch fixes, surviving in the gap between the two caches.

A non-empty distro list proves wsl.exe ran, so drop the negative availability
cache and let the next call re-probe. Scoped to non-empty lists only: those are
cached for the process lifetime, so this cannot re-spawn the blocking 5s probe
more than once. An empty list keeps its failure cache, since it re-probes on a
15s-to-5min schedule and would otherwise pay the blocking probe far too often.
@OrcaWin
OrcaWin force-pushed the OrcaWin/crash-win-07-28 branch from e2002c4 to 82288ea Compare July 30, 2026 00:37

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/wsl.ts (1)

161-211: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Consider in-flight dedupe for concurrent distro probes.

listWslDistros/listWslDistrosAsync spawn a new wsl.exe child process on every call once outside the retry window, with no shared in-flight promise — each concurrent caller (e.g. multiple owner-keyed renderer capability reads) triggers its own subprocess. The sequence-guard in cacheWslDistroList already handles the resulting out-of-order races correctly, but a shared in-flight promise (similar to pendingCapabilitiesByOwnerKey in windows-terminal-capabilities.ts) would avoid redundant subprocess spawns and simplify reasoning about overlapping probes.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f30f0611-5466-4b0d-94e5-232a0719289d

📥 Commits

Reviewing files that changed from the base of the PR and between 82288ea and 951901d.

📒 Files selected for processing (14)
  • config/tsconfig.tc.web.json
  • src/main/crash-reporting/gpu-fallback-restart-prompt.test.ts
  • src/main/crash-reporting/gpu-fallback-restart-prompt.ts
  • src/main/index.ts
  • src/main/startup/gpu-fallback-switches.test.ts
  • src/main/startup/gpu-fallback-switches.ts
  • src/main/wsl-distro-list-output.test.ts
  • src/main/wsl-distro-list-output.ts
  • src/main/wsl-distro-retry.ts
  • src/main/wsl.test.ts
  • src/main/wsl.ts
  • src/renderer/src/lib/windows-terminal-capabilities.test.ts
  • src/renderer/src/lib/windows-terminal-capabilities.ts
  • src/renderer/src/lib/windows-terminal-capability-read.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/renderer/src/lib/windows-terminal-capabilities.ts (1)

252-269: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Avoid allocating no-op intervals for remote consumers.

Every enabled hook creates a 30-second timer, even though remote, environment, and SSH consumers return immediately on every tick. Create the interval only for local targets without an SSH connection, and clear it conditionally during cleanup. This matches the PR objective that periodic refresh is limited to local WSL capability consumers.

Suggested adjustment
-    const refreshInterval = globalThis.setInterval(() => {
-      if (resolvedTarget.kind !== 'local' || sshConnectionIdKey) {
-        return
-      }
+    const refreshInterval =
+      resolvedTarget.kind === 'local' && !sshConnectionIdKey
+        ? globalThis.setInterval(() => {
       const cachedCapabilities = getCachedWindowsTerminalCapabilities(resolvedOwnerKey)
       if (cachedCapabilities.wslAvailable && cachedCapabilities.wslDistros.length > 0) {
         return
       }
       void loadWindowsTerminalCapabilities({
         ownerKey: resolvedOwnerKey,
         target: resolvedTarget,
         sshConnectionId: sshConnectionIdKey
       })
-    }, CAPABILITY_CACHE_TTL_MS)
+          }, CAPABILITY_CACHE_TTL_MS)
+        : undefined

-      globalThis.clearInterval(refreshInterval)
+      if (refreshInterval !== undefined) {
+        globalThis.clearInterval(refreshInterval)
+      }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 777c6efb-ca5e-4052-acc7-30ba054fb5d8

📥 Commits

Reviewing files that changed from the base of the PR and between 951901d and e4ca7f7.

📒 Files selected for processing (1)
  • src/renderer/src/lib/windows-terminal-capabilities.ts

@OrcaWin
OrcaWin merged commit 3b7ea59 into main Jul 31, 2026
42 checks passed
OrcaWin pushed a commit that referenced this pull request Aug 7, 2026
…robes

#11295 added a 30s renderer interval to `useWindowsTerminalCapabilities` whose
early-return only fires when WSL is available with at least one distro, so on the
common Windows host (no WSL) it re-ran a full capability read forever. Each read
IPCs four probes whose main-process handlers were synchronous `execFileSync` calls
to wsl.exe/pwsh.exe, blocking the Electron main event loop for up to 5s a time.

The un-latching intent is kept: a host that answers "no WSL" is still re-checked,
now on an exponential backoff (30s, +60s, +120s) that parks once the answer stops
moving, re-arms on window focus, is shared by all consumers of an owner key, and
stops entirely when the last consumer unmounts. The wsl/pwsh IPC handlers now use
async twins that share the existing caches and back off identically.
OrcaWin added a commit that referenced this pull request Aug 8, 2026
…exe probes (#11698)

* perf(windows): stop the capability poll respawning blocking wsl.exe probes

#11295 added a 30s renderer interval to `useWindowsTerminalCapabilities` whose
early-return only fires when WSL is available with at least one distro, so on the
common Windows host (no WSL) it re-ran a full capability read forever. Each read
IPCs four probes whose main-process handlers were synchronous `execFileSync` calls
to wsl.exe/pwsh.exe, blocking the Electron main event loop for up to 5s a time.

The un-latching intent is kept: a host that answers "no WSL" is still re-checked,
now on an exponential backoff (30s, +60s, +120s) that parks once the answer stops
moving, re-arms on window focus, is shared by all consumers of an owner key, and
stops entirely when the last consumer unmounts. The wsl/pwsh IPC handlers now use
async twins that share the existing caches and back off identically.

* fix(windows): classify async wsl/pwsh probe failures with the execFile error shape

The async twins feed `execFile` callback errors into classifiers written for
`execFileSync`: a non-zero exit lands on `error.code` as a number rather than
`error.status`, and a timeout is a SIGTERM kill rather than ETIMEDOUT.

So a Windows host without WSL (wsl.exe ships in System32, so it exits non-zero
instead of ENOENT) was cached as retryable, shrinking the shared window from
10min to 45s and making the still-sync callers re-pay their blocking spawn ~13x
more often; and a pwsh cold start past 5s cached "pwsh missing" for 30s,
demoting the user's PowerShell 7 preference — the exact case the ETIMEDOUT
branch exists to prevent.

Also drops a literal NUL byte from the new re-probe module's signature
separator, which made the file binary to git, and seeds `lastProbeAt` at
registration so focus churn right after mount cannot defer the first re-probe
indefinitely.

Co-authored-by: Orca <[email protected]>

* perf(windows): route relay host-capability probes through the async wsl/pwsh twins

A paired web/mobile client resolves `useWindowsTerminalCapabilities` to a local
target (TabBar's `isWebClient` gate, and `useSettingsNavigationMetadata` forces
`{kind:'local'}`), so the new re-probe arms there too. But `window.api.wsl/pwsh`
on a web client is not the ipc/app.ts channel — it is `host.wsl.*`/`host.pwsh.*`
over the runtime RPC, which still ran the sync probes and blocked the desktop
main event loop on `execFileSync('wsl.exe' | 'pwsh.exe')` for up to 5s per call.

Switch those handlers and the relay preflight capability probe to the async
twins added here; they share the same caches, dedupe and backoff, so remote
callers see no behavior change.

* fix(windows): harden async capability reprobes

* fix(windows): dedupe PowerShell shell probes

---------

Co-authored-by: Orca <[email protected]>
Co-authored-by: OrcaWin <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…d stop WSL latching absent (stablyai#11295)

* fix(windows): make the GPU fallback actually remove the GPU child, and stop WSL latching absent

Three Windows crash/regression fixes from shipped 1.4.156/1.4.158/1.4.159 crash reports.

GPU fallback (cluster D, 14 reports, exit 0x80000003 STATUS_BREAKPOINT):
the software-rendering fallback called disableHardwareAcceleration() plus
--disable-gpu, neither of which removes the GPU child process — Chromium still
spawns it to host Viz and merely drops the backend to software GL. Measured on
Windows 11 / Electron 43.1.0: gpuProcessCount stays 1. So a GPU process being
killed by a bad driver or an injected DLL kept dying after the fallback engaged,
on every launch, for the life of that build (the marker is sticky per version).
The crash tails show exactly this: gpu_fallback_applied followed by another GPU
crash 1.3s later. --in-process-gpu is the only switch that drops the child count
to 0; --disable-software-rasterizer is deliberately excluded because it also
kills SwiftShader, which would drop every terminal to the DOM renderer.

WSL distro list: a successful-but-empty `wsl --list --quiet` was cached for the
process lifetime. `wsl --install` reports zero distros while one is still
provisioning, so an early probe latched "no WSL" until restart — WSL appeared
during setup and then vanished from the terminal picker. Empty results now
re-probe on an exponential window (15s doubling to a 5min cap) while staying
readable, so a missing distro is still visible to isKnownMissingDistro.

WSL availability: isWslAvailable() latched false on any failure via a bare catch,
so one slow wsl.exe activation disabled WSL for the whole session. Failures are
now classified — a numeric exit status or ENOENT is answer-shaped and holds for
10min, anything else (timeout, spawn failure) retries after 45s — and both back
off per consecutive failure, mirroring isPwshAvailable.

Windows-only: every changed path is behind an existing process.platform check,
so macOS and Linux behaviour is unchanged.

* fix(windows): drop a stale WSL availability failure once a distro list succeeds

The distro-list and availability caches expire independently, and
getWslRepairReason checks availability first. So a definitive availability
failure (numeric exit status or ENOENT) held for 10-30min would keep reporting
`wsl-unavailable` even after `wsl --list --quiet` successfully returned a
distro — i.e. over a WSL that demonstrably just answered. That is the same
latch class this branch fixes, surviving in the gap between the two caches.

A non-empty distro list proves wsl.exe ran, so drop the negative availability
cache and let the next call re-probe. Scoped to non-empty lists only: those are
cached for the process lifetime, so this cannot re-spawn the blocking 5s probe
more than once. An empty list keeps its failure cache, since it re-probes on a
15s-to-5min schedule and would otherwise pay the blocking probe far too often.

* fix(windows): harden GPU safe mode and WSL recovery

* fix(wsl): make capability refresh cleanup explicit

---------

Co-authored-by: OrcaWin <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…exe probes (stablyai#11698)

* perf(windows): stop the capability poll respawning blocking wsl.exe probes

stablyai#11295 added a 30s renderer interval to `useWindowsTerminalCapabilities` whose
early-return only fires when WSL is available with at least one distro, so on the
common Windows host (no WSL) it re-ran a full capability read forever. Each read
IPCs four probes whose main-process handlers were synchronous `execFileSync` calls
to wsl.exe/pwsh.exe, blocking the Electron main event loop for up to 5s a time.

The un-latching intent is kept: a host that answers "no WSL" is still re-checked,
now on an exponential backoff (30s, +60s, +120s) that parks once the answer stops
moving, re-arms on window focus, is shared by all consumers of an owner key, and
stops entirely when the last consumer unmounts. The wsl/pwsh IPC handlers now use
async twins that share the existing caches and back off identically.

* fix(windows): classify async wsl/pwsh probe failures with the execFile error shape

The async twins feed `execFile` callback errors into classifiers written for
`execFileSync`: a non-zero exit lands on `error.code` as a number rather than
`error.status`, and a timeout is a SIGTERM kill rather than ETIMEDOUT.

So a Windows host without WSL (wsl.exe ships in System32, so it exits non-zero
instead of ENOENT) was cached as retryable, shrinking the shared window from
10min to 45s and making the still-sync callers re-pay their blocking spawn ~13x
more often; and a pwsh cold start past 5s cached "pwsh missing" for 30s,
demoting the user's PowerShell 7 preference — the exact case the ETIMEDOUT
branch exists to prevent.

Also drops a literal NUL byte from the new re-probe module's signature
separator, which made the file binary to git, and seeds `lastProbeAt` at
registration so focus churn right after mount cannot defer the first re-probe
indefinitely.

Co-authored-by: Orca <[email protected]>

* perf(windows): route relay host-capability probes through the async wsl/pwsh twins

A paired web/mobile client resolves `useWindowsTerminalCapabilities` to a local
target (TabBar's `isWebClient` gate, and `useSettingsNavigationMetadata` forces
`{kind:'local'}`), so the new re-probe arms there too. But `window.api.wsl/pwsh`
on a web client is not the ipc/app.ts channel — it is `host.wsl.*`/`host.pwsh.*`
over the runtime RPC, which still ran the sync probes and blocked the desktop
main event loop on `execFileSync('wsl.exe' | 'pwsh.exe')` for up to 5s per call.

Switch those handlers and the relay preflight capability probe to the async
twins added here; they share the same caches, dedupe and backoff, so remote
callers see no behavior change.

* fix(windows): harden async capability reprobes

* fix(windows): dedupe PowerShell shell probes

---------

Co-authored-by: Orca <[email protected]>
Co-authored-by: OrcaWin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant