Stop the stream seeking against itself, and stop the desk scrolling itself
Build 126. Two reports, unrelated to each other. IPHONES REPEATING AND SKIPPING PARTS OF EVERY SENTENCE. DRIFT_LAND was 0.6 s and one segment is 0.697 s, so the position the player was being held at sat INSIDE the newest segment — a point it very often did not have yet. It got dragged to the edge, ran out of audio and stalled. Then 'stalled' and 'waiting' were both wired to seekLive(), and a seek on a live HLS stream makes the element re-buffer, which raises those same two events. So the correction caused the stall that caused the correction. On Safari, where HLS is native and a seek lands on a segment boundary, each turn of that loop replays or drops a piece of a sentence — which is exactly what was described. Three changes, all of them about not fighting the player: those two events no longer seek, the target is three segments back (~2.1 s, what an HLS player picks for itself on a live playlist), and a correction now has 5 s to settle before another may run. Costs about 1.5 s of extra delay. A listener a second further behind is following the service; one whose audio keeps jumping backwards is not. NOT YET CONFIRMED ON A REAL IPHONE — the mechanism is read off the code and the measured segment length, and the next service is the test. CANNOT SCROLL THE MONITOR WHILE LIVE. Four boxes ended their update with box.scrollTop = box.scrollHeight, unconditionally, so every sentence yanked the view back to the live edge and reading back was impossible. They now follow the bottom only while the operator is already at the bottom, and resume when they return — nothing to press either way. Trimming the top is held off while they are scrolled away too, since dropping old lines moves the text being read; the cap comes back the moment they return, with a ceiling so nothing grows all service. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+60
-7
@@ -195,6 +195,59 @@ const state = {
|
||||
degradedAt: 0
|
||||
};
|
||||
|
||||
/*
|
||||
* FOLLOW THE BOTTOM ONLY WHILE THE OPERATOR IS AT THE BOTTOM.
|
||||
*
|
||||
* Every one of these boxes used to end its update with
|
||||
* `box.scrollTop = box.scrollHeight`, unconditionally. While the service is
|
||||
* running that fires on every sentence, so scrolling back to re-read what was
|
||||
* just said was impossible: the box yanked itself to the live edge a fraction
|
||||
* of a second later, every time. Reported from the desk as "can't scroll on
|
||||
* what's being said when it's live", which is exactly what it was.
|
||||
*
|
||||
* A box follows the live edge until the operator scrolls away from it, and
|
||||
* starts following again when they come back to it. Nothing has to be pressed
|
||||
* to get out, and nothing has to be pressed to get back in.
|
||||
*
|
||||
* The slack matters. A programmatic jump to the bottom also raises a scroll
|
||||
* event, and it lands AT the bottom, so sticking survives its own scrolling.
|
||||
* Sub-pixel layout and a growing last line can leave a couple of pixels
|
||||
* behind, which with a zero threshold would unstick the box on its own output.
|
||||
*/
|
||||
/*
|
||||
* Trimming the TOP of a box the operator is reading moves the text under
|
||||
* their eyes — the other half of "it keeps jumping". While they are scrolled
|
||||
* away the cap is suspended, so the lines they are looking at stay put; when
|
||||
* they return to the live edge the backlog is trimmed in one go. The ceiling
|
||||
* keeps a box that is left scrolled up all service from growing without end.
|
||||
*/
|
||||
function trimTop(box, cap) {
|
||||
if (!box) return;
|
||||
const held = box.dataset.stick === '0';
|
||||
const limit = held ? cap * 6 : cap;
|
||||
while (box.children.length > limit) box.removeChild(box.firstChild);
|
||||
}
|
||||
|
||||
const STICK_SLACK_PX = 48;
|
||||
const stickWired = new WeakSet();
|
||||
|
||||
function followBottom(box) {
|
||||
if (!box) return;
|
||||
if (!stickWired.has(box)) {
|
||||
stickWired.add(box);
|
||||
box.dataset.stick = '1';
|
||||
box.addEventListener('scroll', () => {
|
||||
const atBottom =
|
||||
box.scrollHeight - box.scrollTop - box.clientHeight <= STICK_SLACK_PX;
|
||||
box.dataset.stick = atBottom ? '1' : '0';
|
||||
}, { passive: true });
|
||||
}
|
||||
/* Scrolled away: leave the view exactly where they put it. New content
|
||||
grows BELOW the viewport, so not touching scrollTop is what holds the
|
||||
reader's place — there is nothing else to do here. */
|
||||
if (box.dataset.stick !== '0') box.scrollTop = box.scrollHeight;
|
||||
}
|
||||
|
||||
// ────────────────────────────────────────────────────────── logging
|
||||
|
||||
function log(msg, kind) {
|
||||
@@ -208,8 +261,8 @@ function log(msg, kind) {
|
||||
if (kind) line.className = kind;
|
||||
line.textContent = new Date().toLocaleTimeString() + ' ' + msg;
|
||||
el.appendChild(line);
|
||||
while (el.children.length > 200) el.removeChild(el.firstChild);
|
||||
el.scrollTop = el.scrollHeight;
|
||||
trimTop(el, 200);
|
||||
followBottom(el);
|
||||
}
|
||||
|
||||
function hero(stateName, title, body) {
|
||||
@@ -2471,8 +2524,8 @@ function monitorFinal(cid, text) {
|
||||
monRows.set(cid, el);
|
||||
/* Neither the map nor the box may grow for the length of a service. */
|
||||
while (monRows.size > 60) monRows.delete(monRows.keys().next().value);
|
||||
while (box.children.length > 24) box.removeChild(box.firstChild);
|
||||
box.scrollTop = box.scrollHeight;
|
||||
trimTop(box, 24);
|
||||
followBottom(box);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2514,7 +2567,7 @@ function monitorTranslation(cid, lang, text) {
|
||||
row.classList.add('dropped');
|
||||
}
|
||||
const box = $('monitor');
|
||||
if (box) box.scrollTop = box.scrollHeight;
|
||||
followBottom(box);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2581,9 +2634,9 @@ function showMonitor(text, isPartial, langCount) {
|
||||
sub.textContent = langCount + ' language' + (langCount === 1 ? '' : 's') + ' · ' + state.lagMs + ' ms';
|
||||
el.appendChild(sub);
|
||||
box.appendChild(el);
|
||||
while (box.children.length > 30) box.removeChild(box.firstChild);
|
||||
trimTop(box, 30);
|
||||
}
|
||||
box.scrollTop = box.scrollHeight;
|
||||
followBottom(box);
|
||||
}
|
||||
|
||||
// ────────────────────────────────────────────────────────── church server
|
||||
|
||||
Reference in New Issue
Block a user