diff --git a/lib/media/drm_engine.js b/lib/media/drm_engine.js index 33755e9bea..200011c088 100644 --- a/lib/media/drm_engine.js +++ b/lib/media/drm_engine.js @@ -550,6 +550,7 @@ shaka.media.DrmEngine = class { tasks.push(session.remove()); await Promise.all(tasks); + this.activeSessions_.delete(session); } /** diff --git a/test/media/drm_engine_unit.js b/test/media/drm_engine_unit.js index 405979f227..707a2372c6 100644 --- a/test/media/drm_engine_unit.js +++ b/test/media/drm_engine_unit.js @@ -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', () => {