diff --git a/src/scripts/app.ts b/src/scripts/app.ts index 7ebf7022117..97c87df3c0d 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -8,6 +8,7 @@ import { useCanvasPositionConversion } from '@/composables/element/useCanvasPosi import { layoutStore } from '@/renderer/core/layout/store/layoutStore' import { syncLayoutStoreNodeBoundsFromGraph } from '@/renderer/core/layout/sync/syncLayoutStoreFromGraph' import { flushScheduledSlotLayoutSync } from '@/renderer/extensions/vueNodes/composables/useSlotElementTracking' +import { createRafBatch } from '@/utils/rafBatch' import { st, t } from '@/i18n' import { ChangeTracker } from '@/scripts/changeTracker' @@ -949,10 +950,16 @@ export class ComfyApp { this.rootGraph.start() - // Ensure the canvas fills the window + // Coalesce ResizeObserver bursts during splitter / window drags into one + // resize per frame to stop redundant draw(true, true) calls and the link + // overlay redraw lag they cause. + const scheduleCanvasResize = createRafBatch(() => { + const canvasEl = this.canvasElRef.value + if (canvasEl) this.resizeCanvas(canvasEl) + }) useResizeObserver(this.canvasElRef, ([canvasEl]) => { if (canvasEl.target instanceof HTMLCanvasElement) { - this.resizeCanvas(canvasEl.target) + scheduleCanvasResize.schedule() } })