The short answer
Yes, the challenge is a few KB. A FairPlay SPC is 9.3–11.9k characters of base64 (about 7–9 KB of bytes), as measured in the contract's own doc (PlayerSessionTypes.kt:395). The contract caps it at 16,384 base64 characters and the licence answer at 24,576. Both fit easily in kwry's 64 KiB per-message cap (Contract.kt:116), so one key request is one bridge message each way, with no chunking.
One key request, step by step
Same flow on Android (Widevine through Media3) and iOS (FairPlay through AVContentKeySession). Only the CDM and the challenge name differ.
1 · The page opens a session JS
openFor() picks the rendition, manifest URL and key system, and for FairPlay fetches the certificate itself and passes it as bytes (native-main.ts). The open carries no licence URL and no token: the contract has no field for them (PlayerSessionTypes.kt).
2 · The CDM produces a challenge native
Media3 asks the Widevine CDM for a key request when it meets encrypted content; AVFoundation asks for an SPC. Media3 calls the engine's fetchLicense, whose URL is only a marker (VIA_JS) and is never fetched (Media3Engine.kt:623).
3 · The bytes go to the page bridge
licenceViaJs base64-encodes the challenge and hands it to the LicenceBroker, which emits Effect.LicenseRequest {sessionId, requestId, keySystem, challengeB64} on the session's effects stream (Media3Engine.kt:341, LicenceBroker.kt:46). A timer starts after the request is registered, so a fast timeout can never leave it waiting forever.
4 · The page calls the licence server JS
sessionLicence() builds the entitlement URL (key system, codec, app version) and POSTs the challenge bytes with the user's bearer or anonymous token. A 401/403 refreshes the token once and retries (license.ts). The POST leaves from the WebView's fetch, inside a playback.licence trace span (fetchPost).
5 · The licence goes back bridge
The page sends Command.ProvideLicense {requestId, licenseB64}; SessionWire routes it to the broker, which completes the waiting key request exactly once (LicenceBroker.kt:68). Media3 / AVFoundation installs the key and playback starts.
6 · Failure is bounded safety
No answer within 30 s, or the session is released, fails the key request as DRM LICENCE_NO_ANSWER, never a hang (Media3Engine.kt:337).
Why the page does it, not native
| Concern | Owner | Why |
|---|---|---|
| Licence URL, query params, codec | JS | The entitlement API changes with the backend; a web deploy fixes it the same day |
| Token, refresh on 401/403 | JS | The page already owns the session; native held a second copy before (PlayerAuth, removed) |
| Body envelope / error parsing | JS | {data: base64} vs raw bytes is a server detail (license.ts:68) |
| Challenge bytes, key install, offline key storage | Native | Only the OS CDM can create the challenge or hold the key |
| Timeout backstop | Native | A dead page must not hang the decoder |
Cost of the round-trip
- Extra hops
- Two bridge messages (challenge out, licence in), each well under the 16 KiB target. In-process WebMessage, no network.
- Encoding
- Base64 grows bytes by 4/3, so an ~9 KB SPC becomes ~12k characters. The contract's limits are set in base64 characters for that reason.
- When it happens
- Once per key, at start (and on key rotation). Not per segment.
- Offline downloads
- Same broker, with a
dl-session prefix, and the page answers with a persistent licence (SessionWire.kt:65). - Cast receiver
- The TV asks the phone's page over the Cast peer bridge, with the same 16,384 / 24,576 caps (
CastPeer.kt:90).
Left over from the old path
Dead native licence code is still compiled
CustomDrmCallback in videoplayer-core still has its own DefaultHttpDataSource and a runBlocking licence fetch (CustomDrmCallback.kt). On the session path its provider.fetchLicense is the DumbEnvironment, which hands the bytes to the page, so no native licence POST happens. Its provisioning request (executeProvisionRequest, a one-time Widevine device provisioning POST to Google) does still go out natively, which is correct: it carries no Hoichoi token.