From d1db694f6e58d27ae40e9b37f8fd8238c5d4d167 Mon Sep 17 00:00:00 2001 From: Vincent Valot Date: Tue, 27 Jun 2023 20:02:27 +0200 Subject: [PATCH] fix: prevent access to null config_ in SimpleAbrManager (#5362) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Well sometimes network information change could be triggered even if this.config_ is null, resulting in an exception thrown in the browser. Doesn't affect playback, but affects the number of errors detected by our tools 😅 Let's check if abrManager is enabled before checking its config --- lib/abr/simple_abr_manager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/abr/simple_abr_manager.js b/lib/abr/simple_abr_manager.js index 304d11eec2..0b5a885ffc 100644 --- a/lib/abr/simple_abr_manager.js +++ b/lib/abr/simple_abr_manager.js @@ -54,7 +54,7 @@ shaka.abr.SimpleAbrManager = class { // of connectivity changes. if (navigator.connection && navigator.connection.addEventListener) { this.onNetworkInformationChange_ = () => { - if (this.config_.useNetworkInformation && this.enabled_) { + if (this.enabled_ && this.config_.useNetworkInformation) { this.bandwidthEstimator_ = new shaka.abr.EwmaBandwidthEstimator(); if (this.config_) { this.bandwidthEstimator_.configure(this.config_.advanced);