fix(web): decimate ratio writes refresh the evaluated modifier stack
The modifier merge ran after refresh_scene_from_main round-tripped Main through the blend format, which dropped the DEG tag issued by the setter, so DEG_get_evaluated kept publishing the previous COW copy: Ratio 0.1 was visible in Main and in the snapshot parameters while triangleCount and python to_mesh() stayed at the add-time 968 until an external update_tag()+view_layer.update(). - engine: tag every modifier owner with DEG_id_tag_update_ex(state->main, ID_RECALC_ALL) before merge evaluation and update through BKE_scene_graph_update_tagged (same call ViewLayer.update uses). - tests: mode menu items are menuitemcheckbox; select-all lives in the header 选择 ▸ 全部 menu, not 网格 ▸ 选择工具. - runner: archive per-case evidence JSON under artifacts/evidence; checker reads fixtures.desktopOracle instead of a missing top-level key. - docs: record the root cause, fix and receipt MESH-DECIMATE-HEADED-20261129-012441. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -12627,6 +12627,18 @@ bool web_engine_blend_main_merge_modifier_snapshot(WebBlendMainState *state,
|
||||
using json = nlohmann::json;
|
||||
try {
|
||||
json snapshot = json::parse(snapshot_json);
|
||||
/* Callers reach this merge through refresh_scene_from_main, which writes and
|
||||
* re-reads Main; that drops every DEG_id_tag_update issued while mutating
|
||||
* the modifier, so the update below would keep publishing the previous COW
|
||||
* copy. Re-tag the modifier owners here, before the graph update. */
|
||||
if (state != nullptr && state->main != nullptr) {
|
||||
LISTBASE_FOREACH (Object *, object, &state->main->objects) {
|
||||
if (object->modifiers.first != nullptr) {
|
||||
/* Same tag ViewLayer.update() relies on after Object.update_tag(). */
|
||||
DEG_id_tag_update_ex(state->main, &object->id, ID_RECALC_ALL);
|
||||
}
|
||||
}
|
||||
}
|
||||
Depsgraph *depsgraph = nullptr;
|
||||
for (json &mesh : snapshot["meshes"]) {
|
||||
const std::string mesh_id = mesh.value("id", "");
|
||||
@@ -12671,7 +12683,10 @@ bool web_engine_blend_main_merge_modifier_snapshot(WebBlendMainState *state,
|
||||
static_cast<ViewLayer *>(state->scene->view_layers.first);
|
||||
if (view_layer == nullptr) continue;
|
||||
depsgraph = BKE_scene_ensure_depsgraph(state->main, state->scene, view_layer);
|
||||
BKE_scene_graph_update_for_newframe(depsgraph);
|
||||
/* Match ViewLayer.update(), which is the only path that has been shown
|
||||
* to consume modifier tags in this runtime; update_for_newframe left
|
||||
* the previous COW copy in place. */
|
||||
BKE_scene_graph_update_tagged(depsgraph, state->main);
|
||||
}
|
||||
Object *object_eval = DEG_get_evaluated(depsgraph, object);
|
||||
Mesh *mesh_eval = object_eval != nullptr ? BKE_object_get_evaluated_mesh(object_eval) : nullptr;
|
||||
|
||||
@@ -437,3 +437,34 @@ Web 视图里在大纲中 Ctrl+点击选中两个对象后,原生选择被覆
|
||||
**5. 声明**
|
||||
|
||||
- `acceptance: NOT_CLAIMED`:本工具尚未运行;本记录不含任何通过结论,单次有头通过只代表该候选、该环境。
|
||||
|
||||
### Decimate 有头验证与 ratio 写入缺口修复(回执 MESH-DECIMATE-HEADED-20261129-012441)
|
||||
|
||||
**1. 验证结果**
|
||||
|
||||
- 候选 `/home/mes123456/workinf_Blender_Wasm/web/dist`,wasm sha256 `f0a528ae44be8335d4c340bcc5d08ffb1e450b9e5420318dba50370d4fab8280`。
|
||||
- `node tools/web/run-mesh-decimate-headed.mjs --grep dec-monkey`:PASS 4 / FAIL 0(`MESH-DECIMATE-HEADED-20261129-012441`)。
|
||||
- `check-mesh-decimate-headed.mjs`:PASS;桌面参考 `tests/golden/MESH-DECIMATE-DESKTOP/desktop-decimate.json`(sha256 `043370b6…`)已绑定,4 条用例的桌面对照断言实际执行。
|
||||
- 用例证据 JSON 归档到回执 `artifacts/evidence/`。
|
||||
|
||||
**2. 修复的缺口:修改器参数写入后求值副本不刷新**
|
||||
|
||||
- 现象:UI 把 Ratio 写成 0.1 后,Main 读回 `m.ratio == 0.1`、快照 `editableParameters.ratio == 0.1`,但求值副本 `evalRatio == 1`、三角数仍 968;同引擎 python 直接 `to_mesh()` 也是 968,只有 `update_tag()+view_layer.update()` 后才变 96。
|
||||
- 根因:`refresh_scene_from_main` 把 Main 写盘再解析(快照),setter 里的 `DEG_id_tag_update` 在图更新前已被丢弃;`web_engine_blend_main_merge_modifier_snapshot` 随后的图更新在没有 tag 的情况下沿用了旧 COW 副本。
|
||||
- 修复(`blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp`,单文件):merge 求值前对所有带修改器的对象执行 `DEG_id_tag_update_ex(state->main, &object->id, ID_RECALC_ALL)`,并把求值调用改为 `BKE_scene_graph_update_tagged(depsgraph, state->main)`——与 `ViewLayer.update()`(`makesrna/intern/rna_layer.cc:235`)一致的调用。
|
||||
- 效果:设置 Ratio 的同一条命令内,三角数 968→96、`evaluationStatus=EVALUATED`、`evaluatedRatio=0.1`;移除/应用/撤销断言不变。
|
||||
|
||||
**3. 测试与工具修正(非产品缺口)**
|
||||
|
||||
- 模式芯片菜单项角色是 `menuitemcheckbox`(不是 `menuitem`)。
|
||||
- 编辑模式「全选」的真实入口是头部「选择 ▸ 全部」(`selectHeader`);本移植没有「网格 ▸ 选择工具」子菜单。
|
||||
- 运行器新增用例证据归档(`artifacts/evidence/`);校验器改读 `fixtures.desktopOracle`(此前误读不存在的顶层字段,误报 missing)。
|
||||
|
||||
**4. 残余**
|
||||
|
||||
- `web/tests/e2e/mesh-simplify-production.spec.ts` 11 例失败于「控制台错误必须为空」断言:记录中只有 WASM 运行时 `warning: unsupported syscall: __syscall_mprotect`;同文件的几何/修改器断言均通过。该警告是运行时桩消息,与本次 3 行打标改动无逻辑关联,但未做 A/B 归因,需单独排查。
|
||||
- 本批只跑了 `dec-monkey` 4 例与该简化套件;其余套件未回归。
|
||||
|
||||
**5. 声明**
|
||||
|
||||
- `acceptance: NOT_CLAIMED`:单次有头通过只代表该候选、该环境,不给出整体完成度。
|
||||
|
||||
@@ -102,3 +102,20 @@ node tools/web/generate-decimate-golden.mjs \
|
||||
- 原生表面用例通过 `window.__nativeWorkflowEngine` 的 python 读回取值;React 快照在 `/` 模式下不随原始 worker 消息刷新,断言以 worker `snapshot` 为准。
|
||||
- 修改器栈求值只对单用户网格、对象模式、≥1 个启用修改器生效;多用户网格或编辑模式下的栈按 `METADATA_ONLY`/`BLOCKED` 如实报告,不冒充求值。
|
||||
- 有头单次通过只代表该候选、该环境;`acceptance: NOT_CLAIMED`,不给整体完成度。
|
||||
|
||||
## 修改器参数写入的求值语义(回执 MESH-DECIMATE-HEADED-20261129-012441)
|
||||
|
||||
- `setModifierParameters` 之后,求值几何在同一条命令内刷新:`web_engine_blend_main_merge_modifier_snapshot` 在求值前对带修改器的对象执行 `DEG_id_tag_update_ex(state->main, id, ID_RECALC_ALL)`,并用 `BKE_scene_graph_update_tagged` 更新(与 `ViewLayer.update()` 相同)。
|
||||
- 原因:`refresh_scene_from_main` 的写盘/解析会丢弃 setter 发出的 tag;没有重新打标时 merge 会继续发布旧 COW 副本(快照与 python `to_mesh()` 都读到旧三角数,只有外部 `update_tag()+view_layer.update()` 才能刷新)。
|
||||
- 推论:只读 `type:'snapshot'` 不触发求值,看到的是最近一次刷新的结果;新增/改参/移除修改器、应用与撤销都以各自命令的刷新为准。
|
||||
|
||||
### 有头用例的菜单口径(本移植)
|
||||
|
||||
- 模式菜单项角色是 `menuitemcheckbox`(`Object Mode` 芯片 → `编辑模式` / `物体模式`),不是 `menuitem`。
|
||||
- 编辑模式「全选」入口是头部 `选择 ▸ 全部`(`selectHeader('all')`);没有 `网格 ▸ 选择工具` 子菜单。
|
||||
- 简化几何入口:`网格 ▸ 清理 ▸ 简化几何…`,对话框内填比例后确认。
|
||||
|
||||
### 残余补充
|
||||
|
||||
- 用例证据 JSON 由运行器归档到回执 `artifacts/evidence/`;Playwright 仅对失败用例保留附件路径,运行器按本次运行时间过滤 `web/test-results/**/decimate-*.json` 复制。
|
||||
- `web/tests/e2e/mesh-simplify-production.spec.ts` 当前失败于「控制台错误必须为空」断言(记录里只有 `warning: unsupported syscall: __syscall_mprotect`),几何断言通过;与本次改动的关系未做 A/B 归因,单独排查。
|
||||
|
||||
@@ -138,4 +138,4 @@ if (errors.length > 0) {
|
||||
console.error(JSON.stringify({ status: "FAIL", errors }, null, 2));
|
||||
process.exit(1);
|
||||
}
|
||||
console.log(JSON.stringify({ status: "PASS", report: reportFile, cases: cases.length, artifacts: artifactCount, candidate, wasmSha256: report.release?.wasmSha256, desktopOracle: report.desktopOracle ?? "missing" }, null, 2));
|
||||
console.log(JSON.stringify({ status: "PASS", report: reportFile, cases: cases.length, artifacts: artifactCount, candidate, wasmSha256: report.release?.wasmSha256, desktopOracle: report.fixtures?.desktopOracle ?? "missing" }, null, 2));
|
||||
|
||||
@@ -185,6 +185,27 @@ function copyArtifacts(cases) {
|
||||
}
|
||||
}
|
||||
|
||||
function collectEvidence(startedMs) {
|
||||
const base = path.join(WEB_DIR, "test-results");
|
||||
const directory = path.join(reportDir, "artifacts", "evidence");
|
||||
const collected = [];
|
||||
if (!fs.existsSync(base)) return collected;
|
||||
fs.mkdirSync(directory, { recursive: true });
|
||||
for (const entry of fs.readdirSync(base)) {
|
||||
const candidate = path.join(base, entry);
|
||||
if (!fs.statSync(candidate).isDirectory()) continue;
|
||||
for (const file of fs.readdirSync(candidate)) {
|
||||
if (!/^decimate-.*\.json$/.test(file)) continue;
|
||||
const source = path.join(candidate, file);
|
||||
if (fs.statSync(source).mtimeMs < startedMs - 1000) continue;
|
||||
const target = path.join(directory, file);
|
||||
fs.copyFileSync(source, target);
|
||||
collected.push({ name: file, path: path.relative(reportDir, target), sha256: sha256File(target), bytes: fs.statSync(target).size });
|
||||
}
|
||||
}
|
||||
return collected;
|
||||
}
|
||||
|
||||
function renderHtml(report) {
|
||||
const rows = report.cases.map((item) => `<tr><td>${item.caseId}</td><td>${item.title}</td><td class="${item.status}">${item.status}</td><td>${item.artifacts.map((artifact) => `<a href="${artifact.path}">${artifact.name}</a>`).join(" ")}</td><td><pre>${item.error ?? ""}</pre></td></tr>`).join("");
|
||||
const checks = report.preflight.map((item) => `<tr><td>${item.name}</td><td class="${item.ok ? "PASS" : "FAIL"}">${item.ok ? "OK" : "FAIL"}</td><td>${JSON.stringify(item.detail)}</td></tr>`).join("");
|
||||
@@ -276,6 +297,7 @@ function writeBlocked(detail) {
|
||||
const cases = [];
|
||||
flattenSuites(raw.suites, null, cases);
|
||||
copyArtifacts(cases);
|
||||
const evidence = collectEvidence(started);
|
||||
if (cases.length === 0) { writeBlocked("Playwright reported no cases (check --grep/testMatch)"); fs.rmSync(jsonPath, { force: true }); process.exit(2); }
|
||||
|
||||
const caseIds = new Set(cases.filter((item) => item.status !== "SKIP").map((item) => item.caseId));
|
||||
@@ -302,7 +324,7 @@ function writeBlocked(detail) {
|
||||
candidate: options.candidate,
|
||||
release, fixtures,
|
||||
environment: { display, gpuMode: options.headed ? "hardware" : "swiftshader", browser: options.headed ? "chromium-headed" : "chromium-headless", chrome: chromeVersion, chromePath, node: process.version, port: options.port, workers: options.workers },
|
||||
preflight, cases, summary,
|
||||
preflight, cases, evidence, summary,
|
||||
errors: missingCaseIds.length ? [`missing expected cases: ${missingCaseIds.join(", ")}`] : [],
|
||||
acceptance: "NOT_CLAIMED",
|
||||
};
|
||||
|
||||
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": {
|
||||
"fileName": "web_engine.wasm",
|
||||
"url": "/vendor/blender/web_engine.wasm",
|
||||
"sha256": "e9d98b7b2b2890a11287a183d64f6714708e2ff0de492b3b3de4af1731dbb05a"
|
||||
"sha256": "f0a528ae44be8335d4c340bcc5d08ffb1e450b9e5420318dba50370d4fab8280"
|
||||
},
|
||||
"pthread": {
|
||||
"fileName": "web_engine.wasm",
|
||||
@@ -27,7 +27,7 @@
|
||||
"single": {
|
||||
"fileName": "web_engine.wasm",
|
||||
"url": "/vendor/blender/web_engine.wasm",
|
||||
"sha256": "e9d98b7b2b2890a11287a183d64f6714708e2ff0de492b3b3de4af1731dbb05a"
|
||||
"sha256": "f0a528ae44be8335d4c340bcc5d08ffb1e450b9e5420318dba50370d4fab8280"
|
||||
},
|
||||
"pthread": {
|
||||
"fileName": "web_engine.wasm",
|
||||
@@ -44,7 +44,7 @@
|
||||
"single": {
|
||||
"fileName": "web_engine.wasm",
|
||||
"url": "/vendor/blender/web_engine.wasm",
|
||||
"sha256": "e9d98b7b2b2890a11287a183d64f6714708e2ff0de492b3b3de4af1731dbb05a"
|
||||
"sha256": "f0a528ae44be8335d4c340bcc5d08ffb1e450b9e5420318dba50370d4fab8280"
|
||||
},
|
||||
"pthread": {
|
||||
"fileName": "web_engine.wasm",
|
||||
@@ -61,7 +61,7 @@
|
||||
"single": {
|
||||
"fileName": "web_engine.wasm",
|
||||
"url": "/vendor/blender/web_engine.wasm",
|
||||
"sha256": "e9d98b7b2b2890a11287a183d64f6714708e2ff0de492b3b3de4af1731dbb05a"
|
||||
"sha256": "f0a528ae44be8335d4c340bcc5d08ffb1e450b9e5420318dba50370d4fab8280"
|
||||
},
|
||||
"pthread": {
|
||||
"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.
@@ -4,7 +4,7 @@ import path from 'node:path';
|
||||
import { observeNative, performNativeAction } from '../fixtures/native-ui-workflow';
|
||||
import { webMain } from '../fixtures/console-main-workflow';
|
||||
import { openFromUI, pythonReply } from '../fixtures/wasm-console-workflow';
|
||||
import { nativeRequest, queryNativeJSON } from '../fixtures/native-modeling-workflow';
|
||||
import { nativeRequest, queryNativeJSON, waitNativeModal } from '../fixtures/native-modeling-workflow';
|
||||
|
||||
/* Headed Decimate (triangle simplification) suite on the monkey-head GLB.
|
||||
* Two desktop entries are exercised end to end:
|
||||
@@ -93,14 +93,25 @@ async function meshOf(page: Page, name: string) {
|
||||
return { snapshot, node, mesh };
|
||||
}
|
||||
|
||||
/** pythonExec that is allowed to change Main; returns the parsed stdout payload. */
|
||||
/** pythonExec that is allowed to change Main; returns the parsed stdout payload.
|
||||
* A previous native desktop gesture is retired on the next frame, and the engine
|
||||
* refuses edits until then (NATIVE_GESTURE_ACTIVE); wait for that frame. */
|
||||
async function pythonRun(page: Page, source: string, timeoutMs = 180000) {
|
||||
const response = await nativeRequest(page, { type: 'jsonCommand', cmd: 'pythonExec', params: { source: `exec(${JSON.stringify(source)}, {'__name__': '__wbv2_decimate__'})`, filename: 'M2Decimate.py', console: false } }, timeoutMs);
|
||||
const reply = await pythonReply(page);
|
||||
expect(reply, 'pythonExec must publish a console reply').not.toBeNull();
|
||||
expect(reply!.requestId).toBe(response.requestId);
|
||||
expect(reply!.state, reply!.output).toBe('DONE');
|
||||
return { revision: reply!.revision, changed: reply!.changed, value: JSON.parse(reply!.output) };
|
||||
for (let attempt = 0; ; attempt += 1) {
|
||||
try {
|
||||
const response = await nativeRequest(page, { type: 'jsonCommand', cmd: 'pythonExec', params: { source: `exec(${JSON.stringify(source)}, {'__name__': '__wbv2_decimate__'})`, filename: 'M2Decimate.py', console: false } }, timeoutMs);
|
||||
const reply = await pythonReply(page);
|
||||
expect(reply, 'pythonExec must publish a console reply').not.toBeNull();
|
||||
expect(reply!.requestId).toBe(response.requestId);
|
||||
expect(reply!.state, reply!.output).toBe('DONE');
|
||||
return { revision: reply!.revision, changed: reply!.changed, value: JSON.parse(reply!.output) };
|
||||
}
|
||||
catch (error) {
|
||||
if (attempt >= 20 || !/NATIVE_GESTURE_ACTIVE/.test((error as Error).message ?? '')) throw error;
|
||||
await waitNativeModal(page, false);
|
||||
await page.waitForTimeout(120);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const selectObject = (name: string) => `
|
||||
@@ -331,14 +342,13 @@ test('[dec-monkey-edit-web] 猴头:编辑模式 ▸ 网格 ▸ 清理 ▸ 简
|
||||
const triangleBefore = baseline.mesh.triangleCount;
|
||||
expect(triangleBefore).toBeGreaterThan(0);
|
||||
|
||||
/* Enter Edit Mode through the mode chip, then select all through 网格 ▸ 选择工具. */
|
||||
/* Enter Edit Mode through the mode chip, then select all through 选择 ▸ 全部. */
|
||||
await page.getByRole('button', { name: 'Object Mode', exact: true }).click();
|
||||
await page.getByRole('menuitem', { name: '编辑模式', exact: true }).click();
|
||||
await page.getByRole('menuitemcheckbox', { name: '编辑模式', exact: true }).click();
|
||||
const meshMenu = page.getByRole('button', { name: '网格', exact: true });
|
||||
await expect(meshMenu).toBeVisible({ timeout: 60000 });
|
||||
await meshMenu.click();
|
||||
await page.getByRole('menuitem', { name: '选择工具', exact: true }).click();
|
||||
await page.getByRole('menuitem', { name: '全选', exact: true }).click();
|
||||
await page.getByRole('button', { name: '选择', exact: true }).click();
|
||||
await page.getByRole('menuitem', { name: '全部', exact: true }).click();
|
||||
|
||||
/* G3: Mesh ▸ Clean Up ▸ Decimate Geometry. */
|
||||
await meshMenu.click();
|
||||
@@ -353,7 +363,7 @@ test('[dec-monkey-edit-web] 猴头:编辑模式 ▸ 网格 ▸ 清理 ▸ 简
|
||||
|
||||
/* Leave Edit Mode; the snapshot then carries the decimated triangles. */
|
||||
await page.getByRole('button', { name: 'Edit Mode', exact: true }).click();
|
||||
await page.getByRole('menuitem', { name: '物体模式', exact: true }).click();
|
||||
await page.getByRole('menuitemcheckbox', { name: '物体模式', exact: true }).click();
|
||||
await expect(page.getByRole('button', { name: 'Object Mode', exact: true })).toBeVisible({ timeout: 60000 });
|
||||
const decimated = await expect.poll(async () => (await meshOf(page, imported.name)).mesh.triangleCount, { timeout: 180000 }).toBeLessThanOrEqual(Math.ceil(triangleBefore * 0.65)).then(async () => (await meshOf(page, imported.name)).mesh);
|
||||
const kept = decimated.triangleCount / triangleBefore;
|
||||
|
||||
Reference in New Issue
Block a user