Web: WebAssembly build served cross-origin isolated, immutable and precompressed

The web app is built with --wasm (skwasm, JS/CanvasKit fallback beside it).
The proxy serves it with COOP same-origin + COEP credentialless so skwasm
renders on a worker; an installed build loads from /_v/<buildId>/ cached as
immutable, other files revalidate by ETag, and the installer precompresses
.br/.gz variants the proxy sends by Accept-Encoding. The bootstrap no
longer registers Flutter's deprecated service worker (a reload per install).
Read aloud on the web uses the Web Speech API through package:web: the
flutter_tts web plugin's interop casts fail under wasm. Bench kit: isolation
and headed modes, renderer and memory reporting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-01 21:05:17 +00:00
parent 23d8658e80
commit 3b1760fe8e
17 changed files with 737 additions and 17 deletions
+4
View File
@@ -13,6 +13,10 @@ no longer matches the app.
removes Chrome, the profile and the server.
- It needs no npm packages: Node 22+ (global `WebSocket` and `fetch`) and
Google Chrome (`CHROME_PATH` overrides the macOS default).
- `CAPTURE_ISOLATE=1` serves the build with the web proxy's cross-origin
isolation headers, so a `--wasm` build renders multi-threaded as installed.
`CAPTURE_HEADED=1` opens a real X11 window instead of headless (run under
`xvfb-run -a`; Xvfb has no WebGL, so the wasm build falls back to CanvasKit).
## The fixture app
+2 -1
View File
@@ -14,7 +14,8 @@ const DEFAULT_CHROME ='/Applications/Google Chrome.app/Contents/MacOS/Google Chr
async function launch(chromePath, gpu, args = []) {
const profile = await mkdtemp(join(tmpdir(), 'pipelines-capture-chrome-'));
const chrome = spawn(chromePath, [
'--headless=new', '--no-first-run', '--no-default-browser-check',
// CAPTURE_HEADED=1 opens a real X11 window (under xvfb-run) instead.
...(process.env.CAPTURE_HEADED === '1' ? ['--ozone-platform=x11'] : ['--headless=new']), '--no-first-run', '--no-default-browser-check',
// Without a GPU CanvasKit rasterises on the CPU; `gpu` keeps WebGL (Metal
// through ANGLE on a Mac) for benches that measure raster time.
// Linux keeps the GPU through ANGLE on Vulkan.
+8
View File
@@ -21,6 +21,13 @@ const MIME = {
'.woff2': 'font/woff2',
};
// `CAPTURE_ISOLATE=1` adds the Pipelines proxy's cross-origin isolation
// headers (web/src/appFiles.js), so a `--wasm` build renders multi-threaded as
// it does when installed; without them skwasm runs single-threaded.
const ISOLATE = process.env.CAPTURE_ISOLATE === '1'
? { 'cross-origin-opener-policy': 'same-origin', 'cross-origin-embedder-policy': 'credentialless' }
: {};
/** Serves [dir]; resolves to `{ origin, close() }`. */
export async function serveBuild(dir) {
const root = resolve(dir);
@@ -41,6 +48,7 @@ export async function serveBuild(dir) {
res.writeHead(200, {
'content-type': MIME[extname(file)] ?? 'application/octet-stream',
'cache-control': 'no-store',
...ISOLATE,
}).end(body);
} catch {
res.writeHead(404).end('not found');