Skip to content

fix(eme-controller): unhandled type error depending on promise state#7877

Open
bwallberg wants to merge 1 commit into
video-dev:masterfrom
bwallberg:bugfix/pending-key-promise-unhandled
Open

fix(eme-controller): unhandled type error depending on promise state#7877
bwallberg wants to merge 1 commit into
video-dev:masterfrom
bwallberg:bugfix/pending-key-promise-unhandled

Conversation

@bwallberg
Copy link
Copy Markdown
Contributor

This PR will...

Add missing throwIfDestroyed() after keySystemAccess has resolved, this prevents the promise chain to continue in an invalid state resulting in type errors due to expectation of this.config to exist.

I also added a catch to the this.keyFormatPromise that is "cached" until onMediaEncrypted is called, this prevents an unhandled promise rejection from surfacing to the consumer if it occurs before onMediaEncrypted is called.

It's fairly easy to reproduce when playing any DRM protected media with a #EXT-X-SESSION-KEY in the manster manifest, just add the following to your code ( I haven't seen it myself for real but can see it in bugsnag ).

hlsjs.on(Events.MANIFEST_LOADED, () => {
  hlsjs.destroy();
});

Why is this Pull Request needed?

Unhandled promise rejection surfaces to the consumer of hls.js eg. to bugsnag/sentry etc unnecessarily as the rejection thrown after the hls.js has been destroyed.

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

The this.keyFormatPromise.catch(() => {}); silents an error until the media element detects the media is encrypted, a nicer solution might be to handle the error but not consider it fatal, but that has more impact on the API.

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 N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

2 participants