fix: Report media failures once per failure (#2666)

This commit is contained in:
Dermot Duffy
2026-08-09 10:48:17 -07:00
committed by GitHub
parent 8d8d486afa
commit 5e199b5612
22 changed files with 484 additions and 123 deletions
@@ -248,12 +248,34 @@ describe('MediaPlayerLivenessDetector', () => {
await callIntersectionHandler(true);
fireMediaPlayerLiveness(false);
detector.reset();
detector.invalidate('stream-changed');
expect(detector.getVerdict()).toEqual({ state: 'unknown' });
expect(unsubscribe).toHaveBeenCalledTimes(1);
});
it('should keep the verdict when media loads', async () => {
const { detector, loadMedia } = setup();
const { player, unsubscribe, fireMediaPlayerLiveness } = createPlayer();
detector.subscribe();
loadMedia(player);
await callIntersectionHandler(true);
fireMediaPlayerLiveness(false);
// The media player reported that media it had already loaded stopped
// delivering frames, which another load does not answer.
detector.invalidate('media-loaded');
expect(detector.getVerdict()).toEqual({
state: 'not_live',
authority: 'direct',
renderPlaceholder: true,
reason: 'stalled',
});
expect(unsubscribe).not.toHaveBeenCalled();
});
it('should tear down the watch and stop listening on unsubscribe', async () => {
const { detector, loadMedia } = setup();
const first = createPlayer();