Skip to content

Commit

Permalink
fix(offline): Fix error when un-storing DRM asset
Browse files Browse the repository at this point in the history
The DRM engine, when asked to remove a session, would then
remove it again when destroyed.
This changes the DRM engine to no longer track removed sessions
as active.

Closes shaka-project#3534

Change-Id: I2a3b99eb97e1d8f68282062c592a7cd35ffbe3cd
  • Loading branch information
theodab committed Sep 9, 2021
1 parent 6a775e2 commit 23e0d76
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/media/drm_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ shaka.media.DrmEngine = class {
tasks.push(session.remove());

await Promise.all(tasks);
this.activeSessions_.delete(session);
}

/**
Expand Down
13 changes: 13 additions & 0 deletions test/media/drm_engine_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2285,6 +2285,19 @@ describe('DrmEngine', () => {
await expectAsync(drmEngine.removeSession('abc'))
.toBeRejectedWith(expected);
});

// Regression test for #3534
it('does not remove the same session again on destroy', async () => {
updatePromise.resolve();
expect(session1.remove).not.toHaveBeenCalled();
await drmEngine.removeSession('abc');
expect(session1.remove).toHaveBeenCalled();
session1.remove.calls.reset();
await drmEngine.destroy();
// The session should only be removed ONCE. If it's double-removed, it
// will make a (non-fatal) DOMException.
expect(session1.remove).not.toHaveBeenCalled();
});
});

describe('expiration', () => {
Expand Down

0 comments on commit 23e0d76

Please sign in to comment.