From 1015fbab7f2bd08810c2134497c4f080e7603d1d Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 14 Oct 2026 16:01:52 +0800 Subject: [PATCH] gui: a part kept in place is put back to the nearest whole pixel, so WebKit's dropped fraction no longer adds up (#1804) backToReader set scrollTop to a fractional target. WebKit truncates scrollTop, and the early return let anything under 1px stand, so the part kept in place (the Routing groups under the live stage) could sit up to just under a pixel off either way. Two of those apart moved it by nearly two. routing-steady caught it as "the editor at 334.33, not 332.64": rt-cols grew by 40.72px and the view followed by 40. A probe of every layout showed it isn't load. Each request's growth above the groups has its own fraction, and how far they drift depends only on which fractions happen to come in. Rounding to the nearest pixel, with a 0.5px early return, keeps the part within half a pixel of where the reader left it. Run: - routing-steady (WebKit, alone, load ~150-170): 8 of 8 green. Without the change, on 019404940 under the same load, 5 of 10 were red. - The 32 GUI files that check scrollTop (routing, scroll, pin, reader, agents) in Chromium and WebKit: all green except routing-mode-goes "webkit zh 420px", a 5s waitForFunction timeout at load avg 390. It passes alone 2 of 2. --- internal/gui/assets/app.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index bd2876460..4a0a303da 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -23987,9 +23987,12 @@ const pinSizes = new ResizeObserver(() => { function backToReader(v) { if (v.hidden) return; const pinned = pinnedAt(v); - const want = Math.max(0, Math.min(pinned ?? readerAt.get(v) ?? 0, v.scrollHeight - v.clientHeight)); + // to the nearest whole pixel: WebKit's scrollTop drops the fraction, so + // the part kept slid by up to a pixel each time what's above it grew by + // one, and two of those by nearly two (#1804) + const want = Math.round(Math.max(0, Math.min(pinned ?? readerAt.get(v) ?? 0, v.scrollHeight - v.clientHeight))); if (pinned != null) readerAt.set(v, want); - if (Math.abs(v.scrollTop - want) < 1) return; + if (Math.abs(v.scrollTop - want) < 0.5) return; v.scrollTop = want; // a field focused out of sight still comes into view, no further than needed const f = document.activeElement;