Skip to content

Commit f5ea7ad

Browse files
authored
fix: Fix onUpdateEnd when the MSE engine has been destroyed (#8591)
Related to #8491
1 parent 42c08f6 commit f5ea7ad

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/media/media_source_engine.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,20 @@ shaka.media.MediaSourceEngine = class {
19441944
* @private
19451945
*/
19461946
onUpdateEnd_(contentType) {
1947-
if (this.reloadingMediaSource_) {
1947+
// If we're reloading or have been destroyed, clear the queue for this
1948+
// content type.
1949+
if (this.reloadingMediaSource_ || this.destroyer_.destroyed()) {
1950+
// Resolve any pending operations in this content type's queue
1951+
const queue = this.queues_.get(contentType);
1952+
if (queue && queue.length) {
1953+
// Resolve the first operation that triggered this updateEnd
1954+
const firstOperation = queue[0];
1955+
if (firstOperation && firstOperation.p) {
1956+
firstOperation.p.resolve();
1957+
}
1958+
// Clear the rest of the queue
1959+
this.queues_.set(contentType, []);
1960+
}
19481961
return;
19491962
}
19501963
const operation = this.queues_.get(contentType)[0];

0 commit comments

Comments
 (0)