From 8e42816ec53385e43b3daa6982c0bb57a24ce570 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Wed, 24 Sep 2025 20:30:41 -0400 Subject: [PATCH] Clear srcObject before replaying torrents --- js/app.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/js/app.js b/js/app.js index 6ebb0f13..79bf45c3 100644 --- a/js/app.js +++ b/js/app.js @@ -1247,12 +1247,20 @@ class bitvidApp { if (this.videoElement) { this.videoElement.pause(); this.videoElement.src = ""; + // When WebTorrent (or other MediaSource based flows) mount a stream they + // set `srcObject` behind the scenes. Forgetting to clear it leaves the + // detached MediaSource hanging around which breaks the next playback + // attempt. Always null it out alongside the normal `src` reset. + this.videoElement.srcObject = null; this.videoElement.load(); } // If there's a modal video if (this.modalVideo) { this.modalVideo.pause(); this.modalVideo.src = ""; + // See comment above—keep the `srcObject` reset paired with the `src` + // wipe so magnet-only replays do not regress into the grey screen bug. + this.modalVideo.srcObject = null; this.modalVideo.load(); } // Tell webtorrent to cleanup @@ -2372,8 +2380,13 @@ class bitvidApp { await torrentClient.cleanup(); this.modalVideo.pause(); + // Clearing the WebTorrent attachment requires wiping both `src` and + // `srcObject`. Multiple regressions have shipped where we only blanked + // `src`, leaving the old MediaSource wired up and the next magnet would + // stall on a grey frame. Always clear both before calling `load()`. this.modalVideo.src = ""; this.modalVideo.removeAttribute("src"); + this.modalVideo.srcObject = null; this.modalVideo.load(); this.resetTorrentStats();