Skip to content

Commit 752c327

Browse files
fix(render-pipeline): fast-path redraw when window position unchanged (resize fix)
When requestRender fires for a pure canvas resize (ResizeObserver → window.resize → rAF), the window position is identical to the last render. Previously this triggered a streaming fetch from S3, which on CI could take >15 s and cause the ResizeObserver e2e test to time out. Now: if lastChannels covers the same startSample+windowSamples, redraw immediately with the cached data. deviceFitCanvas picks up the new clientWidth in that draw call, updating canvas.width synchronously.
1 parent a69f9e1 commit 752c327

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

viewer/render-pipeline.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,24 @@
6767
Math.round(ctx.view.window_sec * fs)
6868
);
6969

70+
// Fast path: same window position as last render (e.g. canvas resize,
71+
// gain-pill update, or a re-render after ResizeObserver fires). Redraw
72+
// immediately with lastChannels so canvas.width updates without a network
73+
// round-trip. The abort above already cancelled any in-flight streaming, so
74+
// this is safe — lastChannels still represents the correct visible window.
75+
const lastSample = ctx.lastStartSec != null
76+
? Math.round(ctx.lastStartSec * fs) : -1;
77+
const lastWindow = ctx.lastWindowSec != null
78+
? Math.round(ctx.lastWindowSec * fs) : -1;
79+
if (ctx.lastChannels && startSample === lastSample && windowSamples === lastWindow) {
80+
const drawOpts = ctx.buildDrawOpts(ctx.lastChannels, startSample, fs);
81+
ctx.TraceRenderer.draw(ctx.tracesCanvas, drawOpts);
82+
ctx.updateGainReadout();
83+
if (ctx.lastPointerEvent) ctx.refreshCursor();
84+
ctx.prefetchNeighbours();
85+
return;
86+
}
87+
7088
// Use streaming path for foreground pan on cache miss + no active filters.
7189
const cacheKey = `${startSample}-${windowSamples}`;
7290
const cacheHit = ctx.readCache.has(cacheKey);

0 commit comments

Comments
 (0)