fix: generate showcase thumbnails deterministically
Some checks failed
ci / test (macos-latest, 3.10) (push) Has been cancelled
ci / test (macos-latest, 3.12) (push) Has been cancelled
ci / test (ubuntu-latest, 3.10) (push) Has been cancelled
ci / test (ubuntu-latest, 3.12) (push) Has been cancelled
ci / test (windows-latest, 3.10) (push) Has been cancelled
ci / test (windows-latest, 3.12) (push) Has been cancelled
ci / browser-smoke (push) Has been cancelled

This commit is contained in:
2026-07-21 14:53:23 +08:00
parent e0cd974c6b
commit 8cc64f2e58
3 changed files with 26 additions and 3 deletions

View File

@@ -74,6 +74,7 @@ Read only the branches needed for the current task:
- Require `verify_showcase.py --strict` and `verify_delivery.py` to pass.
- Inspect at least one iso/front/side/plan render personally.
- For served Web output, use `cad_showcase.py run --web`; it Draco-compresses Trimesh GLBs, starts a temporary local server, runs `web_smoke_test.mjs` at real 1440×900 and 390×844 viewports, and feeds the report to final verification automatically.
- Use the `thumbnail.png` emitted by the Web smoke. It is exported directly from the WebGL canvas with the canonical camera; do not manually crop the browser screenshot or iterate on UI-free framing.
- For `--offline`, the pipeline embeds the retained uncompressed `standard.raw.glb`, opens `viewer.html` through a real `file://` Chromium page, and records `offline_browser_smoke_report.json`. Never embed a Draco GLB in the r147 offline viewer unless a matching offline decoder is bundled and tested.
- Confirm idle `window.__renders` does not grow, GLBs decode, variants exist, controls work, and console errors are zero.

View File

@@ -373,7 +373,7 @@ def ensure_node_runtime(pipeline: Pipeline, *, browser: bool) -> None:
)
def run_browser_smoke(pipeline: Pipeline, web_dir: Path, report: Path, screenshots: Path) -> None:
def run_browser_smoke(pipeline: Pipeline, web_dir: Path, report: Path, screenshots: Path, thumbnail: Path) -> None:
"""Serve the formal Web bundle and mechanically prove desktop/mobile loading."""
report.parent.mkdir(parents=True, exist_ok=True)
port = available_port()
@@ -405,8 +405,10 @@ def run_browser_smoke(pipeline: Pipeline, web_dir: Path, report: Path, screensho
str(report),
"--screenshots-dir",
str(screenshots),
"--thumbnail-out",
str(thumbnail),
),
[report, screenshots],
[report, screenshots, thumbnail],
)
finally:
server.terminate()
@@ -695,7 +697,13 @@ def run_pipeline(args: argparse.Namespace) -> int:
browser_report = (
Path(args.browser_report).resolve() if args.browser_report else out_dir / "browser_smoke_report.json"
)
run_browser_smoke(pipeline, web_dir, browser_report, out_dir / "browser_smoke")
run_browser_smoke(
pipeline,
web_dir,
browser_report,
out_dir / "browser_smoke",
out_dir / "thumbnail.png",
)
standard = bundle / "variants" / "standard" / "standard.glb"
offline = out_dir / "viewer.html"

View File

@@ -12,6 +12,7 @@ function arg(name, fallback = null) {
const url = arg("--url");
const out = arg("--out", "browser_smoke_report.json");
const shots = arg("--screenshots-dir", "browser_smoke");
const thumbnailOut = arg("--thumbnail-out");
if (!url) {
throw new Error("Usage: web_smoke_test.mjs --url http://127.0.0.1:8188 --out report.json");
}
@@ -24,6 +25,7 @@ try {
}
await fs.mkdir(shots, { recursive: true });
if (thumbnailOut) await fs.mkdir(path.dirname(thumbnailOut), { recursive: true });
const browser = await chromium.launch({ headless: true });
const consoleErrors = [];
const pageErrors = [];
@@ -56,6 +58,18 @@ async function inspect(viewport, name) {
await page.waitForTimeout(1500);
const after = await page.evaluate(() => window.__renders || 0);
checks.push({ name: `${name}:idle-render`, status: after === before ? "PASS" : "FAIL", detail: `${before}->${after}` });
if (name === "desktop" && thumbnailOut) {
// Export the renderer itself. Cropping a page screenshot retains UI panels
// and makes Agents guess at a dark-background crop; the canvas is already
// the canonical customer model view. Zoom out a fixed amount so the white
// model remains a compact subject on the dark exhibit background.
const canvas = page.locator("#scene");
await canvas.hover();
await page.mouse.wheel(0, 1800);
await page.waitForTimeout(500);
const dataUrl = await canvas.evaluate((element) => element.toDataURL("image/png"));
await fs.writeFile(thumbnailOut, Buffer.from(dataUrl.split(",", 2)[1], "base64"));
}
await page.screenshot({ path: path.join(shots, `${name}.png`), fullPage: true });
await page.close();
}