- 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>
135 lines
6.8 KiB
JavaScript
135 lines
6.8 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Interaction soak for the native desktop canvas: drives pointer/keyboard load
|
|
* in a real headed Chrome, watches the browser stderr for GPU-process crashes
|
|
* and keeps a screenshot-difference liveness signal.
|
|
*
|
|
* node tools/web/headed/soak/soak-interaction.mjs [--url <origin>]
|
|
* [--flags <csv>] [--minutes N] [--shots <dir>] [--out <receipt dir>]
|
|
*
|
|
* Verdicts: STABLE (no crash pattern, canvas changing), GPU_CRASH (crash
|
|
* patterns seen), CANVAS_STALL (no crash but the final round's canvas did not
|
|
* change). Exit 0 STABLE, 1 otherwise, 2 preflight blocked.
|
|
*/
|
|
import path from "node:path";
|
|
import { launchChrome, normalizeArgs } from "../lib/browser.mjs";
|
|
import { createCrashWatch } from "../lib/crash-watch.mjs";
|
|
import { bufferHash, snapshot } from "../lib/liveness.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: soak-interaction.mjs [--url <origin>] [--flags <csv>] [--minutes N] [--shots <dir>] [--out <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", "minutes", "shots", "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 flags = (take("flags") ?? "--enable-unsafe-webgpu").split(",").filter(Boolean);
|
|
const minutes = Number(take("minutes") ?? "3");
|
|
const jsonOnly = argv.includes("--json-only");
|
|
if (!Number.isFinite(minutes) || minutes <= 0) { console.error("--minutes must be a positive number"); process.exit(64); }
|
|
|
|
const preflightItems = await preflight({ url });
|
|
if (preflightBlocked(preflightItems)) {
|
|
console.error(JSON.stringify({ status: "BLOCKED", preflight: preflightItems }, null, 2));
|
|
process.exit(2);
|
|
}
|
|
|
|
const shots = mediaDir("gpu-soak", take("shots"));
|
|
const stderrFile = path.join(shots, "chrome-stderr.log");
|
|
const watch = createCrashWatch();
|
|
const session = await launchChrome({ flags: ["--no-sandbox", ...flags], viewport: { width: 1440, height: 900 }, stderrFile });
|
|
session.stderr.onLine = (line) => watch.feed(line);
|
|
|
|
const state = () => session.page.evaluate(() => ({
|
|
engine: document.querySelector('[data-testid="engine-status"]')?.textContent ?? null,
|
|
wasm: document.querySelector('[data-testid="wasm-status"]')?.textContent ?? null,
|
|
native: document.querySelector('[aria-label="Blender 桌面"]')?.getAttribute("data-native-canvas-open") ?? null,
|
|
gpuStats: typeof globalThis.__WBV2_GPU_STATS === "function" ? globalThis.__WBV2_GPU_STATS() : null,
|
|
})).catch(() => null);
|
|
|
|
const started = Date.now();
|
|
let ready = false;
|
|
let readyMs = null;
|
|
const jsErrors = [];
|
|
const gpuStats = [];
|
|
session.page.on("pageerror", (error) => jsErrors.push(String(error).slice(0, 200)));
|
|
session.page.on("console", (message) => {
|
|
const text = message.text();
|
|
// The compute worker prints cumulative GPU-object counters every 15 s.
|
|
const stats = text.match(/\[gpu-stats\]\s*(\{.*\})/);
|
|
if (stats) { try { gpuStats.push({ atMs: Date.now() - started, ...JSON.parse(stats[1]) }); } catch { /* partial line */ } }
|
|
if (message.type() === "error" && /webgpu|dawn|shader|compute/i.test(text)) jsErrors.push(text.slice(0, 200));
|
|
});
|
|
|
|
let canvasAlive = null;
|
|
let interactions = 0;
|
|
let rounds = 0;
|
|
const samples = [];
|
|
try {
|
|
await session.page.goto(url, { waitUntil: "domcontentloaded", timeout: 60_000 });
|
|
for (let attempt = 0; attempt < 120; attempt += 1) {
|
|
const current = await state();
|
|
if (current && /ready/i.test(current.wasm ?? "") && /new General project|SceneIR/i.test(current.engine ?? "")) { ready = true; break; }
|
|
await session.page.waitForTimeout(1000);
|
|
}
|
|
readyMs = Date.now() - started;
|
|
|
|
const viewport = session.page.viewportSize() ?? { width: 1440, height: 900 };
|
|
const cx = Math.round(viewport.width * 0.45);
|
|
const cy = Math.round(viewport.height * 0.5);
|
|
const deadline = Date.now() + minutes * 60_000;
|
|
while (Date.now() < deadline) {
|
|
rounds += 1;
|
|
const before = bufferHash(await snapshot(session.page));
|
|
await session.page.mouse.move(cx, cy);
|
|
await session.page.mouse.wheel(0, rounds % 2 ? -240 : 240);
|
|
await session.page.mouse.down({ button: "middle" });
|
|
await session.page.mouse.move(cx + 80, cy + 40, { steps: 8 });
|
|
await session.page.mouse.up({ button: "middle" });
|
|
await session.page.mouse.click(cx + 40, cy + 20);
|
|
await session.page.keyboard.press("n").catch(() => {});
|
|
await session.page.waitForTimeout(500);
|
|
await session.page.keyboard.press("n").catch(() => {});
|
|
await session.page.keyboard.press("F3").catch(() => {});
|
|
await session.page.waitForTimeout(300);
|
|
await session.page.keyboard.press("Escape").catch(() => {});
|
|
await session.page.waitForTimeout(1500);
|
|
const after = bufferHash(await snapshot(session.page));
|
|
if (before !== null && after !== null) canvasAlive = before !== after;
|
|
interactions += 5;
|
|
await session.page.screenshot({ path: path.join(shots, `round-${String(rounds).padStart(3, "0")}.png`) }).catch(() => {});
|
|
const current = await state();
|
|
samples.push({ round: rounds, atMs: Date.now() - started, alive: canvasAlive, crashed: watch.count, state: current });
|
|
if (rounds % 3 === 0) {
|
|
await session.page.click('[data-testid="native-web-tools-toggle"]', { timeout: 3000 }).catch(() => {});
|
|
await session.page.waitForTimeout(1000);
|
|
await session.page.click('[data-testid="desktop-file-transfer-entry"]', { timeout: 3000 }).catch(() => {});
|
|
await session.page.waitForTimeout(1000);
|
|
}
|
|
}
|
|
} finally {
|
|
await session.close();
|
|
}
|
|
|
|
const finalState = samples.at(-1)?.state ?? null;
|
|
const verdict = watch.count > 0 ? "GPU_CRASH" : canvasAlive ? "STABLE" : "CANVAS_STALL";
|
|
const report = {
|
|
tool: "soak-interaction", url, flags, minutes, chrome: session.chrome, preflight: preflightItems,
|
|
ready, readyMs, rounds, interactions, canvasAlive, verdict,
|
|
crashes: watch.summary(), jsErrors: jsErrors.slice(0, 10), finalState,
|
|
gpuStats: gpuStats.slice(-160), stderrFile,
|
|
samples: samples.filter((_, index) => index % 10 === 0).slice(0, 60), shots,
|
|
};
|
|
const file = writeReceipt(receiptDir("GPU-SOAK", take("out")), report);
|
|
if (jsonOnly) console.log(JSON.stringify(report, null, 2));
|
|
else console.log(JSON.stringify({ receipt: file, verdict, minutes, crashes: report.crashes.count, fatal: report.crashes.fatalCount, rounds, canvasAlive }, null, 2));
|
|
process.exit(verdict === "STABLE" ? 0 : 1);
|