Skip to content

Commit

Permalink
Don't wait for sessions to close on DrmEngine#destroy (#1168)
Browse files Browse the repository at this point in the history
This is a workaround for Chrome bug https://crbug.com/690583

Resolves #1093
  • Loading branch information
chrisfillmore authored and joeyparrish committed Dec 4, 2017
1 parent c218844 commit e387e06
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/media/drm_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,21 @@ shaka.media.DrmEngine.prototype.destroy = function() {
var Functional = shaka.util.Functional;
this.destroyed_ = true;

var async = this.activeSessions_.map(function(activeSession) {
// TODO: wait for sessions to close when destroying. Due to a bug in Chrome,
// sometimes the Promise returned by MediaKeySession#close never resolves.
// See #1093 and https://crbug.com/690583
this.activeSessions_.forEach(function(activeSession) {
// Ignore any errors when closing the sessions. One such error would be
// an invalid state error triggered by closing a session which has not
// generated any key requests.
// Chrome sometimes returns |undefined|: https://crbug.com/690664
var p = activeSession.session.close() || Promise.resolve();
return p.catch(Functional.noop);
p = p.catch(Functional.noop);
});
this.allSessionsLoaded_.reject();

var async = [];

if (this.eventManager_)
async.push(this.eventManager_.destroy());

Expand Down

0 comments on commit e387e06

Please sign in to comment.