Encrypted LL-HLS startup: DRM key readiness serializes init and part downloads (hls.js #8099, unresolved)

GitHub source

Evidence not classified. This page is generated from GitHub Issue #60; GitHub remains the canonical authoring and discussion source.

Status and source#

  • Upstream: video-dev/hls.js#8099
  • Checked 2026-11-22: OPEN; milestone 1.8.0, project Top priorities; no linked development PR. #8134 was merged for a related part-selection/handover problem, not a complete resolution of #8099. The reporter's workaround is an external custom fLoader, not a native fix.
  • Scope: hls.js / EME Widevine evidence. Not a demonstrated native AVPlayer or FairPlay bug.

Technical question#

Why do encrypted LL-HLS cold starts serialize DRM key readiness with init/part downloads, and can media bytes be fetched early without violating decrypt/append readiness?

Evidence ledger#

  1. Reporter cites hls.js base-stream-controller.ts at commit d0b3453: loadInitSegmentIfNeeded gates encrypted init loading on key; parts branch waits for Promise.all([keyLoadingPromise, initDataPromise]) before doFragPartsLoad. Confirm exact lines against pinned source before publishing as independently verified.
  2. Reporter tested patch against commit 9d8b510; maintainer robwalch considered approach reasonable but questioned queued gate.
  3. On v1.7.4, reporter's eight cold starts per variant: median playing 1111 ms stock, 840 ms queued, 943 ms whole-segment-first; key usable 503/509/501 ms respectively; 0/8 stalls in first 24 s for each. These are reporter measurements, not independently reproduced.
  4. Maintainer merged #8134 to address part selection/handover; reporter confirmed the earlier handover stalls disappeared on v1.7.4, while key/media overlap improvement remained outstanding.
  5. No linked resolving PR under #8099 as of check.

Causal model (provisional)#

Current: manifest → EME key request / key usable → init/part HTTP request → transmux/append → first frame.
Proposed: manifest → [key acquisition || init/part HTTP requests] → readiness gate → transmux/append → first frame.
First divergence to prove: first HTTP part request occurs only after EME key usable in stock path. Do not confuse key availability with permission to download ciphertext.

Reusable insight#

A decryption dependency is not automatically a network-download dependency. Separate key-ready, bytes-ready, parse-ready, append-ready and first-frame timestamps. For native AVPlayer, media request scheduling is private; do not claim hls.js source proves AVFoundation behavior.

Reproduction / acceptance tests#

  • Pin stock v1.7.4 and candidate patch; use the same authorized LL-HLS fMP4 SAMPLE-AES/CENC stream, stable network profile, cache reset, randomized A/B runs (>=30 each).
  • Record performance.now(), KEY_LOADING, KEY_LOADED, EME keystatuseschange, init/part request start/end, transmux push, append, playing, first video frame, live-edge distance and rebuffering.
  • Assert: init and parts may download while key pending, but no media push/append before key + init readiness.
  • Negative tests: AES-128 encrypted init, key rejection, expired/output-restricted status, key rotation, stale fragCurrent, abort/retry, byte-range parts, progressive mode, playlist discontinuity.
  • Validate no duplicate requests, leaked loaders, out-of-order parts or post-start stalls.
  • FairPlay control: run authorized Safari native HLS and EME tests separately; don't transfer Widevine findings without proof.

Next article milestone#

Verify pinned source lines, check current upstream PRs/releases again, run the above A/B matrix, and publish only demonstrated conclusions. Root cause of scheduling in the cited code is reported with source evidence; broad product-level fix remains unresolved.

Extended reverse-engineering prompt for second AI

Act as a senior iOS/tvOS reverse engineer, AVFoundation/CoreMedia forensic engineer, HLS/LL-HLS protocol specialist and FairPlay DRM specialist.

Case: video-dev/hls.js#8099. Investigate encrypted LL-HLS startup scheduling and its relationship to DRM key readiness. Identify the first causal divergence between stock and candidate patch, distinguish Widevine/EME from FairPlay and native AVPlayer, and test whether early encrypted-byte fetching preserves safety and playback correctness.

STRICT EVIDENCE HIERARCHY:

  1. Apple Developer Documentation, FairPlay Streaming SDK guidance, Apple HLS specifications, RFC 8216 and LL-HLS drafts/specifications, W3C EME.
  2. Pinned WebKit/hls.js source (commit SHA, file, function, exact line range), official implementation notes, verified peer-reviewed security research. WebKit is not native AVPlayer source.
  3. Controlled device/browser experiments, manifest captures, HTTP traces, symbolicated AVFoundation/CoreMedia stack traces and authorized key lifecycle logs.
  4. Falsifiable hypotheses, explicitly marked unverified. Never guess private Apple behavior.

Investigate EXT-X-KEY, KEYFORMAT, EXT-X-MAP, EXT-X-PART, PART-TARGET, independent parts, CENC/SAMPLE-AES versus AES-128 full-segment encryption, EME key-system access, server certificate, license round trip, key status, request scheduling, fragment-context invalidation, init parsing, transmux and MSE append. For FairPlay examine SKD, AVContentKeySession / AVAssetResourceLoader callbacks, SPC/CKC transaction metadata (sanitized), persistable versus online keys, key rotation and renewal; never extract keys or bypass DRM.

Reproduce baseline and patched behavior with identical assets, network conditions and randomized repeated runs. Collect timestamped network waterfall and event timeline. Test failure/abort races, key rotation, stale fragment context, byte-range parts and startup rebuffering. Distinguish source-proven mechanism, reporter-observed outcome and independently verified result.

Root cause acceptance: reproducible failure, first proven divergence, intervention that reverses it, and exclusion of competing hypotheses. Otherwise state ROOT CAUSE UNVERIFIED. Deliver evidence ledger with URLs and pinned lines, causal graph, commands, experiment matrix, risk analysis, client-only mitigations, separately labeled packaging/server proposals, regression tests and publication-ready article. Never fabricate citations, experiments, metrics, patches or publication status.