fix(playback): tear down the Shaka engine on critical error events too

A non-recoverable Shaka error emitted after a successful load left the
dead engine attached to the media element and exposed to the
shared-controls bridge (Greptile P1, round 2). Critical error events now
destroy the player right after the diagnostic is emitted, matching the
load-failure path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
4grayandClaude Fable 5 committed 2026-07-24 00:02:47 +02:00
1 parent c19c639ef2
commit 61651b659b
2 files changed
+7

No files matched your search

@@ -102,10 +102,14 @@ describe('ShakaVideoSession', () => {
const player = environment.instances[0];
player.dispatch('error', { severity: 1, category: 1, code: 1002 });
expect(issues).toEqual([]);
expect(session.getPlayer()).toBe(player);
player.dispatch('error', { severity: 2, category: 6, code: 6001 });
expect(issues).toHaveLength(1);
expect(issues[0].code).toBe(PlaybackDiagnosticCode.DrmOrEncryption);
// Critical errors end playback: the dead engine must be torn down.
expect(player.destroyCount).toBe(1);
expect(session.getPlayer()).toBeNull();
});
it('emits a diagnostic and tears the engine down when load rejects', async () => {
@@ -236,6 +236,9 @@ export class ShakaVideoSession {
this.config.emitPlaybackIssue(
classifyShakaPlaybackIssue(detail, this.createMetadata(url))
);
// Critical errors end playback; never leave the dead engine
// attached or exposed to the shared-controls bridge.
this.beginPlayerTeardown();
};
const refreshListener = (): void => {
if (!this.isStale(generation) && this.player === player) {