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 EME controller async errors #2552

Merged
merged 1 commit into from
Mar 16, 2020
Merged

Fix EME controller async errors #2552

merged 1 commit into from
Mar 16, 2020

Conversation

robwalch
Copy link
Collaborator

@robwalch robwalch commented Mar 14, 2020

This PR will...

Fix "Fatal: Media is encrypted but no CDM access or no keys have been obtained yet" error by using a mediaKeys promise in the "encrypted" event callback.

Why is this Pull Request needed?

EME API is async, but our handling of the 'encrypted' media event is not which causes functional tests to fail.

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

@robwalch
Copy link
Collaborator Author

Related to #1918

@robwalch robwalch changed the title [WIP] Test EME async fix Fix EME controller async errors Mar 15, 2020
this._onMediaKeySystemAccessObtained(keySystem, mediaKeySystemAccess));

keySystemAccessPromise.catch((err) => {
logger.error(`Failed to obtain key-system "${keySystem}" access:`, err);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why don't we actually trigger errors in catch blocks?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We definitely can throw an error. Not sure off the top of my head what happens if you rethrow in the catch block, it might actually hit window and stop the current stack from running, rather than just reject the promise.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm just talking about triggering the no-key/access/session error events in catch blocks.

Throwing in the catch block throws the stack, and is caught in a wrapping promise if there is one.

We could throw in methods wrapped in promises like _attemptSetMediaKeys and _generateRequestWithPreferredKeySession and in a catch block, trigger the error events based on error object. These are just thoughts for how to improve the controller in v1. For this PR the goal is to just fix the failing functional test which it does.

});

mediaKeysPromise.catch((err) => {
logger.error('Failed to create media-keys:', err);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If we triggered errors in catch blocks we wouldn't need keysListItem checks in _attemptSetMediaKeys and _generateRequestWithPreferredKeySession.

My thought is to leave as-is for 0.14, but refactor in feature/v1.0.0.

type: ErrorTypes.KEY_SYSTEM_ERROR,
details: ErrorDetails.KEY_SYSTEM_NO_KEYS,
fatal: true
});
Copy link
Collaborator Author

@robwalch robwalch Mar 15, 2020

Choose a reason for hiding this comment

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

This would really be more of an async error.

If for whatever reason onManifestParsed was not called or did not set mediaKeysPromise, we could always call _attemptKeySystemAccess here to get the ball rolling. That way this redundant error handling could be removed.

@robwalch robwalch merged commit 7663044 into master Mar 16, 2020
@robwalch robwalch deleted the bugfix/eme-async branch March 16, 2020 17:48
@robwalch robwalch added this to the 0.14.0 milestone Mar 16, 2020
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.

None yet

2 participants