Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Close keySession when player is disposed #176

Merged
merged 4 commits into from
Oct 13, 2022

Conversation

alex-barstow
Copy link
Contributor

@alex-barstow alex-barstow commented Oct 5, 2022

Description

This fixes a bug where a keySession could continue to receive events and trigger license requests even after a player is disposed.

Specific Additions

Call keySession.close() on 'dipose'.

Relevant spec: https://www.w3.org/TR/encrypted-media/#x6.-mediakeysession-interface

A MediaKeySession object shall not be destroyed and shall continue to receive events if it is not closed and the MediaKeys object that created it remains accessible. Otherwise, a MediaKeySession object that is no longer accessible shall not receive further events and may be destroyed.

close(): https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-close

Copy link
Member

@gkatsev gkatsev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One non-blocking question.

src/eme.js Outdated
@@ -108,8 +108,9 @@ export const makeNewRequest = (requestOptions) => {

eventBus.trigger('keysessioncreated');

return new Promise((resolve, reject) => {
player.on('dispose', keySession.close);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this work properly to have the close() method not directly attached/bound to keySession?
would it be better to bind it or wrap in an arrow function?

@alex-barstow alex-barstow merged commit c8ca31a into main Oct 13, 2022
@alex-barstow alex-barstow deleted the close-keysession-on-dispose branch October 13, 2022 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants