mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-22 13:32:11 +00:00
Two independent resize paths existed: resizeCanvas() in app.ts (DPR-aware) and LGraphCanvas.resize() (DPR-unaware). Neither documented its dependency on the other, creating implicit temporal coupling. The bg/fg canvas size mismatch occurred because drawFrontCanvas() composites the bg canvas by dividing its dimensions by DPR — assuming both canvases were DPR-scaled — but LGraphCanvas.resize() set them to CSS pixels. Introduce CanvasViewport: a plain frozen data object (ECS component style) that serves as single source of truth for canvas sizing. measureViewport() is a pure function producing viewport state from DOM measurements. applyViewport() atomically sizes both fg and bg canvases and scales their contexts, eliminating the possibility of a partial resize. - Add devAssert() utility: throws in DEV, console.errors in prod - Add fg/bg size invariant assertion in LGraphCanvas.draw() - Make LGraphCanvas.resize() DPR-aware (scales both canvases + contexts) - Replace resizeCanvas() internals with viewport system - Wire viewport resize into canvasScheduler for app-mode transitions - 13 new unit tests for viewport and assert modules