- renderer: release_transfer_images() deletes the transfer framebuffer instead of only zeroing the name; the leak exhausted VRAM and killed the GPU process under Vulkan after ~3-7 minutes - canvas: status notices are absolute overlays, so they no longer resize the native surface (each show/hide freed and recreated region draw buffers and eventually froze the main regions) - compute: bounded shader/layout/pipeline caches, staging pool, device-lost error propagation, dev-only ?glStats / ?computeFault / ?compute hooks - headed tools: soak/probe/smoke assets and docs - evidence: 20-minute Vulkan soak STABLE (GPU-SOAK-20261205-161007), SwiftShader control STABLE (GPU-SOAK-20261205-162105), Clip 28/28 NOT_CLAIMED (CLIP-HEADED-20261205-162214) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
103 lines
4.6 KiB
JavaScript
103 lines
4.6 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Probe the WebGPU adapter under several Chrome flag sets.
|
|
*
|
|
* node tools/web/headed/probe/probe-webgpu-flags.mjs [--url <origin>] [--out <dir>] [--json-only]
|
|
*
|
|
* Loads the app origin once per flag set, records navigator.gpu / adapter
|
|
* info / WebGL2 renderer / engine-side WebGPU errors and writes
|
|
* report.json. Exit 0 when every flag set was probed, 1 on a hard failure,
|
|
* 2 when preflight conditions are missing.
|
|
*/
|
|
import path from "node:path";
|
|
import { launchChrome, normalizeArgs } from "../lib/browser.mjs";
|
|
import { preflight, preflightBlocked } from "../lib/preflight.mjs";
|
|
import { receiptDir, writeReceipt } from "../lib/receipt.mjs";
|
|
|
|
const argv = normalizeArgs(process.argv.slice(2));
|
|
if (argv.includes("--help")) {
|
|
console.log("usage: probe-webgpu-flags.mjs [--url <origin>] [--out <receipt dir>] [--json-only] [--help]");
|
|
process.exit(0);
|
|
}
|
|
const take = (name) => { const index = argv.indexOf(`--${name}`); return index >= 0 && argv[index + 1] ? argv[index + 1] : null; };
|
|
for (let index = 0; index < argv.length; index += 1) {
|
|
if (!argv[index].startsWith("--")) { console.error(`unexpected argument: ${argv[index]}`); process.exit(64); }
|
|
const name = argv[index].slice(2);
|
|
if (!["url", "out", "json-only", "help"].includes(name)) { console.error(`unknown option: --${name}`); process.exit(64); }
|
|
if (name !== "json-only") index += 1;
|
|
}
|
|
const url = take("url") ?? "http://127.0.0.1:5173/";
|
|
const jsonOnly = argv.includes("--json-only");
|
|
|
|
const combos = [
|
|
{ name: "none", flags: [] },
|
|
{ name: "unsafe-webgpu", flags: ["--enable-unsafe-webgpu"] },
|
|
{ name: "unsafe+ignore-blocklist", flags: ["--enable-unsafe-webgpu", "--ignore-gpu-blocklist"] },
|
|
{ name: "unsafe+vulkan", flags: ["--enable-unsafe-webgpu", "--enable-features=Vulkan"] },
|
|
{ name: "unsafe+angle-vulkan", flags: ["--enable-unsafe-webgpu", "--enable-features=Vulkan", "--use-angle=vulkan"] },
|
|
];
|
|
|
|
const preflightItems = await preflight({ url });
|
|
if (preflightBlocked(preflightItems)) {
|
|
console.error(JSON.stringify({ status: "BLOCKED", preflight: preflightItems }, null, 2));
|
|
process.exit(2);
|
|
}
|
|
|
|
const started = Date.now();
|
|
const results = [];
|
|
let chromeInfo = null;
|
|
for (const combo of combos) {
|
|
const session = await launchChrome({ flags: ["--no-sandbox", ...combo.flags], viewport: { width: 1440, height: 900 } });
|
|
chromeInfo ??= session.chrome;
|
|
const errors = [];
|
|
session.page.on("console", (message) => {
|
|
if (message.type() === "error" && /webgpu|dawn|shader|compute/i.test(message.text())) errors.push(message.text().slice(0, 200));
|
|
});
|
|
try {
|
|
await session.page.goto(url, { waitUntil: "domcontentloaded", timeout: 60_000 });
|
|
await session.page.waitForTimeout(9_000);
|
|
const state = await session.page.evaluate(async () => {
|
|
const out = { secure: globalThis.isSecureContext, gpu: Boolean(navigator.gpu) };
|
|
const canvas = document.createElement("canvas");
|
|
const gl = canvas.getContext("webgl2");
|
|
if (gl) {
|
|
const ext = gl.getExtension("WEBGL_debug_renderer_info");
|
|
out.webgl2Renderer = ext ? gl.getParameter(ext.UNMASKED_RENDERER_WEBGL) : gl.getParameter(gl.RENDERER);
|
|
}
|
|
if (navigator.gpu) {
|
|
try {
|
|
const adapter = await navigator.gpu.requestAdapter();
|
|
out.adapter = Boolean(adapter);
|
|
if (adapter) {
|
|
out.info = adapter.info ? { vendor: adapter.info.vendor, architecture: adapter.info.architecture, device: adapter.info.device, description: adapter.info.description } : null;
|
|
const device = await adapter.requestDevice().catch(() => null);
|
|
out.device = Boolean(device);
|
|
}
|
|
} catch (error) { out.adapterError = String(error).slice(0, 160); }
|
|
}
|
|
return out;
|
|
});
|
|
results.push({ ...combo, state, engineErrors: errors.slice(0, 5) });
|
|
} catch (error) {
|
|
results.push({ ...combo, error: error.message, engineErrors: errors.slice(0, 5) });
|
|
} finally {
|
|
await session.close();
|
|
}
|
|
}
|
|
|
|
const report = {
|
|
tool: "probe-webgpu-flags",
|
|
url,
|
|
startedAt: new Date().toISOString(),
|
|
durationMs: Date.now() - started,
|
|
chrome: chromeInfo,
|
|
preflight: preflightItems,
|
|
combos: results,
|
|
};
|
|
const dir = receiptDir("GPU-PROBE", take("out"));
|
|
const file = writeReceipt(dir, report);
|
|
const failed = results.filter((item) => item.error).length;
|
|
if (jsonOnly) console.log(JSON.stringify(report, null, 2));
|
|
else console.log(JSON.stringify({ receipt: file, adapters: results.map((item) => ({ flags: item.name, adapter: item.state?.info ?? item.state?.adapter ?? null, device: item.state?.device ?? null })) }, null, 2));
|
|
process.exit(failed === results.length ? 1 : 0);
|