Repeated sine-wave pops in Shaka vs hls.js: timestamp and PCM boundary investigation

GitHub source

Inferred. This page is generated from GitHub Issue #41; GitHub remains the canonical authoring and discussion source.

Local reproduction and solution — 18 November 2026#

Status: Actual MediaSourceEngine audio-offset regression reproduced and fixed.

Source and evidence#

Upstream case · local report and evidence · portable reproduction instructions

Observed results are Reproduced only within the stated seam. Implementation explanations remain Inferred, not Apple Confirmed.

Reconstruct the scene#

Feed contiguous 44.1 kHz AAC segments with 215/215/216-frame progression, whose first audio frame does not align exactly with the playlist grid.

With the parent production file, the continuity regression fails while two controls pass. With ed721ac20382315c4a93cf18a546ab7e9b49e222, all three tests pass.

Solution / guideline#

Use/backport #10899: preserve the existing offset for contiguous same-discontinuity audio without seek/adaptation while discrepancy stays below 0.1 s; retain correction on real discontinuities and larger errors.

All pinned patches and results

Limits / remaining work#

Timing behavior is locally verified. Rendered PCM, audible clicks and physical Safari/native AVPlayer were not captured.

This update supersedes earlier no-local-run statements below only within the stated scope. Historical source reports are retained; no unresolved issue is closed by this publication.


Earlier investigation and source history

Verification update — 17 November 2026#

Status: upstream reproduction available; targeted fix merged. PR #10899 merged on 2026-11-03 as ed721ac20382315c4a93cf18a546ab7e9b49e222, explicitly fixing upstream #10887.

  • Causal finding: recalculating audio timestampOffset on every segment snaps non-frame-aligned AAC boundaries onto playlist times, introducing small gaps/overlaps that can produce periodic clicks.
  • Solution: preserve the current offset for consecutive audio segments in the same discontinuity, without seek/adaptation, while the offset discrepancy remains below 0.1 seconds. Real discontinuities and larger errors retain correction behavior.
  • Regression coverage added upstream: 5-second, 44.1 kHz AAC segments with 215/215/216-frame progression; contiguous segments retain the offset, while seek/discontinuity/large-error cases remain controlled.
  • Action: use a Shaka build containing #10899 or backport the patch and tests. This review inspected the merged source/tests; no local PCM capture, audible before/after playback or native AVPlayer test was run. Release inclusion remains unverified.

This update supersedes older statements below about missing fix verification; the historical investigation and prompt are retained.


HLS audio pops every ~15 seconds in Shaka but not hls.js: isolate timestamp discontinuity from playback stalls#

Original report (30 October 2026)#

shaka-project/shaka-player#10887

Reporter: Shaka Player v5.3.3 / main build ef9f8cfe9, Chrome 156 on Windows 11. A sine-wave HLS stream produces audible pops approximately every 15 seconds in Shaka, but not in hls.js, under side-by-side comparison. Reporter says video playback is smooth and the symptom persists with ABR disabled. This is not yet an AVPlayer or FairPlay reproduction.

Evidence and constraints#

Direct report: repeated audio pops, stable video, fixed audio selection, cross-player difference. No raw PCM samples, exact media segments, source playlist snapshots, or timestamp traces were supplied in the issue body. The manifest endpoint is dynamically generated, so archive exact bytes and hashes before testing.

Known engineering boundary: an audible pop can arise from sample discontinuity, timestamp gap/overlap, AAC priming/encoder delay, demux/transmux behavior, decoder reset, or an audio-renderer transition. Smooth video and disabled ABR narrow the search but do not prove any one mechanism.

Unverified: whether the cadence matches EXTINF boundaries, discontinuity tags, timestamp resets, AAC frames, or a player append window. No root cause is established.

Forensic workflow#

  1. Capture exact master and audio media playlists and consecutive revisions; record EXT-X-MEDIA, EXTINF, EXT-X-MAP, EXT-X-DISCONTINUITY, EXT-X-DISCONTINUITY-SEQUENCE, MEDIA-SEQUENCE, codec and container. Save raw media bytes and SHA-256.
  2. Locate the pop times by recording decoded output PCM from both players, with the same source and controlled audio volume. Detect discontinuities via adjacent-sample delta and short-window energy, taking care not to classify legitimate sine-wave phase changes or device output glitches as media defects.
  3. Parse AAC/ADTS or fMP4 audio timing (sample counts, timescale, tfdt/trun or TS PTS/PCR). Compare the expected start of segment N+1 to the actual end of N; identify gap/overlap and decoder priming.
  4. Instrument Shaka's segment append and transmux paths and hls.js's audio demux/remux path at pinned commits. Correlate audio append, timestamp offsets, SourceBuffer updateend, gap jumps, and MediaSource state with the pop.
  5. Run the same byte-identical HLS in native AVPlayer as an independent control, with error/access logs and rendered audio capture. Safari/WebKit and Chrome MSE behavior must not be conflated with native AVFoundation.
  6. If FairPlay protection is introduced in a separate authorized test, independently trace EXT-X-KEY → SKD/KID → AVContentKeySession → SPC/KSM/CKC → usable key; do not attribute clear-stream audio artifacts to DRM.

Controlled tests#

  • Compare Shaka and hls.js with identical frozen playlist/segment bytes.
  • Compare original audio versus a losslessly repackaged timeline (preserving encoded samples where possible).
  • Disable ABR; fix one audio rendition.
  • Compare MSE audio append sequences and timestamp offsets.
  • Compare native AVPlayer, and optionally clear versus legitimately FairPlay-encrypted copies.
  • Vary one parameter at a time; repeat and report pop rate per minute, timestamp residuals, and confidence intervals.

Root-cause decision rule#

Do not claim root cause until (1) reproduced from archived media, (2) first divergent sample/append/presentation boundary identified, (3) one-variable correction removes the pop, and (4) major alternatives are falsified. Otherwise state HLS AUDIO POP REPORTED; FIRST CAUSAL DIVERGENCE UNVERIFIED.

Reusable insight#

A smooth video timeline does not validate audio sample continuity. Diagnose audio at three layers separately: encoded timestamps, decoded PCM boundaries, and rendered output. A cross-player difference is a powerful discriminator, not proof that the media is compliant or that one player has a decoder defect.

References#

Status: Source report reviewed; no native-device playback, PCM capture, or segment-level experiment executed.