diff --git a/blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp b/blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp index 486b98175..3f6d59faf 100644 --- a/blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp +++ b/blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp @@ -72,6 +72,7 @@ #include "ED_scene.hh" #include "ED_select_utils.hh" #include "ED_object.hh" +#include "ED_armature.hh" #include "ED_mesh.hh" #include "ED_outliner.hh" #include "ED_view3d.hh" @@ -19503,6 +19504,11 @@ static void web_armature_sync_endpoints(Bone *bone) { copy_v3_v3(bone->arm_head, bone->arm_mat[3]); madd_v3_v3v3fl(bone->arm_tail, bone->arm_head, bone->arm_mat[1], bone->length); + /* Edit bones mirror arm_roll (armature space), which desktop refreshes on + * every edit-mode round trip; keep it current after runtime roll edits. */ + float arm_mat3[3][3]; + copy_m3_m4(arm_mat3, bone->arm_mat); + mat3_to_vec_roll(arm_mat3, nullptr, &bone->arm_roll); LISTBASE_FOREACH (Bone *, child, &bone->childbase) { web_armature_sync_endpoints(child); } @@ -19522,6 +19528,11 @@ static void web_armature_tag_update(WebBlendMainState *state, bArmature *armatur candidate.id.recalc |= ID_RECALC_GEOMETRY | ID_RECALC_TRANSFORM; } } + /* Desktop keeps bone authoring in the edit-bone list while the armature object + * is in Edit mode, and saving flushes that list back into object bones + * (ED_editors_flush_edits → ED_armature_from_edit). Mirror these object-bone + * edits into the edit bones so the save does not discard them. */ + if (armature->edbo != nullptr) ED_armature_to_edit(armature); } static Bone *web_armature_add_bone(bArmature *armature, diff --git a/web/app/public/vendor/blender/web_engine.wasm b/web/app/public/vendor/blender/web_engine.wasm index 7ab01a8ca..7a8c72dae 100644 Binary files a/web/app/public/vendor/blender/web_engine.wasm and b/web/app/public/vendor/blender/web_engine.wasm differ diff --git a/web/app/public/wasm-module-manifest.json b/web/app/public/wasm-module-manifest.json index 780c2f2fb..6ab5eff4f 100644 --- a/web/app/public/wasm-module-manifest.json +++ b/web/app/public/wasm-module-manifest.json @@ -10,7 +10,7 @@ "single": { "fileName": "web_engine.wasm", "url": "/vendor/blender/web_engine.wasm", - "sha256": "f07de0a823848a932ada2c69d9f605f32ad3a1de817c69f65cbb588a870a4e81" + "sha256": "b940dd921425f474b5a9ff8f3069a2025e07c22eeee51dcc9bb64f7a2d66bbc9" }, "pthread": { "fileName": "web_engine.wasm", @@ -27,7 +27,7 @@ "single": { "fileName": "web_engine.wasm", "url": "/vendor/blender/web_engine.wasm", - "sha256": "f07de0a823848a932ada2c69d9f605f32ad3a1de817c69f65cbb588a870a4e81" + "sha256": "b940dd921425f474b5a9ff8f3069a2025e07c22eeee51dcc9bb64f7a2d66bbc9" }, "pthread": { "fileName": "web_engine.wasm", @@ -44,7 +44,7 @@ "single": { "fileName": "web_engine.wasm", "url": "/vendor/blender/web_engine.wasm", - "sha256": "f07de0a823848a932ada2c69d9f605f32ad3a1de817c69f65cbb588a870a4e81" + "sha256": "b940dd921425f474b5a9ff8f3069a2025e07c22eeee51dcc9bb64f7a2d66bbc9" }, "pthread": { "fileName": "web_engine.wasm", @@ -61,7 +61,7 @@ "single": { "fileName": "web_engine.wasm", "url": "/vendor/blender/web_engine.wasm", - "sha256": "f07de0a823848a932ada2c69d9f605f32ad3a1de817c69f65cbb588a870a4e81" + "sha256": "b940dd921425f474b5a9ff8f3069a2025e07c22eeee51dcc9bb64f7a2d66bbc9" }, "pthread": { "fileName": "web_engine.wasm", diff --git a/web/app/src/app/app-shell.css b/web/app/src/app/app-shell.css index 78d4ce671..96675b217 100644 --- a/web/app/src/app/app-shell.css +++ b/web/app/src/app/app-shell.css @@ -369,7 +369,7 @@ button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus- .file-browser-query { padding: 4px 6px; } .file-browser-query input { width: 100%; padding: 3px 6px; color: #e0e2e6; background: #1d1d1d; border: 1px solid #3c3c3c; border-radius: 3px; } /* Diagnostic workbenches stay mounted for evidence but are hidden until asked for. */ -.properties-content[data-diagnostic-panels="hidden"] > .property-section[data-testid$="-workbench"]:not([data-testid="physics-workbench"]):not([data-testid="object-data-workbench"]) { display: none; } +.properties-content[data-diagnostic-panels="hidden"] > .property-section[data-testid$="-workbench"]:not([data-testid="physics-workbench"]):not([data-testid="object-data-workbench"]):not([data-testid="armature-authoring-workbench"]) { display: none; } .property-tab-diagnostics { margin-top: auto; } .preferences-paths { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: 11px; } .preferences-paths th { padding: 3px 6px; color: #9aa0a8; text-align: left; border-bottom: 1px solid #454545; } diff --git a/web/app/src/engine-client/WebEngineClient.ts b/web/app/src/engine-client/WebEngineClient.ts index 9f3ad5cc2..d605984ef 100644 --- a/web/app/src/engine-client/WebEngineClient.ts +++ b/web/app/src/engine-client/WebEngineClient.ts @@ -64,6 +64,10 @@ export interface WebEngineClientOptions { nativeServices?: boolean; timeoutMs?: number; workerFactory?: () => Worker; + /** false = run this instance without the shared OPFS native-files store and + * its exclusive `web-blender:native-files:/browser` lock (headless tooling and + * command-level tests); the editor window keeps the store. Default true. */ + nativeFiles?: boolean; onWorkerFault?: (fault: WorkerFault) => void; onNativeExitRequest?: (client: WebEngineClient) => void; onNativeRecoveryWarning?: (message: string) => void; @@ -72,8 +76,11 @@ export interface WebEngineClientOptions { } import { attachPageComputeRelay } from "./gpu-compute-relay"; -const defaultWorkerFactory = () => { - const worker = new Worker(new URL("../workers/web-engine.worker.ts", import.meta.url), { type: "module" }); +/* The worker name is the only channel available before its first command, so an + * instance that must not touch the shared native-files store is marked here. */ +const EPHEMERAL_WORKER_NAME = "web-engine-ephemeral"; +const defaultWorkerFactory = (nativeFiles = true) => { + const worker = new Worker(new URL("../workers/web-engine.worker.ts", import.meta.url), { type: "module", name: nativeFiles ? "web-engine" : EPHEMERAL_WORKER_NAME }); attachPageComputeRelay(worker); return worker; }; @@ -322,7 +329,7 @@ export class WebEngineClient { this.onAudioError = options.onAudioError ?? (message => console.error(message)); this.nativeServices=options.nativeServices!==false; this.timeoutMs = options.timeoutMs ?? 30_000; - this.workerFactory = options.workerFactory ?? defaultWorkerFactory; + this.workerFactory = options.workerFactory ?? (() => defaultWorkerFactory(options.nativeFiles !== false)); this.onWorkerFault = options.onWorkerFault; this.onNativeExitRequest = options.onNativeExitRequest; this.onNativeRecoveryWarning = options.onNativeRecoveryWarning ?? (message => console.warn(message)); diff --git a/web/app/src/vendor/blender/web_engine.wasm b/web/app/src/vendor/blender/web_engine.wasm index 7ab01a8ca..7a8c72dae 100644 Binary files a/web/app/src/vendor/blender/web_engine.wasm and b/web/app/src/vendor/blender/web_engine.wasm differ diff --git a/web/app/src/workers/web-engine.worker.ts b/web/app/src/workers/web-engine.worker.ts index 63089f4f1..3c7fd8c7c 100644 --- a/web/app/src/workers/web-engine.worker.ts +++ b/web/app/src/workers/web-engine.worker.ts @@ -155,6 +155,10 @@ const scope = self as unknown as { postMessage(message: WebEngineResponse, transfer?: Transferable[]): void; }; let module: WasmModule | null = null; +/* Instances created for headless tooling or command-level tests declare through + * their worker name that they run without the shared OPFS native-files store; + * they must not contend for its exclusive Web Lock or write to it. */ +const nativeFilesPersistent = (self as unknown as { name?: string }).name !== "web-engine-ephemeral"; const audioOutput = new NativeAudioTransport(); scope.postMessage({ kind: "audioOutput", port: audioOutput.port }, [audioOutput.port]); let wasmFactory: WasmFactory | null = null; @@ -190,7 +194,7 @@ const paintStrokeSessions = new PaintStrokeSessionStore(); // persistence behind it changes: OPFS instead of IDBFS. There is no IDBFS // fallback — all product files must live in OPFS. function mountBrowserFS(target: WasmModule): void { const fs = target.FS; if (!fs?.mkdirTree) throw report('CAPABILITY_MISSING', 'Native filesystem is unavailable'); if (browserFSModules.has(target)) return; fs.mkdirTree('/browser'); browserFSModules.add(target); } -async function syncBrowserFS(populate: boolean, target = module): Promise { if (!target) return; mountBrowserFS(target); const fs = target.FS as unknown as BrowserFSLike | undefined; if (!fs) return; try { if (populate) await populateBrowserFS(fs); else await persistBrowserFS(fs); } catch (error) { throw report('WASM_INIT_FAILED', `${populate ? 'NATIVE_FILES_RESTORE_FAILED' : 'NATIVE_FILES_PERSISTENCE_PENDING'}: ${String(error)}; ${populate ? 'stored files were not replaced' : 'live files remain in memory; retry or download a backup before closing'}`); } } +async function syncBrowserFS(populate: boolean, target = module): Promise { if (!nativeFilesPersistent || !target) return; mountBrowserFS(target); const fs = target.FS as unknown as BrowserFSLike | undefined; if (!fs) return; try { if (populate) await populateBrowserFS(fs); else await persistBrowserFS(fs); } catch (error) { throw report('WASM_INIT_FAILED', `${populate ? 'NATIVE_FILES_RESTORE_FAILED' : 'NATIVE_FILES_PERSISTENCE_PENDING'}: ${String(error)}; ${populate ? 'stored files were not replaced' : 'live files remain in memory; retry or download a backup before closing'}`); } } let gpuSurface: { session: string; canvas: OffscreenCanvas; width: number; height: number; pixelRatio: number; ownerGeneration: number; nativeInputEpoch?: number; bound: boolean; contextLost: boolean; resetPending: boolean; listeners: AbortController; cursorRevision?: number } | null = null; @@ -3174,7 +3178,7 @@ async function initialize(): Promise { if (module) return status(); if (!initializationPromise) { initializationPromise = (async () => { - await ownBrowserFS(); + if (nativeFilesPersistent) await ownBrowserFS(); const moduleManifest = await fetch("/wasm-module-manifest.json", { cache: "force-cache" }).then(async (response) => { if (!response.ok) throw new Error(`wasm-module-manifest request failed: ${response.status}`); return response.json(); @@ -3190,11 +3194,16 @@ async function initialize(): Promise { }; const binary = await wasmModuleLoader.load("debug-incremental"); const initializedModule = await factory({ wasmBinary: binary }); - try { await syncBrowserFS(true, initializedModule); initializedModule.FS!.mkdirTree('/browser/.autosave'); - try { const recovery = await restoreNativeSessionRecovery(initializedModule.FS!); if (recovery) { await syncBrowserFS(false, initializedModule); if (recovery.warning) postMessage({ type: 'blender-native-recovery-warning', message: recovery.warning }); } } - catch (error) { postMessage({ type: 'blender-native-recovery-warning', message: `OPFS 自动恢复未完成:${String(error)}。请先备份并检查恢复文件。` }); } + /* Ephemeral instances keep the native tree purely in memory: no OPFS + * populate and no autosave recovery, since both read the editor's store. */ + if (nativeFilesPersistent) { + try { await syncBrowserFS(true, initializedModule); initializedModule.FS!.mkdirTree('/browser/.autosave'); + try { const recovery = await restoreNativeSessionRecovery(initializedModule.FS!); if (recovery) { await syncBrowserFS(false, initializedModule); if (recovery.warning) postMessage({ type: 'blender-native-recovery-warning', message: recovery.warning }); } } + catch (error) { postMessage({ type: 'blender-native-recovery-warning', message: `OPFS 自动恢复未完成:${String(error)}。请先备份并检查恢复文件。` }); } + } + catch (error) { audioOutput.release(initializedModule); computeHosts.get(initializedModule)?.(); computeHosts.delete(initializedModule); throw error; } } - catch (error) { audioOutput.release(initializedModule); computeHosts.get(initializedModule)?.(); computeHosts.delete(initializedModule); throw error; } + else mountBrowserFS(initializedModule); const initializedHandle = initializedModule._web_engine_create(); if (initializedHandle <= 0) { audioOutput.release(initializedModule); diff --git a/web/tests/e2e/armature-editor-coverage-ui-production.spec.ts b/web/tests/e2e/armature-editor-coverage-ui-production.spec.ts index 59e2436cf..b6768b182 100644 --- a/web/tests/e2e/armature-editor-coverage-ui-production.spec.ts +++ b/web/tests/e2e/armature-editor-coverage-ui-production.spec.ts @@ -25,7 +25,9 @@ test("armature panel operates on the selected bone", async ({ page }, testInfo) page.setDefaultTimeout(8_000); await observeNative(page); const workflow = new NativeUIWorkflow(page, testInfo.outputPath("panel")); - await page.goto("/"); + /* The armature workbench is the web workbench Properties editor; the desktop + * mode renders the native properties mirror instead. */ + await page.goto("/?ui=web"); await workflow.load(path.join(root, fixturePath), "PoseConstraintArmatureObject"); const panel = page.getByTestId("armature-authoring-workbench"); await workflow.save("before"); @@ -80,7 +82,10 @@ for (const route of Object.keys(routes) as Route[]) { finally { timings.push({ stage: name, seconds: (performance.now() - start) / 1000 }); } }; const create = () => { - const client = new WebEngineClient({ timeoutMs: 10_000 }); + /* These engines never touch the shared OPFS native-files store: the page's + * editor already holds its exclusive Web Lock, and the fixture round-trips + * through saveBlend/openBlend bytes only. */ + const client = new WebEngineClient({ timeoutMs: 10_000, nativeFiles: false }); clients.push(client); return client; }; diff --git a/web/tests/fixtures/native-ui-workflow.ts b/web/tests/fixtures/native-ui-workflow.ts index d57d06868..b72a63f71 100644 --- a/web/tests/fixtures/native-ui-workflow.ts +++ b/web/tests/fixtures/native-ui-workflow.ts @@ -122,8 +122,33 @@ export class NativeUIWorkflow { await this.command(() => this.page.getByTestId("blend-file-input").setInputFiles(file)); await expect(this.page.getByTestId("open-progress")).not.toBeVisible(); const nativeToggle = this.page.getByTestId("native-web-tools-toggle"); - if (await nativeToggle.count()) await nativeToggle.click({ force: true }); - const item = this.page.getByRole("treeitem").filter({ hasText: object }); + /* The tree repeats object names on data-block and modifier-target rows; + * only the object row carries its object id, so match on that. */ + const item = this.page.locator(`[role="treeitem"][aria-label="${object}"]:has([data-node-id]:not([data-node-id=""]))`); + /* The web workbench (`?ui=web`) renders the tree directly and has no native + * overlay to switch off, so the toggle step only applies to the desktop mode. */ + if (await nativeToggle.count()) { + /* The desktop overlay renders only after the opened snapshot is applied, so + * sample the switch late instead of right after the open response. */ + await expect.poll(async () => (await item.isVisible()) || (await nativeToggle.isVisible()), { timeout: 30_000 }).toBe(true); + /* `force` would dispatch into the topbar while the overlay still sits at + * its initial offset; wait for the toggle to actually receive events. */ + if (!(await item.isVisible())) await nativeToggle.click({ timeout: 30_000 }); + } + /* Native Outliner rows exist only under open tree-store elements, so a + * nested object stays hidden behind a collapsed branch exactly as it does + * in desktop Blender for the same saved tree store (TSE_CLOSED). Expand + * branches until the row is reachable, which is the desktop interaction. */ + for (let round = 0; round < 4 && !(await item.isVisible()); round++) { + const collapsed = await this.page.locator('button.tree-expand[aria-label^="展开"]') + .evaluateAll((buttons) => [...new Set(buttons.map((button) => button.getAttribute("aria-label") ?? ""))]); + if (!collapsed.length) break; + for (const label of collapsed) { + if (await item.isVisible()) break; + await this.page.locator(`button.tree-expand[aria-label="${label}"]`).click({ timeout: 5_000 }).catch(() => {}); + } + } + await expect(item).toBeVisible({ timeout: 30_000 }); await item.click(); await expect(item).toHaveAttribute("aria-selected", "true"); }