From f8cb6ef50a5501a92a94e13099a80690fb7b046d Mon Sep 17 00:00:00 2001 From: Tian Shao Date: Tue, 15 Aug 2023 08:43:01 -0700 Subject: [PATCH] fix: Fix memory leak on SimpleAbrManager (#5478) closes [#5477](https://github.com/shaka-project/shaka-player/issues/5477) Moving `this.onNetworkInformationChange_ = null;` before creating the navigator.connection event listener. Currently it resets it to null after creating the listener so the release() wont be able to remove the eventlistener --- lib/abr/simple_abr_manager.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/abr/simple_abr_manager.js b/lib/abr/simple_abr_manager.js index 0b5a885ffc..8f3d866c0c 100644 --- a/lib/abr/simple_abr_manager.js +++ b/lib/abr/simple_abr_manager.js @@ -48,6 +48,9 @@ shaka.abr.SimpleAbrManager = class { /** @private {shaka.abr.EwmaBandwidthEstimator} */ this.bandwidthEstimator_ = new shaka.abr.EwmaBandwidthEstimator(); + /** @private {?function():void} */ + this.onNetworkInformationChange_ = null; + // Some browsers implement the Network Information API, which allows // retrieving information about a user's network connection. We listen // to the change event to be able to make quick changes in case the type @@ -98,9 +101,6 @@ shaka.abr.SimpleAbrManager = class { /** @private {ResizeObserver} */ this.resizeObserver_ = null; - /** @private {?function():void} */ - this.onNetworkInformationChange_ = null; - /** @private {shaka.util.Timer} */ this.resizeObserverTimer_ = new shaka.util.Timer(() => { if (this.config_.restrictToElementSize) {