Your App Feels Awful on Windows (And the MacBook Blind Spots Killing It)
Chasing Windows startup stalls got my shader-cache fix merged into Electron itself, shaving ~400 ms off repeat launches in our Windows demo. Too bad everyone is about to rewrite to native on Rune anyway.
Most dev tools get built on MacBooks (especially in SF and startups). Windows gets a green CI check and shipped. Subsystem costs do not scale the same on Windows as macOS or Linux: what is free on a MacBook Air can stall a $6,000 Windows laptop for 5 seconds.
Notes from 154 public PRs (136 merged) across Electron, OpenCode, Rune, Cap, Hex, Bun, and Strobe. Exact numbers, no fluff.
Want to make your app faster on Windows? Paste this into your coding agent:
Read https://lukeparker.dev/your-app-feels-awful-on-windows/ and audit this repo for every Windows performance and reliability issue it covers (Defender, NTFS, GPU/VRAM, timers, tray/occlusion, process spawns, updates, Win32). Fix the highest-impact issues in focused PRs using quick single-run before/after sanity checks on Windows (ideally via Strobe: https://github.com/anomalyco/strobe; skip full interleaved paired runs during the sweep so it finishes fast). When done, report the total PR count, a markdown table with one row per PR and columns PR, Metrics, Before, and After (stacking every metric moved by a PR on separate lines inside its Metrics, Before, and After cells), and the Strobe command to run full paired benchmarks afterward for rigorous final numbers.Also try this (I tack it onto most of my work):
For each PR as it is ready for review, ask opus 5.5 high and gemini 4 neon high to review. action any findings, then Merge.Scoreboard
Different apps, machines, and workloads. Each row is one controlled comparison.
| Bottleneck | Before | After | PR |
|---|---|---|---|
| New-build first frame (Defender) | 5,542 ms | 1,768 ms split / 184-321 ms seen launcher | opencode-rune#953, #969 |
Post-install --version (dirty cache) | 1,330-1,454 ms | 17-24 ms | opencode-rune#997 |
| Tab close sync storage (8 ops) | 41.88 ms med | 9 µs med | opencode#47695 |
| WGSL composite pipeline (FXC -> DXC) | 26,207 ms (5-run mean) | 255 ms (102.9x) | Cap#2135 |
| Electron Skia shader demo | baseline (~480 ms GPU compile) | ~400 ms sooner (repeat) | electron#54113 |
| Tray idle (display GPU) | 584 MB private / 203 wakes/s | 229 MB / 74 wakes/s | hex#1223 |
Tray idle (drop ID3D12Device) | 229 MB / 219 MB VRAM / 71/s | 51 MB / 0 MB VRAM / 7/s | hex#1229 |
| Hybrid GPU adapter select | 1,065 ms med | 54 ms med | rune#625 |
| MP4 export (15.6 ms timer) | 99.5-99.9 s (55 fps enc) | 30.9-31.2 s (224 fps enc) | Cap#2439 |
| MP4 readback yield-spin | 21.1-21.9 s (259 fps / 87% NVENC) | 19.8-20.5 s (294 fps / 97% NVENC) | Cap#2450 |
| Camera poll growth (60 runs) | +53 thr / +3,858 hnd / +49 MB | 0 growth | Cap#2143 |
| Untracked diff (257 files) | 28.4-34.0 s (783 git) | 0.34-0.36 s (17 git) | opencode#53449 |
| App update restart (closed) | 11.8 s | 1.4 s | opencode#55933 |
| Binary delta update (x64) | 68.75 MB full ZIP | 13.75 MB delta (-80%) | opencode-rune#1748 |
| Own-process thread walk (per walk) | 58-66 ms | 0.01-0.13 ms | rune#806 |
| Occluded debug spinner CPU | 955 ms/s | 0-3 ms/s | rune#570 |
Defender
- 0.35 MiB
/Breprothin.exe+.dll: A single 163 MiB signed exe took 5,542 ms to first frame on my laptop (separate signed-EXE probe: 6,451 ms insideCreateProcessW, 5,516 ms Defender CPU). Loading a fresh 160 MiB.dlltook 137-220 ms wall and 0 ms observed Defender CPU. Splitting into a 0.35 MiB launcher linked with/Brepro+ static1.0.0version resource (reproducible bytes when launcher inputs stay unchanged) cut CI first frame 5,542 → 1,768 ms, and 184-321 ms across 4 launches with a previously seen launcher. Signed updates and SmartScreen were not tested (opencode-rune#953, #969). - Warm Defender with
CREATE_SUSPENDED: In our installer simulation, spawningCREATE_SUSPENDED | CREATE_NO_WINDOWand terminating during a 1.5 s completion pause moved Defender work off the next click: first frame 525 → 49 ms median (10 pairs). Reading or memory-mapping the file did not warm it in our tests (opencode-rune#877, #876). - No sync temp-file renames on UI threads:
electron-storewrites a temp file and callsrename(). A sharing conflict with Defender or Windows Search Indexer makesstubborn-fsspin up to 1,000 ms per failed write (3-5 s tab-close freezes). Queuing 8 storage ops to write-behind SQLite WAL cut main-thread median 41.88 ms → 9 µs; disk commit happens asynchronously (opencode#47695). - Close partial DLL downloads before
ExitProcess: Leaving a half-writtenlibcef.dll(295 MB full) open at exit pushed cleanup into kernel teardown (ExSweepHandleTable → MpScanFile), burning 6.45 s off-CPU in one trace. Cancelling and waiting for close cut next-build first frame 2,032 → 224 ms median across 6 quits/build (opencode-rune#1072). - Benchmark signed downloads in a normally scanned folder: An excluded dev checkout hides multi-second stalls users hit on release day.
GPU & VRAM
- Bundle DXC for
wgpuDX12: Cap'swgpuDX12 path defaulted to legacy FXC (d3dcompiler_47.dll). Bundling Microsoft DXC cut composite pipeline creation from 26,207 → 255 ms (5-run mean, 102.9x, RTX 3080 Ti Laptop, zero WGSL changes; Cap#2135). - Electron was dropping all Skia shaders:
ElectronBrowserClientnever implementedGetGrShaderDiskCacheDirectory(), causing 31/31GrShaderCachemisses and ~480 ms of GPU-threadD3DCompileon Iris Xe ANGLE/D3D11. Fixed upstream in 37 lines (~400 ms sooner repeat launch in our demo once apps ship the fixed Electron; electron#54113). - Do not draw on a display-less iGPU: Three hidden swapchains on my display-less AMD iGPU forced cross-adapter presentation and spawned 111 NVIDIA threads (37/swapchain). Picking a display-driving GPU plus smaller wgpu allocation blocks cut Hex 584 → 229 MB private and 203 → 74 wakes/s (hex#1223).
- Drop
ID3D12Deviceat rest in tray apps: On an RTX 5070 Ti with zero swapchains, a bareID3D12Deviceprobe process jumped 3 → 71 MB private and 0 → 64.7 wakes/s in NVIDIA driver threads. Prewarming on hotkey-down and dropping the HUD device after 5 idle minutes cut Hex 229 → 51 MB private, 219 → 0 MB VRAM, and 71 → 7 wakes/s (hex#1229). - Do not wake Optimus dGPUs during adapter enumeration: Our
wgpu-halDX12enumerate_adapters()initialized every candidate, waking the sleeping NVIDIA GPU and loading software WARP. Inspecting DXGI descriptions first (keeping user overrides and a present fallback) cut adapter pick 1,065 → 54 ms and first frame 1,217 → 205 ms (10-launch medians, Iris Xe + 3080 Ti Laptop; rune#625). - CPU-first boot + D3D12 shader prewarm: Paint opaque frame 1 via GDI DIB before GPU init (rune#689); prewarming D3D12's SQLite shader cache cut CPU-to-GPU handover 1,103-2,092 → 139-145 ms in our warm-up test (opencode-rune#922).
- Size descriptor heaps per device: Lowering
max_non_sampler_bindingsfrom 1M to 65,536 saved 57 MB private in a one-window probe (measured peak use before cutting to 4,096; rune#674, #1014). Rune also serialized three DXBC pipeline-creation calls to work around a crash indxilconv.dll101.9.2602.1360 (rune#2441).
Timers & Tray
- Windows ~15.6 ms wait floor:
sleep(100 µs)in Cap's GPU readback loop quantized to ~15.6 ms, capping a 1572x1080 MP4 export at 55 fps encoder throughput (99.5-99.9 s). ScopingtimeBeginPeriod(1)/timeEndPeriod(1)to export dropped it to 30.9-31.2 s (224 fps; Cap#2439). On a later 2096x1440 test with separate audio encoding (Cap#2448), bounded yield-spin readbacks cut 21.1-21.9 → 19.8-20.5 s (256-259 → 289-294 fps, 84-87% → 95-97% NVENC; Cap#2450). In OpenCode's terminal daemon, event-driven OVERLAPPED pipe accepts + immediate output drain cut an earlier daemon's median echo 52 → 5.7 ms (current 51 ms baseline port open in opencode#65669). - Hidden Tauri/WebView2 windows stay
visible: On Cap 0.5.9,window.hide()leftdocument.visibilityStateatvisible(noICoreWebView2Controller::put_IsVisible(false)), so 5 s camera polling kept running in the tray and reached 3,345 threads, 223,563 handles, and 3.43 GB private at 4h16m (DirectShow leak isolated by@aacarcrash). Bridging native visibility + fixing DirectShow/Media Foundation cleanup cut 60-enumeration growth from +53 thr / +3,858 hnd / +49 MB → 0 (Cap#2143). - No general HWND occlusion message on Win32: DXGI has occlusion events, but Win32 has no general "another ordinary window fully covers this HWND" message. Listening via
SetWinEventHookand checking z-order dropped a covered debug spinner's CPU 955 → 0-3 ms/s (rune#570). - Skip unnecessary
IUIAutomationwalks on browsers: Polling Edge's UIA tree twice a second spiked Edge 0 → 417 ms CPU over 10 s and 162 → 1,407 wakes/s. Skip UIA unless the active feature needs page context (hex#1266).
Processes & Shells
CreateProcessis notfork(): Two per-filegitcalls (stats + patch) plus diff overhead on 257 untracked files ran 783 → 17gitprocesses (28.4-34.0 → 0.34-0.36 s; opencode#53449). In one 13-agent load, ~1 in 50CreateProcesscalls blocked the caller >100 ms; moving spawns to a launcher thread kept stalls off the server thread (opencode#62802, open).- Never spawn a 240 MB CLI just for
--version: Cost 380 ms warm, ~3 s after update under Defender. Ship its build-generated version file beside it (opencode#49762). pwsh& Store alias traps: A freshpwsh -NoProfiledirectory listing (warm caches) took ~450 ms vs 83 ms in a warm PowerShell worker (opencode#45138, closed). Microsoft Storepwsh'sIO_REPARSE_TAG_APPEXECLINKalias threwEACCESonstat(), falling back to PS 5.1 (opencode#61952), thencross-spawnrouted it throughcmd.exeand silently dropped line 2 (opencode#62522). In our tests, Win32 Job Objects caught MSI/zippwshdescendants but not Storepwsh's (opencode#62602, open).- Pass
CREATE_NO_WINDOW(0x0800_0000): A console-less GUI app can flash a terminal when spawning noninteractive console helpers; setCREATE_NO_WINDOWwhile preserving other creation flags (strobe#29, opencode#14197). - Clear only console std handles after
FreeConsole(): Windows closes console handles without clearingSTD_OUTPUT_HANDLEand can reuse that integer for a later open file, causingprintln!to write into it (observed panicking on a read-only file). CheckGetConsoleModebeforeFreeConsole(), then callSetStdHandle(id, null)only on console-attached slots soapp > out.txtand pipes keep working (hex#244). - Cleanup & Ctrl+C inheritance: For owned child trees, assign a Win32 Job Object (
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE) before the child can spawn descendants (opencode#62602, open). Clear inherited Ctrl+C-ignore withSetConsoleCtrlHandler(NULL, FALSE)before launching interactive shells from new process groups (opencode#47163). - Own threads via
NtGetNextThread:CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD)walked ~6,680 OS threads (58-66 ms). Dynamically resolvedNtGetNextThreadwalked our 6 threads (0.01-0.13 ms). Undocumentedntdllexport: keep a documented fallback and close each handle (rune#806).
Updates & NTFS
- Stage app updates in the background: OpenCode's 236 MB electron-builder installer took 11.8 s already closed (6 PowerShell checks 4.8 s, installer startup 2.1 s, single-thread LZMA2 3.0 s). Background unpack + folder swap + Toolhelp check cut restart to 1.4 s; skip NSIS
/NCRConly for updates already verified against trusted metadata and keep CRC + signature checks for manual installs (opencode#55933). Pure-Rust binary delta (dev-491 → dev-492 x64): 68.75 → 13.75 MB (-80%; opencode-rune#1748). - Flush extracted binaries during setup: Immediately launching a newly extracted binary stalled
--version1,330-1,454 ms while Windows flushed dirty cache pages for image mapping (reproduced even in a Defender-excluded folder). CallingFlushFileBuffersduring setup dropped it to 17-24 ms (opencode-rune#997). - Keep long-lived GUI helper CWD out of the install dir: Windows holds a process's working directory open (children inherit it by default), blocking update folder renames. Set helper CWD explicitly and resolve any user-supplied relative CLI paths against the original CWD first (opencode-rune#978).
- NTFS hard-link tricks: Adding a temporary same-volume hard link let our updater unlink a non-last name for a running binary cleanly (clean up after exit + fallback; opencode#50819). Hard-linking the 170 MB helper instead of copying cut handoff 919 → 89 ms scanned (1,015 → 37 ms excluded; fall back to copy; opencode-rune#842).
- Strip installer-only
__COMPAT_LAYER=DetectorsAppHealth: Explorer's PCA heuristic tagged our setup exe, causing child processes to loadapphelp.dll(13.4 → 6.4 ms loader init). Strip only the installer token at handoff and preserve user compatibility layers (opencode-rune#873). - Parallel NTFS cache races: On Bun 1.3.14, four 8-way cold shared-cache rounds failed 32/32 (
ENOTEMPTY/ENOENT) while npm 11.11.0 and pnpm 11.10.0 passed 40/40 each (bun#28063, closed; repro; Bun later marked #28062 fixed via #44968). - Packaging & CLI details: Keep per-channel install dirs separate (opencode#56904); grant
ALL RESTRICTED APPLICATION PACKAGESRX on installed binaries and resources only for Chromium sandbox (opencode#46696); detect ARM64 Prism via Electron'sapp.runningUnderARM64Translation(opencode#54983); stay underCreateProcessW's 32,767 UTF-16 code-unit command-line cap (including NUL) by passing Git large path lists as NUL-delimited stdin (opencode#22560).
Win32 & Random Traps
- Excluded local ports: Nothing listening, bind still denied: Windows had excluded
49292-49391, including our49374(0xC0DE). Hyper-V/WinNAT/WSL can reserve blocks in49152-65535and lower down (checknetsh interface ipv4 show excludedportrange protocol=tcp). We moved defaults well below0xC000(0xB0DE= 45278; opencode#55547); bind port0for discoverable services and surface errors clearly on user-pinned ports. - Mixed-DPI monitors: Creating Cap's overlay on a 100% display then applying a 150%
WM_DPICHANGEDsize change to physical pixels blew 2560x1440 → 3840x2160. Resolve the target monitor first and create at its physical bounds (Cap#2472). Win+L& low-level hooks: Switching to the secure desktop made our hook missWin-up. Read prior modifier state viaGetAsyncKeyState, then apply the current hook event (hex#235).AltGrlayouts: Right Alt can arrive with synthetic Left Ctrl. Do not steal@or€asCtrl+Altshortcuts (rune#154).- Modal titlebar drag: Holding a titlebar parks outer event-loop callbacks. Tick requested animations via
WM_TIMERbetweenWM_ENTERSIZEMOVEandWM_EXITSIZEMOVE; disarm on exit (rune#2918). - Clean shutdown vs crash recovery: Clear crash markers on
WM_ENDSESSIONonly whenwParam != 0(0means shutdown was canceled; Cap#2434). - Transparent DirectComposition windows: Set
WS_EX_NOREDIRECTIONBITMAPfor GPU-composited transparency (keep GDI redirection on windows needing CPU paint; rune#1458).