Skip to content

Commit 9fd3bde

Browse files
osamu620claude
andcommitted
fix(wasm): only rebase timeline when pace-drops drain the ring
The previous fix (552c823) rebased wallStart/rtpStart on every pace-drop. When decode throughput is slightly below source rate (e.g. 25 fps vs 30 fps), the per-drop rebase creates a visible sawtooth: smooth → drop → timeline jump → smooth → repeat. Replace with a lighter touch: rebase only when the ring empties completely from drops (the catastrophic stall that triggered the original bug). Individual drops are absorbed naturally by the existing timeline — surviving frames stay on-schedule and the gradual drift recovers without visible glitches. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 552c823 commit 9fd3bde

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

web/rtp_demo.html

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,16 +1547,14 @@ <h1>HTJ2K RTP Replay — Browser WASM Demo</h1>
15471547
const target = wallStart + totalPausedMs + dtMs;
15481548
const period = entry.framePeriodMs || (1000 / 60);
15491549

1550-
// Pace-drop: too far behind? Discard and rebase the timeline
1551-
// anchor so the next surviving frame is scheduled relative to
1552-
// "now" — without this, every subsequent frame stays behind the
1553-
// stale anchor and gets pace-dropped too, stalling playback.
1554-
// Mirrors the "runaway rebase" in the native RTP receiver.
1550+
// Pace-drop: too far behind? Discard and re-check next entry.
1551+
// If the ring drains completely, reset the anchor so the next
1552+
// decoded frame starts a fresh timeline instead of cascading
1553+
// into further drops that stall playback.
15551554
if (paceDropEnabled() && rafTimestamp - target > PACE_DROP_PERIODS * period) {
15561555
ringPop();
15571556
droppedByPace++;
1558-
wallStart = rafTimestamp;
1559-
rtpStart = (_ringCount > 0) ? ringPeek().rtpTimestamp : rtpStart;
1557+
if (_ringCount === 0) { wallStart = 0; totalPausedMs = 0; }
15601558
continue;
15611559
}
15621560

0 commit comments

Comments
 (0)