Skip to content

Commit 4ea5808

Browse files
osamu620claude
andcommitted
fix(jpip): give thumbnail priority over pending scroll drain
On fast local servers the fetch-decode cycle is short enough that the user is still scrolling when it completes, setting pendingFetch every cycle. Since pendingFetch was checked before thumbnailPending, the thumbnail fetch was indefinitely deferred. On CDN-hosted servers the 50-200ms network latency gives the user time to pause, breaking the cycle — masking the bug in production. Swap the priority: check thumbnailPending first. It fires once, adds ~50ms for the coarse overview, then the pending scroll drains normally. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 48f4ae8 commit 4ea5808

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

web/jpip_viewer.html

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,21 +1481,20 @@ <h3>JPIP Gigapixel Viewer</h3>
14811481
// arrived during the await above, fire one more fetch with the current
14821482
// (freshest) panX/panY/zoom. No debounce — the user already waited the
14831483
// full network+decode round-trip, they don't need another 60 ms.
1484-
if (pendingFetch) {
1485-
pendingFetch = false;
1486-
queueMicrotask(fetchView);
1487-
return;
1488-
}
1489-
// Kick the one-time thumbnail fetch on idle, after the first successful
1490-
// main-view paint. Uses its own busy-lock to coexist with any later
1491-
// user-driven fetch. Skip the adjacent-halo prefetch this round —
1492-
// fetchThumbnail owns the decoder for the next hop; the next pan will
1493-
// set up a new prefetch anyway.
1484+
// Thumbnail takes priority over pending scrolls — it's a one-time fetch
1485+
// and on fast local servers the pendingFetch drain can indefinitely
1486+
// preempt it (user is still scrolling during the short decode window,
1487+
// setting pendingFetch every cycle).
14941488
if (thumbnailPending) {
14951489
thumbnailPending = false;
14961490
queueMicrotask(fetchThumbnail);
14971491
return;
14981492
}
1493+
if (pendingFetch) {
1494+
pendingFetch = false;
1495+
queueMicrotask(fetchView);
1496+
return;
1497+
}
14991498
// Otherwise: schedule an idle-delay prefetch of the adjacent halo.
15001499
// scheduleFetch() cancels this timer on the next user interaction, so
15011500
// continuous panning never triggers a prefetch (the halo would be

0 commit comments

Comments
 (0)