Files
workinf_Blender_Wasm/tools/web/complete/probe-usd-wasm.mjs
mes123456 4eb08faf31 chore(web): checkpoint export fixes, operator routing and three-domain evidence
- Web engine CMake: apply WITH_WEB_USD_PYTHON to blender_web_engine_core,
  embed /usd resources, link pxr Python bindings after the core archive and
  whole-archive the monolithic OpenUSD archive. Fixes the wm.usd_export abort
  and restores Alembic/USD embedded export.
- ?ui=web menus: fix inverted localOnly gating and route queueLocalDesktopOperator
  and nativeAdd through the desktop operator channel with a VIEW_3D context;
  non-mesh edit-mode selection uses the native VIEW3D_SELECT bridge.
- Refresh WebEngine wasm/js artifacts, manual/course pages and the complete
  course video asset.
- Record focused Chromium probes for Add/F3/parameters/modifier/UV/curve/deform,
  scene operations, OPFS save/reopen and worker restart. Evidence is NOT_CLAIMED.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-14 06:12:44 +08:00

139 lines
5.9 KiB
JavaScript

#!/usr/bin/env node
/**
* Focused probe: is /usd present in the WebEngine WASM FS, and where does
* wm.usd_export abort? Drives the product worker directly through a Worker
* wrapper installed before the app boots. Evidence only; no assertions.
*
* node tools/web/complete/probe-usd-wasm.mjs --base-url http://127.0.0.1:5176
*/
import path from "node:path";
import { ASSETS, parseArgs, launchBrowser, newPage, openApp, openFile, waitScene } from "../course/lib/lesson-recorder.mjs";
const args = parseArgs();
const BASE = args.baseUrl || "http://127.0.0.1:5176";
const TIMEOUT = Number(args.timeout || 240_000);
const browser = await launchBrowser(args.gpu);
const { context, page, consoleErrors } = await newPage(browser, {});
const consoleAll = [];
page.on("console", (message) => consoleAll.push(`${message.type()}: ${message.text()}`));
page.setDefaultTimeout(60_000);
await page.addInitScript(() => {
const NativeWorker = window.Worker;
window.__probeWorkers = [];
window.__probeMessages = [];
window.Worker = class extends NativeWorker {
constructor(...params) {
super(...params);
this.__probeLabel = `${String(params[0])} :: ${new Error().stack.split("\n")[2]?.trim() ?? ""}`;
window.__probeWorkers.push(this);
this.addEventListener("message", (event) => window.__probeMessages.push({ worker: this.__probeLabel, data: event.data }));
}
};
});
const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts);
try {
await openApp(page, BASE);
log("app open");
await openFile(page, ASSETS.studio);
await waitScene(page, { objects: 6, timeout: 240_000 });
log("scene open");
const python = async (source) => {
const requestId = `probe-${Date.now()}-${Math.random().toString(36).slice(2)}`;
return await page.evaluate(({ requestId, source }) => new Promise((resolve) => {
const targets = window.__probeWorkers;
const started = Date.now();
const read = () => {
const hit = window.__probeMessages.find((entry) => entry.data && entry.data.requestId === requestId && entry.data.kind === "result");
if (hit) { clearInterval(timer); resolve({ elapsedMs: Date.now() - started, workers: targets.map((w) => w.__probeLabel), response: hit.data, via: hit.worker }); return; }
if (Date.now() - started > 240000) {
clearInterval(timer);
resolve({ elapsedMs: Date.now() - started, timeout: true, workers: targets.map((w) => w.__probeLabel), messages: window.__probeMessages.slice(-10) });
}
};
const timer = setInterval(read, 250);
for (const worker of targets) worker.postMessage({ requestId, command: { type: "jsonCommand", cmd: "pythonExec", params: { source, filename: "ProbeUSD.py", console: false } } });
}), { requestId, source }, { timeout: TIMEOUT });
};
log("--- stage 1: WASM FS + pxr import ---");
log(JSON.stringify(await python(`
import json, os
report = {
'usd_dir': os.path.isdir('/usd'),
'plugInfo': os.path.exists('/usd/plugInfo.json'),
'usd_entries': sorted(os.listdir('/usd'))[:40] if os.path.isdir('/usd') else [],
'pxr_zip': os.path.exists('/python/lib/webengine-pxr.zip'),
'browser_dir': os.path.isdir('/browser'),
}
try:
from pxr import Plug
report['pxr_plugins'] = len(Plug.Registry().GetAllPlugins())
report['file_formats'] = sorted(Plug.Registry().GetPluginWithName(n) is not None for n in ('usdc', 'usda'))
except BaseException as error:
report['pxr_error'] = repr(error)
print('PROBE_STAGE1 ' + json.dumps(report, sort_keys=True))
`)));
log("--- stage 1b: sys.path / zipimporter / operator schema ---");
log(JSON.stringify(await python(`
import json, sys
report = {'path': list(sys.path)}
try:
import zipimport
report['zip_importer'] = zipimport.zipimporter('/python/lib/webengine-pxr.zip').find_spec('pxr') is not None
except BaseException as error:
report['zip_error'] = repr(error)
try:
import bpy
rna = bpy.ops.wm.usd_export.get_rna_type()
report['usd_props'] = sorted(p.identifier for p in rna.properties if p.identifier in ('filepath', 'export_textures_mode', 'relative_paths', 'selected_objects_only', 'as_background_job'))
except BaseException as error:
report['schema_error'] = repr(error)
print('PROBE_STAGE1B ' + json.dumps(report, sort_keys=True))
`)));
log("--- stage 2: wm.usd_export ---");
log(JSON.stringify(await python(`
import json, os, web_blender
os.makedirs('/browser/probe-usd', exist_ok=True)
payload = {
'operator': 'wm.usd_export',
'properties': {'filepath': '/browser/probe-usd/scene.usdc', 'export_textures_mode': 'NEW', 'relative_paths': True},
'baseRevision': web_blender.snapshot().get('revision'),
'areaType': 'VIEW_3D',
'mode': 'OBJECT',
'native': True,
'selectedObjects': [], 'activeObject': None,
}
web_blender.desktop_operator(payload)
print('PROBE_STAGE2 DONE ' + json.dumps({'files': sorted(os.listdir('/browser/probe-usd')), 'bytes': os.path.getsize('/browser/probe-usd/scene.usdc') if os.path.exists('/browser/probe-usd/scene.usdc') else -1}))
`)));
log("--- stage 3: wm.alembic_export ---");
log(JSON.stringify(await python(`
import json, os, web_blender
os.makedirs('/browser/probe-abc', exist_ok=True)
payload = {
'operator': 'wm.alembic_export',
'properties': {'filepath': '/browser/probe-abc/scene.abc'},
'baseRevision': web_blender.snapshot().get('revision'),
'areaType': 'VIEW_3D',
'mode': 'OBJECT',
'native': True,
'selectedObjects': [], 'activeObject': None,
}
web_blender.desktop_operator(payload)
print('PROBE_STAGE3 DONE ' + json.dumps({'files': sorted(os.listdir('/browser/probe-abc')), 'bytes': os.path.getsize('/browser/probe-abc/scene.abc') if os.path.exists('/browser/probe-abc/scene.abc') else -1}))
`)));
} catch (error) {
log("probe error", error instanceof Error ? error.message : String(error));
} finally {
log("consoleErrors", JSON.stringify(consoleErrors.slice(-30)));
log("consoleAll", JSON.stringify(consoleAll.slice(-40)));
await context.close();
await browser.close();
}