perf(web): avoid discarded WASM download before isolation reload
Withdrawn after qualification: stalled service-worker registration delays the synthetic initialization event from 1,936 ms on base to 11,938 ms on head. This startup regression outweighs the normal-case transfer saving. A no-wait keepalive alternative did not establish a useful reduction. See the final investigation comment for before/after evidence. No merge or deployment.
A first visit starts preloading WASM while the isolation service worker installs, then abandons that request during the required reload. Keep Trunk's preloads in an inert template and defer the dynamic import while that reload is pending. Already isolated documents activate both preloads during parsing. Preserve Trunk's initializer API and application-started event.
Preserve GPUI's main-thread fallback when isolation is unavailable: the startup promise settles immediately for missing/failed service workers, insecure contexts, or an existing non-isolated controller. A missing worker script also retains the original startup path. A stalled installation releases startup after 10 seconds; a late worker takeover can still cause a reload. That ceiling is an explicit trade-off for avoiding a download during setup.
Measured with Chromium 151 on one Linux runner, eight alternating base/head pairs and fresh scopes, the real service worker plus a synthetic 22 MiB WASM custom section served in 64 KiB chunks every 5 ms: base made 2 WASM requests and cancelled 1 in all pairs; head made 1 and cancelled 0. Final-head median avoided server-written payload was 1,474,560 bytes. Both completed in every run. With isolation headers supplied by the host, both variants made 1 request and wrote identical payload in all eight pairs. No latency improvement demonstrated; these fixtures measure avoided transfer, not application CPU, heap/RSS, or production startup latency. The amount saved depends on worker installation and network speed.
Reproduce with node web/startup-transfer.mjs and ISOLATED=1 node web/startup-transfer.mjs using Chromium on PATH. CHECK_FLOWS=1 node web/startup-transfer.mjs checks first load, reload/bfcache and an already-loaded document with networking disabled; all pass for base/head. It does not exercise full client offline storage/session behavior or claim offline installation. No application dependencies added.
Validation: 16 Node service-worker/startup tests pass, covering absent APIs/scripts, registration failure, stalled installation, existing controllers, bfcache restoration and the one-reload bound; all 50 xtask tests pass; TOML parses and diff check passes. Full web bundle and platform checks run in CI. Draft keeps preview publication off while validating. Independent of #265 and the daemon/UI/CLI/media/SQLite fronts.