Local reproduction and solution — 18 November 2026#
Status: Actual DrmEngine session-ownership 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#
Reject a mocked MediaKeySession.generateRequest, allow the error/drop path to run, and assert that the removed session is closed.
Baseline fails with “Expected spy close to have been called”. After a2cf89b531832016130f494a1c2e3170576d2379, the complete scoped DrmEngine suite passes 121/121 in Chrome Headless.
Solution / guideline#
Use/backport PR #10954, including closeSession_(session) on the generateRequest rejection path after removing it from active tracking. Removing tracking alone prevents later tracked-session cleanup from seeing it.
All pinned patches and results
Limits / remaining work#
Actual Shaka control flow with mocked EME. Device/CDM exhaustion thresholds, PlayStation, FairPlay and native AVPlayer were not measured.
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: reproduced by upstream unit test; fix merged. PR #10954 merged on 2026-11-12 as a2cf89b531832016130f494a1c2e3170576d2379.
- Reproduction: reject MediaKeySession.generateRequest(), then check whether the dropped session is closed. The added regression test fails without the patch; the PR author reports all 121 DrmEngine tests passed in Chrome Headless.
- Solution: call closeSession_(session) after removing the failed session from activeSessions_. Removing tracking alone prevents later tracked-session cleanup from seeing the session.
- Action: use a build containing #10954 or backport that change with the regression test.
- Scope: merged diff and upstream test report verified; this review did not run the browser suite. The PR explicitly says it was not tested on PlayStation. Device/CDM exhaustion limits, FairPlay and native AVPlayer behavior remain unverified. Release inclusion remains unverified.
This update supersedes older statements below about missing fix verification; the historical investigation and prompt are retained.
Source: shaka-project/shaka-player#10953 (reported 12 Nov 2026). Pinned implementation: drm_engine.js at 5e16349ab.
Symptom and scope#
A Shaka developer reports that when MediaKeySession.generateRequest() rejects, DrmEngine emits error 6006 and drops the session from activeSessions_, but does not close it. The reporter reproduced the ownership path in a Chrome Headless unit test on macOS and encountered accumulating DRM session failures on PlayStation 5 (WebKit). Shaka 5.3.4 and 4.16.10 were named. The approximately 20-session PlayReady limit is reporter-supplied device context, not an independently measured platform guarantee.
This is an EME session-lifecycle case, not evidence of a native AVPlayer or FairPlay defect.
Evidence-backed source finding#
At pinned commit 5e16349ab38819107597506066de9f2e3f0f6a82, lib/drm/drm_engine.js registers the session in activeSessions_ and attaches a session.closed handler. In the generateRequest(...).catch(...) branch, it calls this.activeSessions_.delete(session) without a corresponding close in that branch. The reporter states closeOpenSessions_() later iterates only tracked sessions.
This establishes a Shaka lifecycle ownership gap in the pinned path. It does not, by itself, prove how long any particular browser/CDM retains its underlying secure resources. The issue is closed, but this investigation has not verified a specific merged fix commit.
First divergence#
Create MediaKeySession → register in activeSessions_
→ generateRequest rejects
→ remove session from activeSessions_
→ no close in rejection path
→ subsequent tracked-session cleanup cannot see it
→ possible CDM resource retention / exhaustion
The first demonstrated implementation divergence is loss of session tracking before explicit close. Error 6006 is downstream. License HTTP or CKC failure is not established.
Client-only investigation and regression test#
Inject a rejected generateRequest promise in a pinned Shaka unit test. Assert that the failed session is closed exactly once, cleanup settles, and no session remains owned after destroy(). Compare a failing pinned build and a verified patched build; test cancellation/destroy races and close() rejection separately.
On actual hardware, record anonymized session counts, create/reject/close events and player errors across repeated trials. Distinguish JavaScript tracking from CDM resources. A bounded player reset may limit impact but is not a proven fix. Any CDM, KSM or device-firmware change is a separate proposal.
Reusable insight#
Removing a failed DRM session from an application's registry is not equivalent to closing the underlying session. Track ownership and cleanup across every asynchronous rejection path.
Verification status#
Pinned source-level deletion without close was inspected. No device reproduction, independent session-limit measurement or upstream fix commit verification was performed. FairPlay and native AVPlayer applicability remain unverified.
Extended investigation prompt#
Copy the complete second-AI reverse-engineering prompt
You are a senior iOS/tvOS reverse engineer, AVFoundation/CoreMedia investigator, WebKit EME source analyst, and FairPlay DRM specialist.
CASE: https://github.com/shaka-project/shaka-player/issues/10953
PINNED SOURCE: https://github.com/shaka-project/shaka-player/blob/5e16349ab38819107597506066de9f2e3f0f6a82/lib/drm/drm_engine.js#L1460-L1505
OBJECTIVE: Independently determine the first proven causal divergence when MediaKeySession.generateRequest rejects, Shaka removes the session from activeSessions_ without closing it, and repeated playback eventually exhausts constrained DRM sessions. Identify what is proven in Shaka vs what requires separate WebKit, FairPlay or native AVFoundation testing.
STRICT EVIDENCE HIERARCHY:
T1 — Official Apple Developer Documentation, FairPlay Streaming SDK, Apple HLS Authoring Specification, W3C EME, applicable IETF/ISO specifications and explicit Apple engineer statements.
T2 — Commit-pinned Shaka source, verified WebKit source, Apple open-source code, symbolicated AVFoundation/CoreMedia/CFNetwork diagnostics, independently verified DRM/security research. Every source claim must give repository URL, commit SHA, file, function, exact lines and control-flow proof. WebKit is not native AVPlayer source.
T3 — Reproducible controlled tests, actual EME event/promise traces, session counters, sanitized network and KSM transaction metadata, device diagnostics.
T4 — Explicitly labeled hypotheses with falsification tests.
For each significant conclusion provide claim, tier, source, observation, counterevidence, confidence and falsification test. Never invent source citations, measurements, private implementation details or successful tests.
INVESTIGATION:
1. Read pinned DrmEngine source around generateRequest rejection, activeSessions_.delete, closeOpenSessions_, closeSession_ and destroy. Trace ownership of every created MediaKeySession.
2. Distinguish failure to generate a license request from license HTTP dispatch, KSM response and CKC processing. Error 6006 is not proof of FairPlay failure.
3. Determine W3C EME session.close() semantics and when close can reject; analyze asynchronous destruction races and whether deleting tracking metadata before closing leaks resources.
4. Compare pinned faulty revision with an actual upstream fix if independently verified; confirm PR, merge commit and tests rather than assuming issue closure means fixed.
5. Build deterministic unit tests where generateRequest rejects; assert close invocation and eventual session.closed settlement, with bounded timeouts and explicit mocks.
6. On authorized devices, compare repeated failing sessions, successful sessions and recovery after player.destroy. Use PlayStation/WebKit as original reporter environment; test Safari FairPlay separately and never generalize results to native AVPlayer.
7. If a FairPlay-specific reproduction exists, inspect EXT-X-KEY/KEYFORMAT/SKD, authorized SPC/KSM/CKC lifecycle, key status, route changes and redacted diagnostics. For native AVPlayer, independently investigate AVContentKeySession and delegate lifetimes.
8. Record memory/session-count trajectories, monotonic event timeline and first divergent operation; distinguish JavaScript session reference leaks from actual CDM resource exhaustion.
SECURITY: Authorized assets only; no extraction or exposure of content keys, certificates, credentials, SPC/CKC payloads; no DRM bypass.
ROOT CAUSE STANDARD: Declare a proven root cause only for the scope backed by pinned source or reproducible experiments. To claim a device-specific causal mechanism, require reproduction, first divergence, controlled reversal and alternative-hypothesis falsification. Otherwise label unverified.
OUTPUT: concise executive verdict; evidence ledger; source-level call graph; failure/success timeline; test matrix and results vs proposed tests; Shaka fix verification; WebKit vs native AVPlayer limitations; FairPlay applicability; client-only mitigation; separate KSM/packager proposals; regression tests; open questions; exact source URLs; publication-ready article.