- 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>
85 lines
4.0 KiB
JavaScript
85 lines
4.0 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Read the headed page state: engine/WASM status, native canvas, WebGPU
|
|
* fallback notice, canvases and the WebGL2 renderer string.
|
|
*
|
|
* node tools/web/headed/probe/probe-page-state.mjs [--url <origin>] [--flags <csv>]
|
|
*
|
|
* Exit 0 when the page was evaluated (state recorded), 1 when evaluation
|
|
* failed, 2 when preflight conditions are missing.
|
|
*/
|
|
import fs from "node:fs";
|
|
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";
|
|
|
|
const argv = normalizeArgs(process.argv.slice(2));
|
|
if (argv.includes("--help")) {
|
|
console.log("usage: probe-page-state.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") ?? "").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-page-state", take("shots"));
|
|
const session = await launchChrome({ flags: ["--no-sandbox", ...flags], viewport: { width: 1440, height: 900 } });
|
|
let state = null;
|
|
try {
|
|
await session.page.goto(url, { waitUntil: "domcontentloaded", timeout: 60_000 });
|
|
await session.page.waitForTimeout(9_000);
|
|
state = await session.page.evaluate(() => {
|
|
const text = (selector) => document.querySelector(selector)?.textContent ?? null;
|
|
const canvases = Array.from(document.querySelectorAll("canvas")).map((canvas) => {
|
|
let context = null;
|
|
try { context = canvas.getContext("webgl2") ? "webgl2" : canvas.getContext("webgpu") ? "webgpu" : "other"; }
|
|
catch { context = "transferred"; }
|
|
return { width: canvas.width, height: canvas.height, css: `${canvas.clientWidth}x${canvas.clientHeight}`, context };
|
|
});
|
|
const probe = document.createElement("canvas").getContext("webgl2");
|
|
let renderer = null;
|
|
if (probe) {
|
|
const ext = probe.getExtension("WEBGL_debug_renderer_info");
|
|
renderer = ext ? probe.getParameter(ext.UNMASKED_RENDERER_WEBGL) : probe.getParameter(probe.RENDERER);
|
|
}
|
|
return {
|
|
title: document.title,
|
|
isolated: globalThis.crossOriginIsolated,
|
|
sharedArrayBuffer: typeof SharedArrayBuffer !== "undefined",
|
|
webgl2Renderer: renderer,
|
|
engineStatus: text('[data-testid="engine-status"]'),
|
|
wasmStatus: text('[data-testid="wasm-status"]'),
|
|
nativeDesktop: document.querySelector('[aria-label="Blender 桌面"]')?.getAttribute("data-native-canvas-open") ?? null,
|
|
fallbackNotice: Boolean(document.querySelector('[data-testid="webgpu-fallback-notice"]')),
|
|
canvases,
|
|
bodyText: document.body.innerText.replace(/\s+/g, " ").slice(0, 240),
|
|
};
|
|
});
|
|
await session.page.screenshot({ path: path.join(shots, "page.png") }).catch(() => {});
|
|
} catch (error) {
|
|
state = { error: error.message };
|
|
} finally {
|
|
await session.close();
|
|
}
|
|
|
|
const report = { tool: "probe-page-state", url, flags, chrome: session.chrome, preflight: preflightItems, state, shots };
|
|
const file = writeReceipt(receiptDir("GPU-PROBE", take("out")), report);
|
|
if (jsonOnly) console.log(JSON.stringify(report, null, 2));
|
|
else console.log(JSON.stringify({ receipt: file, state }, null, 2));
|
|
process.exit(state?.error ? 1 : 0);
|
|
void fs;
|