fix(web): force CPU compositor preview evaluation
Temporarily select the CPU compositor device for the embedded preview so the GPU-context requirement no longer aborts. A valid RGB→Composite graph still returns COMPOSITOR_RESULT_MISSING; recorded as a residual. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -20721,16 +20721,29 @@ bool web_engine_blend_main_compositor_evaluate(WebBlendMainState *state,
|
|||||||
error = "COMPOSITOR_RENDER_UNAVAILABLE";
|
error = "COMPOSITOR_RENDER_UNAVAILABLE";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
RE_compositor_execute(*render,
|
/* The embedded host can run without an active WM GPU context (for example the
|
||||||
*state->main,
|
* Compositing workspace has no 3D viewport). The GPU compositor path calls
|
||||||
*scene,
|
* DRW_gpu_context_enable and fails in that state; force CPU for this preview
|
||||||
scene->r,
|
* evaluation and restore the scene setting immediately afterwards. */
|
||||||
*tree,
|
const eCompositorDevice previous_device = scene->r.compositor_device;
|
||||||
"",
|
scene->r.compositor_device = SCE_COMPOSITOR_DEVICE_CPU;
|
||||||
nullptr,
|
try {
|
||||||
/* NodeGroupOutputTypes::GroupOutputNode (1); the compositor
|
RE_compositor_execute(*render,
|
||||||
* header is not on the web_engine include path. */
|
*state->main,
|
||||||
static_cast<compositor::NodeGroupOutputTypes>(1));
|
*scene,
|
||||||
|
scene->r,
|
||||||
|
*tree,
|
||||||
|
"",
|
||||||
|
nullptr,
|
||||||
|
/* NodeGroupOutputTypes::GroupOutputNode (1); the compositor
|
||||||
|
* header is not on the web_engine include path. */
|
||||||
|
static_cast<compositor::NodeGroupOutputTypes>(1));
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
scene->r.compositor_device = previous_device;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
scene->r.compositor_device = previous_device;
|
||||||
RenderResult *result = RE_AcquireResultRead(render);
|
RenderResult *result = RE_AcquireResultRead(render);
|
||||||
if (result == nullptr || !result->have_combined) {
|
if (result == nullptr || !result->have_combined) {
|
||||||
if (result != nullptr) {
|
if (result != nullptr) {
|
||||||
|
|||||||
@@ -456,6 +456,17 @@
|
|||||||
`INVALID_ARGUMENT: COMPOSITOR_NODE_GROUP_MISSING: scene has no
|
`INVALID_ARGUMENT: COMPOSITOR_NODE_GROUP_MISSING: scene has no
|
||||||
compositing node group`。此前错误对象被渲染为 `[object Object]`,已在
|
compositing node group`。此前错误对象被渲染为 `[object Object]`,已在
|
||||||
`App.tsx` 规范化 code/message;证据 `probe-compositor.mjs`。
|
`App.tsx` 规范化 code/message;证据 `probe-compositor.mjs`。
|
||||||
|
- Compositor 求值(2026-11-14 深挖):
|
||||||
|
- 提交图后调用 `WASM 合成求值` 曾报
|
||||||
|
`Browser draw manager must be created once per WM canvas`;已在
|
||||||
|
`web_engine_blend_main_compositor_evaluate` 中临时把
|
||||||
|
`scene.r.compositor_device` 切到 CPU(求值后恢复),消除该 GPU
|
||||||
|
上下文依赖(WASM `198d2f01...`)。
|
||||||
|
- 用正确命令 `setCompositorNodeGraph` 提交 `RGB → Composite` 图(原生
|
||||||
|
树确认为 `CompositorNodeRGB.Color → NodeGroupOutput.Image`)后,
|
||||||
|
`compositorEvaluate` 仍返回 `INVALID_ARGUMENT: COMPOSITOR_RESULT_MISSING`。
|
||||||
|
这是当前 WASM 合成求值的真实残余阻塞,需要补齐 RenderResult/
|
||||||
|
have_combined 初始化;证据 `probe-compositor-eval.mjs`。
|
||||||
|
|
||||||
## 下一动作
|
## 下一动作
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"task": "WBV2-P1425-001",
|
"task": "WBV2-P1425-001",
|
||||||
"updatedAt": "2026-11-14T07:38:00+08:00",
|
"updatedAt": "2026-11-14T07:49:00+08:00",
|
||||||
"status": "in_progress",
|
"status": "in_progress",
|
||||||
"focus": "COMPLETE-TUTORIAL-001 backend export gap (USD/Alembic)",
|
"focus": "COMPLETE-TUTORIAL-001 backend export gap (USD/Alembic)",
|
||||||
"breakpoint": "blender-5.2.0/source/blender/web_engine/CMakeLists.txt (USD wiring); WASM 6ee2b261",
|
"breakpoint": "blender-5.2.0/source/blender/web_engine/CMakeLists.txt (USD wiring); WASM 6ee2b261",
|
||||||
@@ -236,5 +236,12 @@
|
|||||||
"after": "Noise Texture 2→3 (ShaderNodeTexNoise); Emission 2→3 (ShaderNodeEmission)",
|
"after": "Noise Texture 2→3 (ShaderNodeTexNoise); Emission 2→3 (ShaderNodeEmission)",
|
||||||
"wasmSha256": "fc6d0cb1a0f4f003dd7317f8d0143d7d16790c9f5f1f3120f359ac6af9aefe36",
|
"wasmSha256": "fc6d0cb1a0f4f003dd7317f8d0143d7d16790c9f5f1f3120f359ac6af9aefe36",
|
||||||
"acceptance": "NOT_CLAIMED"
|
"acceptance": "NOT_CLAIMED"
|
||||||
|
},
|
||||||
|
"compositorEval": {
|
||||||
|
"fix": "force scene.r.compositor_device=CPU during the WASM compositor preview evaluation and restore it after (removes the Browser draw manager GPU-context error)",
|
||||||
|
"residual": "valid RGB→Composite graph still returns COMPOSITOR_RESULT_MISSING (no combined RenderResult); needs render-result initialization",
|
||||||
|
"wasmSha256": "198d2f01e8205d7316fa56e763d475452e82eb85d8cf3eb888ac98e2264a6da6",
|
||||||
|
"script": "tools/web/complete/probe-compositor-eval.mjs",
|
||||||
|
"acceptance": "NOT_CLAIMED"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
79
tools/web/complete/probe-compositor-eval.mjs
Normal file
79
tools/web/complete/probe-compositor-eval.mjs
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
/**
|
||||||
|
* Focused case: commit a connected compositor graph (RGB -> Composite) and run
|
||||||
|
* the WASM CPU compositor evaluation through the product worker.
|
||||||
|
*
|
||||||
|
* node tools/web/complete/probe-compositor-eval.mjs --base-url http://127.0.0.1:5176
|
||||||
|
*/
|
||||||
|
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 browser = await launchBrowser(args.gpu);
|
||||||
|
const { context, page, consoleErrors } = await newPage(browser, {});
|
||||||
|
page.setDefaultTimeout(90_000);
|
||||||
|
await page.addInitScript(() => {
|
||||||
|
const NativeWorker = window.Worker;
|
||||||
|
window.__probeWorkers = [];
|
||||||
|
window.__probeMessages = [];
|
||||||
|
window.Worker = class extends NativeWorker {
|
||||||
|
constructor(...params) {
|
||||||
|
super(...params);
|
||||||
|
window.__probeWorkers.push(this);
|
||||||
|
this.addEventListener("message", (event) => window.__probeMessages.push(event.data));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts);
|
||||||
|
const request = async (command) => {
|
||||||
|
const requestId = `probe-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
||||||
|
return await page.evaluate(({ requestId, command }) => new Promise((resolve) => {
|
||||||
|
const started = Date.now();
|
||||||
|
const read = () => {
|
||||||
|
const hit = window.__probeMessages.find((message) => message && message.requestId === requestId && message.kind === "result");
|
||||||
|
if (hit) { clearInterval(timer); resolve(hit); return; }
|
||||||
|
if (Date.now() - started > 240000) { clearInterval(timer); resolve({ timeout: true }); }
|
||||||
|
};
|
||||||
|
const timer = setInterval(read, 250);
|
||||||
|
for (const worker of window.__probeWorkers) worker.postMessage({ requestId, command });
|
||||||
|
}), { requestId, command }, { timeout: 300_000 });
|
||||||
|
};
|
||||||
|
const python = (source) => request({ type: "jsonCommand", cmd: "pythonExec", params: { source, filename: "ProbeCompEval.py", console: false } });
|
||||||
|
try {
|
||||||
|
await openApp(page, BASE);
|
||||||
|
await openFile(page, ASSETS.studio);
|
||||||
|
await waitScene(page, { objects: 6, timeout: 240_000 });
|
||||||
|
const sceneResult = await python("import bpy, json\nprint('SCENE ' + json.dumps({'name': bpy.context.scene.name}))");
|
||||||
|
const sceneId = `scene:${JSON.parse(sceneResult.result.json.output.split('SCENE ')[1].trim()).name}`;
|
||||||
|
log("scene", sceneId);
|
||||||
|
const graph = {
|
||||||
|
schemaVersion: 1,
|
||||||
|
id: "probe-graph",
|
||||||
|
name: "Probe Compositor",
|
||||||
|
outputNodeId: "out",
|
||||||
|
nodes: [
|
||||||
|
{ id: "rgb", type: "CONSTANT_COLOR", name: "RGB", properties: { color: [1, 0, 0, 1] }, location: { x: 0, y: 0 } },
|
||||||
|
{ id: "out", type: "COMPOSITE", name: "Composite", properties: {}, location: { x: 300, y: 0 } },
|
||||||
|
],
|
||||||
|
links: [{ fromNodeId: "rgb", fromSocket: "Image", toNodeId: "out", toSocket: "Image" }],
|
||||||
|
resources: [],
|
||||||
|
};
|
||||||
|
const committed = await request({ type: "applyCommand", payload: { type: "setCompositorNodeGraph", sceneId, graph } });
|
||||||
|
log("commit", JSON.stringify({ ok: committed.ok, error: committed.error, revision: committed.result?.snapshot?.revision }));
|
||||||
|
const treeResult = await python(`import bpy, json
|
||||||
|
scene = bpy.context.scene
|
||||||
|
tree = getattr(scene, 'compositing_node_group', None)
|
||||||
|
nodes = [{'name': node.name, 'type': node.bl_idname} for node in tree.nodes] if tree else []
|
||||||
|
links = [{'from': link.from_node.name, 'fromSocket': link.from_socket.name, 'to': link.to_node.name, 'toSocket': link.to_socket.name} for link in tree.links] if tree else []
|
||||||
|
print('TREE ' + json.dumps({'nodes': nodes, 'links': links}))`);
|
||||||
|
log("tree", treeResult.result?.json?.output ?? null);
|
||||||
|
const evaluated = await request({ type: "jsonCommand", cmd: "compositorEvaluate", params: { sceneId } });
|
||||||
|
const payload = evaluated.result?.json;
|
||||||
|
log("evaluate", JSON.stringify({ ok: evaluated.ok, error: evaluated.error, width: payload?.width, height: payload?.height, pixels: typeof payload?.pixelsBase64 === "string" ? payload.pixelsBase64.length : null }));
|
||||||
|
} catch (error) {
|
||||||
|
log("probe error", error instanceof Error ? error.message : String(error));
|
||||||
|
} finally {
|
||||||
|
log("consoleErrors", JSON.stringify(consoleErrors.slice(-8)));
|
||||||
|
await context.close();
|
||||||
|
await browser.close();
|
||||||
|
}
|
||||||
111
tools/web/complete/probe-compositor-graph.mjs
Normal file
111
tools/web/complete/probe-compositor-graph.mjs
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
/**
|
||||||
|
* Focused case: edit mode -> select all -> UV -> 展开(角度) on a mesh.
|
||||||
|
*
|
||||||
|
* node tools/web/complete/probe-compositor-graph.mjs --base-url http://127.0.0.1:5176
|
||||||
|
*/
|
||||||
|
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 browser = await launchBrowser(args.gpu);
|
||||||
|
const { context, page, consoleErrors } = await newPage(browser, {});
|
||||||
|
page.setDefaultTimeout(90_000);
|
||||||
|
await page.addInitScript(() => {
|
||||||
|
const NativeWorker = window.Worker;
|
||||||
|
window.__probeWorkers = [];
|
||||||
|
window.__probeMessages = [];
|
||||||
|
window.Worker = class extends NativeWorker {
|
||||||
|
constructor(...params) {
|
||||||
|
super(...params);
|
||||||
|
window.__probeWorkers.push(this);
|
||||||
|
this.addEventListener("message", (event) => window.__probeMessages.push(event.data));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts);
|
||||||
|
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 started = Date.now();
|
||||||
|
const read = () => {
|
||||||
|
const hit = window.__probeMessages.find((message) => message && message.requestId === requestId && message.kind === "result");
|
||||||
|
if (hit) { clearInterval(timer); resolve(hit); return; }
|
||||||
|
if (Date.now() - started > 240000) { clearInterval(timer); resolve({ timeout: true }); }
|
||||||
|
};
|
||||||
|
const timer = setInterval(read, 250);
|
||||||
|
for (const worker of window.__probeWorkers) worker.postMessage({ requestId, command: { type: "jsonCommand", cmd: "pythonExec", params: { source, filename: "ProbeCompGraph.py", console: false } } });
|
||||||
|
}), { requestId, source }, { timeout: 300_000 });
|
||||||
|
};
|
||||||
|
const compState = async () => {
|
||||||
|
const result = await python(`
|
||||||
|
import bpy, json
|
||||||
|
scene = bpy.context.scene
|
||||||
|
tree = getattr(scene, 'compositing_node_group', None) or getattr(scene, 'node_tree', None)
|
||||||
|
nodes = [{'name': node.name, 'type': node.bl_idname} for node in tree.nodes] if tree else []
|
||||||
|
print('COMP ' + json.dumps({'nodes': nodes, 'use_compositing': scene.render.use_compositing}))
|
||||||
|
`);
|
||||||
|
const out = result?.result?.json;
|
||||||
|
const ui = await page.evaluate(() => ({
|
||||||
|
canvas: document.querySelector('[data-testid="compositor-canvas"]')?.getAttribute('data-node-count') ?? null,
|
||||||
|
status: document.querySelector('[data-testid="engine-status"]')?.textContent ?? "",
|
||||||
|
}));
|
||||||
|
return { state: out?.state, output: out?.output, error: out?.error, ...ui };
|
||||||
|
};
|
||||||
|
const menu = async (label, item) => {
|
||||||
|
await page.getByRole("button", { name: label, exact: true }).click();
|
||||||
|
await page.getByRole("menuitem", { name: item, exact: true }).click();
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
await openApp(page, BASE);
|
||||||
|
await openFile(page, ASSETS.studio);
|
||||||
|
await waitScene(page, { objects: 6, timeout: 240_000 });
|
||||||
|
await page.locator('select[aria-label^="切换 "]').first().selectOption("Compositor");
|
||||||
|
const canvas = page.locator('[data-testid="compositor-canvas"]').first();
|
||||||
|
await canvas.waitFor({ timeout: 30_000 });
|
||||||
|
log("before", JSON.stringify(await compState()));
|
||||||
|
const types = await canvas.locator('select[aria-label="添加节点类型"] option').evaluateAll((nodes) => nodes.map((node) => node.value));
|
||||||
|
log("types", JSON.stringify(types.slice(0, 12)));
|
||||||
|
const addType = types.includes("CONSTANT_COLOR") ? "CONSTANT_COLOR" : types[0];
|
||||||
|
log("addType", addType);
|
||||||
|
await canvas.locator('select[aria-label="添加节点类型"]').selectOption(addType);
|
||||||
|
await canvas.getByRole("button", { name: "添加节点", exact: true }).evaluate((element) => element.click());
|
||||||
|
await page.waitForTimeout(800);
|
||||||
|
log("added", JSON.stringify(await compState()));
|
||||||
|
const fit = page.locator('.react-flow__controls-fitview').first();
|
||||||
|
if (await fit.count()) { await fit.click({ force: true }); await page.waitForTimeout(600); }
|
||||||
|
const sourceHandle = canvas.locator('.react-flow__node', { hasText: "CONSTANT_COLOR" }).locator('[data-handleid="OUT:Image"]').first();
|
||||||
|
const targetHandle = canvas.locator('.react-flow__node', { hasText: "COMPOSITE" }).locator('[data-handleid="IN:Image"]').first();
|
||||||
|
const sourceBox = await sourceHandle.boundingBox();
|
||||||
|
const targetBox = await targetHandle.boundingBox();
|
||||||
|
log("boxes", JSON.stringify({ sourceBox, targetBox }));
|
||||||
|
if (sourceBox && targetBox) {
|
||||||
|
await page.mouse.move(sourceBox.x + sourceBox.width / 2, sourceBox.y + sourceBox.height / 2);
|
||||||
|
await page.mouse.down();
|
||||||
|
await page.mouse.move(targetBox.x + targetBox.width / 2, targetBox.y + targetBox.height / 2, { steps: 12 });
|
||||||
|
await page.mouse.up();
|
||||||
|
await page.waitForTimeout(600);
|
||||||
|
}
|
||||||
|
log("linked", JSON.stringify(await compState()));
|
||||||
|
await canvas.getByRole("button", { name: "提交图", exact: true }).evaluate((element) => element.click());
|
||||||
|
await page.waitForTimeout(2500);
|
||||||
|
log("committed", JSON.stringify(await compState()));
|
||||||
|
const panel = page.locator('[data-testid="scene-pipeline-settings-workbench"]').first();
|
||||||
|
await panel.waitFor({ timeout: 30_000 });
|
||||||
|
await panel.getByRole("button", { name: "WASM 合成求值", exact: true }).evaluate((element) => element.click());
|
||||||
|
for (let index = 0; index < 120; index++) {
|
||||||
|
await page.waitForTimeout(500);
|
||||||
|
const current = await compState();
|
||||||
|
const evalStatus = await page.evaluate(() => document.querySelector('[data-testid="scene-pipeline-settings-workbench"] output[role="status"]')?.textContent ?? "");
|
||||||
|
const hasImage = await page.evaluate(() => Boolean(document.querySelector('[data-testid="scene-pipeline-settings-workbench"] img')));
|
||||||
|
if (hasImage || (evalStatus && !/求值中/.test(evalStatus))) { log("evaluated", JSON.stringify({ ...current, evalStatus, hasImage })); break; }
|
||||||
|
if (index === 119) log("eval timeout", JSON.stringify({ ...current, evalStatus, hasImage }));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
log("probe error", error instanceof Error ? error.message : String(error));
|
||||||
|
log("state", JSON.stringify(await compState().catch(() => null)));
|
||||||
|
} finally {
|
||||||
|
log("consoleErrors", JSON.stringify(consoleErrors.slice(-10)));
|
||||||
|
await context.close();
|
||||||
|
await browser.close();
|
||||||
|
}
|
||||||
BIN
web/app/public/vendor/blender/web_engine.wasm
vendored
BIN
web/app/public/vendor/blender/web_engine.wasm
vendored
Binary file not shown.
@@ -10,7 +10,7 @@
|
|||||||
"single": {
|
"single": {
|
||||||
"fileName": "web_engine.wasm",
|
"fileName": "web_engine.wasm",
|
||||||
"url": "/vendor/blender/web_engine.wasm",
|
"url": "/vendor/blender/web_engine.wasm",
|
||||||
"sha256": "fc6d0cb1a0f4f003dd7317f8d0143d7d16790c9f5f1f3120f359ac6af9aefe36"
|
"sha256": "198d2f01e8205d7316fa56e763d475452e82eb85d8cf3eb888ac98e2264a6da6"
|
||||||
},
|
},
|
||||||
"pthread": {
|
"pthread": {
|
||||||
"fileName": "web_engine.wasm",
|
"fileName": "web_engine.wasm",
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
"single": {
|
"single": {
|
||||||
"fileName": "web_engine.wasm",
|
"fileName": "web_engine.wasm",
|
||||||
"url": "/vendor/blender/web_engine.wasm",
|
"url": "/vendor/blender/web_engine.wasm",
|
||||||
"sha256": "fc6d0cb1a0f4f003dd7317f8d0143d7d16790c9f5f1f3120f359ac6af9aefe36"
|
"sha256": "198d2f01e8205d7316fa56e763d475452e82eb85d8cf3eb888ac98e2264a6da6"
|
||||||
},
|
},
|
||||||
"pthread": {
|
"pthread": {
|
||||||
"fileName": "web_engine.wasm",
|
"fileName": "web_engine.wasm",
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
"single": {
|
"single": {
|
||||||
"fileName": "web_engine.wasm",
|
"fileName": "web_engine.wasm",
|
||||||
"url": "/vendor/blender/web_engine.wasm",
|
"url": "/vendor/blender/web_engine.wasm",
|
||||||
"sha256": "fc6d0cb1a0f4f003dd7317f8d0143d7d16790c9f5f1f3120f359ac6af9aefe36"
|
"sha256": "198d2f01e8205d7316fa56e763d475452e82eb85d8cf3eb888ac98e2264a6da6"
|
||||||
},
|
},
|
||||||
"pthread": {
|
"pthread": {
|
||||||
"fileName": "web_engine.wasm",
|
"fileName": "web_engine.wasm",
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
"single": {
|
"single": {
|
||||||
"fileName": "web_engine.wasm",
|
"fileName": "web_engine.wasm",
|
||||||
"url": "/vendor/blender/web_engine.wasm",
|
"url": "/vendor/blender/web_engine.wasm",
|
||||||
"sha256": "fc6d0cb1a0f4f003dd7317f8d0143d7d16790c9f5f1f3120f359ac6af9aefe36"
|
"sha256": "198d2f01e8205d7316fa56e763d475452e82eb85d8cf3eb888ac98e2264a6da6"
|
||||||
},
|
},
|
||||||
"pthread": {
|
"pthread": {
|
||||||
"fileName": "web_engine.wasm",
|
"fileName": "web_engine.wasm",
|
||||||
|
|||||||
BIN
web/app/src/vendor/blender/web_engine.wasm
vendored
BIN
web/app/src/vendor/blender/web_engine.wasm
vendored
Binary file not shown.
Reference in New Issue
Block a user