perf(web): stop serializing the whole Main on idle native frames
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

measurement on the 238-object scene: the native gpuFrame draw path itself
takes 160-200 ms, but every frame cost ~20.8 s because the unified dispatcher
serialized the entire ~13 MB Main before and after each gpuFrame to compare
bytes for change detection. desktop Blender never does that per frame; changes
come from the undo stack and RNA notifiers.

the worker now reports whether a frame carries only non-mutating input (motion,
focus, grab-cancel) and the dispatcher skips both Main writes for those idle
frames, judging change from the native undo step and playback flag instead.
idle and hover frames drop from ~20.8 s to ~0.13-0.24 s; the large-open headed
case still passes (2.4 min). frames carrying press/key/wheel input keep the
byte comparison for now, which is tracked as the next performance item
(change detection via incremental SceneIR/undo signals instead of a full
serialization). wasm 8d398dc4137a52a419975a2587c5c1edc935d01e4132e59d874ea4078390acc0.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
mes123456
2026-12-06 10:08:02 +08:00
parent 5a21a34c34
commit ac123aa72b
7 changed files with 34 additions and 16 deletions

Binary file not shown.

View File

@@ -775,7 +775,7 @@ async function handleGPURequest(command: Extract<WebEngineRequest["command"], {
const runNativeFrame = (): boolean => {
if (frameSurface.contextLost) return false;
const nativeFrame = module!._web_engine_gpu_ui_attached
? callUnifiedJson<{ state: string; changed: boolean; error?: string; exportPath?: string; exportSaveCopy?: boolean; exportSaveAs?: boolean; exportRevision?: number; modalActive?: boolean }>("gpuFrame") : null;
? callUnifiedJson<{ state: string; changed: boolean; error?: string; exportPath?: string; exportSaveCopy?: boolean; exportSaveAs?: boolean; exportRevision?: number; modalActive?: boolean }>("gpuFrame", { idle: pendingEvents.every(event => event.type === 1 || event.type === 7 || event.type === 8 || event.type === 11) }) : null;
if (typeof nativeFrame?.modalActive === "boolean") modalActive = nativeFrame.modalActive;
if (nativeFrame?.exportPath) {
completedExportPath = nativeFrame.exportPath;