- 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>
78 lines
3.9 KiB
JavaScript
78 lines
3.9 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Check that the native desktop canvas actually renders under a given flag
|
|
* set (adapter present, canvas open, screenshot not empty).
|
|
*
|
|
* node tools/web/headed/smoke/check-canvas-render.mjs [--url <origin>]
|
|
* [--flags <csv>] (default: --enable-unsafe-webgpu)
|
|
*
|
|
* Exit 0 pass, 1 failed, 2 preflight blocked.
|
|
*/
|
|
import path from "node:path";
|
|
import { launchChrome, normalizeArgs } from "../lib/browser.mjs";
|
|
import { preflight, preflightBlocked } from "../lib/preflight.mjs";
|
|
import { receiptDir, mediaDir, writeReceipt } from "../lib/receipt.mjs";
|
|
import { imageStats } from "../../lib/image-stats.mjs";
|
|
|
|
const argv = normalizeArgs(process.argv.slice(2));
|
|
if (argv.includes("--help")) {
|
|
console.log("usage: check-canvas-render.mjs [--url <origin>] [--flags <csv>] [--out <dir>] [--shots <dir>] [--json-only]");
|
|
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", "flags", "out", "shots", "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 flags = (take("flags") ?? "--enable-unsafe-webgpu").split(",").filter(Boolean);
|
|
const jsonOnly = argv.includes("--json-only");
|
|
|
|
const preflightItems = await preflight({ url });
|
|
if (preflightBlocked(preflightItems)) {
|
|
console.error(JSON.stringify({ status: "BLOCKED", preflight: preflightItems }, null, 2));
|
|
process.exit(2);
|
|
}
|
|
|
|
const shots = mediaDir("headed-canvas", take("shots"));
|
|
const session = await launchChrome({ flags: ["--no-sandbox", ...flags], viewport: { width: 1600, height: 900 } });
|
|
let ready = false;
|
|
let nativeDesktop = null;
|
|
let adapter = null;
|
|
try {
|
|
await session.page.goto(url, { waitUntil: "domcontentloaded", timeout: 60_000 });
|
|
for (let attempt = 0; attempt < 120; attempt += 1) {
|
|
const current = await session.page.evaluate(() => ({
|
|
wasm: document.querySelector('[data-testid="wasm-status"]')?.textContent ?? null,
|
|
engine: document.querySelector('[data-testid="engine-status"]')?.textContent ?? null,
|
|
nativeDesktop: document.querySelector('[aria-label="Blender 桌面"]')?.getAttribute("data-native-canvas-open") ?? null,
|
|
})).catch(() => null);
|
|
nativeDesktop = current?.nativeDesktop ?? nativeDesktop;
|
|
if (current && /ready/i.test(current.wasm ?? "") && current.nativeDesktop === "true") { ready = true; break; }
|
|
await session.page.waitForTimeout(1000);
|
|
}
|
|
adapter = await session.page.evaluate(async () => {
|
|
if (!navigator.gpu) return null;
|
|
const found = await navigator.gpu.requestAdapter().catch(() => null);
|
|
return found?.info ? `${found.info.vendor}/${found.info.architecture}` : found ? "adapter" : null;
|
|
}).catch(() => null);
|
|
await session.page.waitForTimeout(1500);
|
|
await session.page.screenshot({ path: path.join(shots, "canvas.png") }).catch(() => {});
|
|
} finally {
|
|
await session.close();
|
|
}
|
|
|
|
let pixels = null;
|
|
try { pixels = imageStats(path.join(shots, "canvas.png")); } catch (error) { pixels = { verdict: "error", detail: error.message }; }
|
|
const ok = ready && Boolean(adapter) && pixels?.verdict !== "error";
|
|
const report = {
|
|
tool: "check-canvas-render", url, flags, chrome: session.chrome, preflight: preflightItems,
|
|
ready, nativeDesktop, adapter, pixels, shots, status: ok ? "PASS" : "FAIL",
|
|
};
|
|
const file = writeReceipt(receiptDir("HEADED-SMOKE", take("out")), report);
|
|
if (jsonOnly) console.log(JSON.stringify(report, null, 2));
|
|
else console.log(JSON.stringify({ receipt: file, status: report.status, ready, nativeDesktop, adapter, pixels: pixels?.verdict ?? null }, null, 2));
|
|
process.exit(ok ? 0 : 1);
|