From fddf65d3e0e02dc78101f8ab1b3f3b4d8b38ca0a Mon Sep 17 00:00:00 2001 From: Daniel Silhavy Date: Thu, 17 Aug 2023 20:13:07 +0200 Subject: [PATCH] Clear list of resource timing entries once buffer is full (#4263) --- .../controllers/ThroughputController.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/streaming/controllers/ThroughputController.js b/src/streaming/controllers/ThroughputController.js index 7418ab09d1..4e954e6c78 100644 --- a/src/streaming/controllers/ThroughputController.js +++ b/src/streaming/controllers/ThroughputController.js @@ -68,10 +68,28 @@ function ThroughputController() { function _registerEvents() { eventBus.on(MediaPlayerEvents.METRIC_ADDED, _onMetricAdded, instance); + + if (performance) { + performance.addEventListener( + 'resourcetimingbufferfull', + _onResourceTimingBufferFull, + ); + } } function _resetEvents() { eventBus.off(MediaPlayerEvents.METRIC_ADDED, _onMetricAdded, instance); + + if (performance) { + performance.removeEventListener( + 'resourcetimingbufferfull', + _onResourceTimingBufferFull, + ); + } + } + + function _onResourceTimingBufferFull() { + performance.clearResourceTimings(); } /**