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(DRM): close properly webkit media key sessions #6775

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

tykus160
Copy link
Member

On WebOS 3.0 we've noticed an issue in production, where TVs are slowly starting to throw the following error after a user has watched at least 30+ episodes: Code: 6006 Category: 6 Severity: 2 ["EME v0.1b key error",{"errorCode":{"code":1,"systemCode":65535}},"0xffff"] and can only be resolved by clearing the app cache, or unplugging the TV.
Further investigation revealed that current workflow, where MSE is destroyed before DRM Engine causes that old EME implementation is not able to close session properly.
image

@avelad avelad requested a review from joeyparrish June 10, 2024 08:17
@avelad avelad added type: bug Something isn't working correctly component: EME The issue involves the Encrypted Media Extensions web API priority: P1 Big impact or workaround impractical; resolve before feature release platform: WebOS Issues affecting WebOS labels Jun 10, 2024
@avelad avelad added this to the v4.10 milestone Jun 10, 2024
@avelad
Copy link
Member

avelad commented Jun 10, 2024

@shaka-bot test

@shaka-bot
Copy link
Collaborator

@avelad: Lab tests started with arguments:

  • pr=6775

@shaka-bot
Copy link
Collaborator

Incremental code coverage: 82.76%

@avelad avelad self-requested a review June 11, 2024 06:07
@avelad avelad merged commit 309bd72 into shaka-project:main Jun 11, 2024
35 of 36 checks passed
@tykus160 tykus160 deleted the wt-webkit branch June 11, 2024 06:30
avelad pushed a commit that referenced this pull request Jun 11, 2024
On WebOS 3.0 we've noticed an issue in production, where TVs are slowly
starting to throw the following error after a user has watched at least
30+ episodes: `Code: 6006 Category: 6 Severity: 2 ["EME v0.1b key
error",{"errorCode":{"code":1,"systemCode":65535}},"0xffff"]` and can
only be resolved by clearing the app cache, or unplugging the TV.
Further investigation revealed that current workflow, where MSE is
destroyed before DRM Engine causes that old EME implementation is not
able to close session properly.
avelad pushed a commit that referenced this pull request Jun 11, 2024
On WebOS 3.0 we've noticed an issue in production, where TVs are slowly
starting to throw the following error after a user has watched at least
30+ episodes: `Code: 6006 Category: 6 Severity: 2 ["EME v0.1b key
error",{"errorCode":{"code":1,"systemCode":65535}},"0xffff"]` and can
only be resolved by clearing the app cache, or unplugging the TV.
Further investigation revealed that current workflow, where MSE is
destroyed before DRM Engine causes that old EME implementation is not
able to close session properly.
// EME v0.1b requires the media element to clear the MediaKeys
if (shaka.util.Platform.isMediaKeysPolyfilled('webkit') &&
this.drmEngine_) {
await this.drmEngine_.destroy();
Copy link
Member

Choose a reason for hiding this comment

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

Is there a downside to destroying DRM engine this early in all cases? Do we need two paths for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

We wanted to make this patch not invasive as much as possible. But I agree though, having diverged paths is not elegant. I can try to move drm engine teardown before the MSE one.

Copy link
Member

Choose a reason for hiding this comment

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

@tykus160 please create a feat with the change

Copy link
Member Author

@tykus160 tykus160 Jun 13, 2024

Choose a reason for hiding this comment

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

Hey @joeyparrish @avelad
According to EME spec:

Support for clearing or replacing the associated MediaKeys object during playback is a quality of implementation issue. In many cases it will result in a bad user experience or rejected promise.

In Chrome if I move drm destroy before mse, next playbacks of protected content are starting to stall after few secs. I’m using Angel One to test, I guess first few secs are clear there... I'm not sure why it is like that, but I see that MediaKeys are attached to the video element.
Explicitly unloading video element in DRM Engine before setting MediaKeys to null seems to fix the issue mentioned above and I see no drawbacks across Chrome, Firefox & Safari in MSE mode. I need to check though how it behaves on SmartTVs.

@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Aug 10, 2024
@shaka-project shaka-project locked as resolved and limited conversation to collaborators Aug 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: EME The issue involves the Encrypted Media Extensions web API platform: WebOS Issues affecting WebOS priority: P1 Big impact or workaround impractical; resolve before feature release status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants