Skip to content

Comments

Handle EME key status errors such as "internal-error" and "output-restricted" before appending media#7414

Merged
robwalch merged 5 commits intomasterfrom
enhancement/handle-key-status-internal-error
Aug 22, 2025
Merged

Handle EME key status errors such as "internal-error" and "output-restricted" before appending media#7414
robwalch merged 5 commits intomasterfrom
enhancement/handle-key-status-internal-error

Conversation

@robwalch
Copy link
Collaborator

@robwalch robwalch commented Jul 18, 2025

This PR will...

  • Handle EME key status errors such as "internal-error" before appending media
  • Ban keys with status "internal-error" so that additional license requests are not made for them when found in other playlists
  • Fallback to variants and renditions that have not been loaded or do not contain the key
  • Multiple key status changes in a single session are handled based on the session playlist key ID
  • Sessions where the playlist key ID changes to status "internal-error" are closed
  • Remove levels with unresolved key status errors ("internal-error" or "output-restricted" w/o defined HDCP-LEVEL attributes)

Why is this Pull Request needed?

@yajin2021 reported that other variants should be selected when a key error occurs:

Preventing appends of media with bad keys prevents the CDM from locking up playback. I was not able to append the media optimistically, and then remove it from the buffer on key error before a switch. Either hls.js queued too much media (appending more after the first key error) or any appends that cannot be decrypted interfere with playback.

Are there any points in the code the reviewer needs to double check?

Created #7474 for #7414 (comment) to be addressed in a future release.

Resolves issues:

Checklist

  • changes have been done against master branch, and PR does not conflict
  • new unit / functional tests have been added (whenever applicable)
  • API or design changes are documented in API.md

Fixes #7413 (playback/switching fails on KEY_SYSTEM_STATUS_INTERNAL_ERROR 'internal-error' key status)
@robwalch robwalch force-pushed the enhancement/handle-key-status-internal-error branch from 3c00a0f to 30c6ca4 Compare August 20, 2025 06:48
@robwalch robwalch modified the milestones: 1.7.0, 1.6.11 Aug 20, 2025
@robwalch robwalch marked this pull request as ready for review August 20, 2025 06:57
@robwalch robwalch changed the title Switch level on "internal-error" key status Handle EME key status errors such as "internal-error" and "output-restricted" before appending media Aug 20, 2025
@robwalch robwalch force-pushed the enhancement/handle-key-status-internal-error branch from 2709b7a to 5d86f38 Compare August 21, 2025 00:47
Add "FIXME" comments for future MediaKeySessionContext multi-key handling improvements
@robwalch
Copy link
Collaborator Author

Commented on flaws in MediaKeySessionContext that limit handling of key sessions to a single key ID. Grouping of sessions by KEY URI and handling multiple keys (level key objects and key statuses) will be addressed in a future release.

export interface MediaKeySessionContext {
keySystem: KeySystems;
mediaKeys: MediaKeys;
decryptdata: LevelKey; // FIXME: LevelKey has a URI which should be bound to the session, but is dependent one KeyId specifically. Session context should be allowed to adopt multiple level keys.
mediaKeysSession: MediaKeySession;
keyStatus: MediaKeyStatus; // FIXME: MediaKeySession can manage multiple keys with each with its own status

@robwalch robwalch mentioned this pull request Aug 21, 2025
…Y_LOADING

// reproducable with `hls.once(Hls.Events.KEY_LOADING, () => hls.removeLevel(hls.loadLevel))`
@robwalch robwalch linked an issue Aug 22, 2025 that may be closed by this pull request
5 tasks
@robwalch robwalch force-pushed the enhancement/handle-key-status-internal-error branch from bf0c2b0 to a2c0369 Compare August 22, 2025 19:21
@robwalch robwalch linked an issue Aug 22, 2025 that may be closed by this pull request
5 tasks
@robwalch robwalch merged commit 4ebd6d2 into master Aug 22, 2025
41 of 42 checks passed
@robwalch robwalch deleted the enhancement/handle-key-status-internal-error branch August 22, 2025 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Development

Successfully merging this pull request may close these issues.

HDCP error when playing manifests with both HD and SD levels The playback ends when the "keySystemStatusInternalError" occurs

1 participant