fix(web): armature edit-mode bones survive save and the coverage spec runs
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

The coverage spec could not start: the armature workbench renders only in the
web workbench (?ui=web), the diagnostic-panel filter hid it there, and the
spec's own WebEngineClient waited on the editor's exclusive native-files Web
Lock. Give the client an ephemeral mode (marked by worker name, no OPFS store
and no lock) and let the fixture load in web mode without the native overlay.

Bone authoring in Edit mode was also discarded on save: the engine wrote
object bones while the save flush rebuilds them from the edit-bone list
(ED_editors_flush_edits -> ED_armature_from_edit). Mirror each edit into the
edit bones and refresh arm_roll from the bone matrix so roll survives the
round trip.

armature-editor-coverage-ui-production: 6 passed (dev server, Chromium).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
mes123456
2026-11-30 02:23:33 +08:00
parent 013ea78a45
commit 8d9bb86f12
9 changed files with 75 additions and 18 deletions

View File

@@ -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<void> { 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<void> { 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<WebEngineStatus> {
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<WebEngineStatus> {
};
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);