Skip to content

Commit 552c823

Browse files
osamu620claude
andcommitted
fix(wasm): rebase timeline anchor after pace-drop to prevent playback stall
The rAF display loop in rtp_demo.html dropped late frames without rebasing wallStart/rtpStart, so every subsequent frame computed a target far in the past and was also dropped — cascading until the ring emptied and playback froze. Particularly visible with the AWS CloudFront 150-frame fixture. Mirrors the native RTP receiver's "runaway rebase" logic (pipeline_multi_threaded.cpp:445-452). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 473f7e6 commit 552c823

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

web/rtp_demo.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1547,10 +1547,16 @@ <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 re-check next entry.
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.
15511555
if (paceDropEnabled() && rafTimestamp - target > PACE_DROP_PERIODS * period) {
15521556
ringPop();
15531557
droppedByPace++;
1558+
wallStart = rafTimestamp;
1559+
rtpStart = (_ringCount > 0) ? ringPeek().rtpTimestamp : rtpStart;
15541560
continue;
15551561
}
15561562

0 commit comments

Comments
 (0)