Skip to content

Commit

Permalink
fix: Restore missing logic for disabling streams on error
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyparrish committed Sep 24, 2024
1 parent fc4893d commit 9b2bb07
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -2781,18 +2781,25 @@ shaka.media.StreamingEngine = class {
* @private
*/
async handleStreamingError_(mediaState, error) {
const logPrefix = shaka.media.StreamingEngine.logPrefix_(mediaState);

// If we invoke the callback right away, the application could trigger a
// rapid retry cycle that could be very unkind to the server. Instead,
// use the backoff system to delay and backoff the error handling.
await this.failureCallbackBackoff_.attempt();
this.destroyer_.ensureNotDestroyed();

// Try to recover from network errors
if (error.category === shaka.util.Error.Category.NETWORK) {
if (error.category === shaka.util.Error.Category.NETWORK &&
error.code == shaka.util.Error.Code.HTTP_ERROR) {
if (mediaState.restoreStreamAfterTrickPlay) {
this.setTrickPlay(/* on= */ false);
return;
}
const maxDisabledTime = this.getDisabledTime_(error);
if (maxDisabledTime) {
shaka.log.debug(logPrefix, 'Disabling stream due to error', error);
}
error.handled = this.playerInterface_.disableStream(
mediaState.stream, maxDisabledTime);

Expand All @@ -2817,6 +2824,7 @@ shaka.media.StreamingEngine = class {

/**
* @param {!shaka.util.Error} error
* @return {number}
* @private
*/
getDisabledTime_(error) {
Expand Down

0 comments on commit 9b2bb07

Please sign in to comment.