Source: shaka-project/shaka-player#9794 (report and maintainer discussion). Candidate patch: shaka-project/shaka-player#9795.
Symptom and environment#
A reporter describes FairPlay HLS failures in Shaka's Safari native src= playback path. The original report used Shaka 5.0.4 and Safari 18.3, with MEDIA_ERR_SRC_NOT_SUPPORTED / Shaka 3016, and initially attributed the failure to late MediaKeys attachment. Later testing contradicted the proposed universal fix.
Evidence and current verdict#
- A Shaka maintainer tested TS single-key and CMAF multi-key assets on Safari 18.6: both native
com.apple.fpsand legacycom.apple.fps.1_0paths worked before the patch; the proposed patch regressed native EME with 3016. See maintainer A/B results. - The reporter reproduced the regression on Safari 26.3 and confirmed that unpatched Shaka with the legacy Apple polyfill worked, while the native
com.apple.fpspath stalled without a license request. See reporter follow-up. - The reporter proposed narrowing PR #9795 to polyfill-only changes: key-system mapping and
webkitSetMediaKeystiming. Maintainers requested additional testing; the public discussion inspected does not establish a merged universal fix.
Verdict: cross-version/key-system behavior differs in the reported tests. The original assertion that Safari always requires early MediaKeys attachment is contradicted by the maintainer's working native EME control. Root cause for the native Safari 26.3 stall remains unverified.
First divergence to investigate#
native src= HLS selection → native EME vs PatchedMediaKeysApple → MediaKeys attachment timing → encrypted / webkitneedkey → generateRequest / SPC → license HTTP → CKC update → protected decode.
The first missing transition must be measured separately for each OS, key-system mode and media type. An encrypted event without a license request is not proof of a network or KSM failure.
Controlled client-side experiments#
| Variable | A/B control | Required observation |
|---|---|---|
| Safari build | 18.6 vs 26.3, pinned exact build | encrypted event, EME promise rejection |
| Key-system path | native com.apple.fps vs legacy polyfill |
actual MediaKeys implementation |
| Shaka build | 5.0.4 vs PR #9795 revision | first changed transition |
| Packaging | TS single-key vs CMAF multi-key | EXT-X-KEY, SKD/KID mapping |
| Attachment order | before src vs delayed (only in authorized test fork) |
readiness, error and key events |
Capture monotonic timestamps, video.readyState, video.error, encrypted, webkitneedkey, waitingforkey, message, keystatuseschange, promise rejections and sanitized license request status. Record certificate and content-ID identity without disclosing protected material. Use identical media bytes and authorized KSM credentials. Run repeated trials.
Client-only guidance#
Do not globally force early MediaKeys attachment or install the legacy polyfill on all Safari versions. Feature-test and A/B the two key-system paths with representative assets. Treat the proposed polyfill timing change as an experiment pending cross-version regression verification. Any KSM/packager adjustment is a separate proposal.
Reusable insight#
FairPlay native EME and legacy Apple Media Keys are different integration paths. A workaround that repairs one path can regress the other; validate key-session lifecycle and media readiness on both.
Publication status#
Evidence-backed case study based on upstream reporter and maintainer observations. No independent Safari device run, WebKit source audit or DRM trace was performed for this entry. Root cause unverified.
Extended investigation prompt#
Copy the full second-AI reverse-engineering prompt
Act as a senior iOS/tvOS reverse engineer, AVFoundation/CoreMedia investigator, WebKit EME source analyst, HLS forensic engineer, and FairPlay DRM specialist.
CASE:
https://github.com/shaka-project/shaka-player/issues/9794
PATCH CANDIDATE:
https://github.com/shaka-project/shaka-player/pull/9795
OBJECTIVE: Find the FIRST PROVEN causal divergence in Safari native HLS FairPlay playback. Explain why a proposed early-MediaKeys patch reportedly repairs one mode but regresses native com.apple.fps on other tested configurations. Do not assume the reporter's initial root-cause theory is correct.
STRICT EVIDENCE HIERARCHY:
Tier 1: Apple Developer Documentation, FairPlay Streaming SDK, Apple engineer statements, HLS Authoring Specification, W3C EME, IETF HLS, and relevant ISO BMFF standards.
Tier 2: Version-pinned WebKit and Shaka source code, symbolicated AVFoundation/CoreMedia/CFNetwork traces, and independently verified security research. For every source claim provide repository URL, commit SHA, file, function, exact line range, and control flow. WebKit source is NOT native AVPlayer implementation evidence.
Tier 3: Reproducible physical-device experiments, byte-preserved HLS manifests and media, synchronized EME event traces, redacted KSM/network captures.
Tier 4: Explicit, falsifiable hypotheses only.
Never fabricate citations, experiments, API requirements, or error-code interpretations.
RECONCILE CONTRADICTORY EVIDENCE:
- Maintainer Safari 18.6 tests: native and legacy work before patch; early-attach patch breaks native.
- Reporter Safari 26.3: legacy polyfill works; native EME reportedly stalls after encrypted/waitingforkey with no license HTTP.
- Reporter withdrew broad drm_engine.js changes, proposed polyfill-only modifications.
- Maintainers requested cross-version retesting; do not label an unmerged candidate as a verified fix.
TRACE:
HLS EXT-X-KEY / KEYFORMAT / SKD identity -> src= selection -> native EME or PatchedMediaKeysApple -> requestMediaKeySystemAccess / setMediaKeys or webkitSetMediaKeys -> src assignment -> encrypted / webkitneedkey -> initDataTransform -> generateRequest -> SPC -> license HTTP/KSM -> CKC -> session.update -> key status -> protected audio/video decoding.
INSPECT:
Shaka DrmEngine.attach, needWaitForEncryptedEvent, srcEquals_, manifestInitData_, PatchedMediaKeysApple.install, setMedia, WebKitMediaKeys constructor, event bridges, certificate handling, and content-ID transform. Pin exact source revisions. Inspect WebKit only where the verified code corresponds to the tested Safari build; do not infer private AVFoundation behavior from WebKit.
EXPERIMENTS:
Run pinned Safari 18.6 and 26.3, Shaka 5.0.4 and precise PR revisions, native vs legacy key-system paths, TS single-key and CMAF multi-key, clear HLS control, and independent native AVPlayer control. Change one variable at a time; repeat trials. Preserve exact media bytes and monotonic event timelines. Capture EME promise errors, video readyState/error, actual license dispatch, and key-status changes. Do not equate Shaka 3016 with a proven DRM-server failure.
SECURITY:
Use authorized media and KSM access. Never reveal certificates, tokens, keys, SPC/CKC payloads or circumvent DRM.
ROOT CAUSE STANDARD:
Require reproducible failure, proven earliest divergence, controlled intervention reversing it, and tests that falsify competing explanations. Otherwise state ROOT CAUSE UNVERIFIED.
DELIVER:
Executive finding, evidence ledger with contradictory results, source-code audit with pinned lines, manifest/key identity matrix, synchronized successful/failing timelines, A/B test matrix, confidence levels, client-only mitigation, separately labeled KSM/packaging proposals, regression tests, exact source URLs, and a publication-ready article.