From db66a912bf60e1fd8ecbffe4e505e1771742536d Mon Sep 17 00:00:00 2001 From: Bertrand Berthelot Date: Wed, 29 Sep 2021 14:56:13 +0200 Subject: [PATCH] Avoid creating one HTTPLoader instance per request --- src/streaming/net/URLLoader.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/streaming/net/URLLoader.js b/src/streaming/net/URLLoader.js index 2d1dfa9dec..90a8416f57 100644 --- a/src/streaming/net/URLLoader.js +++ b/src/streaming/net/URLLoader.js @@ -49,21 +49,21 @@ function URLLoader(cfg) { schemeLoaderFactory = SchemeLoaderFactory(context).getInstance(); function load(config) { - - let loaderFactory = schemeLoaderFactory.getLoader(config && config.request ? config.request.url : null); - loader = loaderFactory(context).create({ - errHandler: cfg.errHandler, - mediaPlayerModel: cfg.mediaPlayerModel, - requestModifier: cfg.requestModifier, - dashMetrics: cfg.dashMetrics, - boxParser: cfg.boxParser ? cfg.boxParser : null, - constants: cfg.constants ? cfg.constants : null, - dashConstants: cfg.dashConstants ? cfg.dashConstants : null, - urlUtils: cfg.urlUtils ? cfg.urlUtils : null, - requestTimeout: !isNaN(cfg.requestTimeout) ? cfg.requestTimeout : 0, - errors: cfg.errors - }); - + if (!loader) { + let loaderFactory = schemeLoaderFactory.getLoader(config && config.request ? config.request.url : null); + loader = loaderFactory(context).create({ + errHandler: cfg.errHandler, + mediaPlayerModel: cfg.mediaPlayerModel, + requestModifier: cfg.requestModifier, + dashMetrics: cfg.dashMetrics, + boxParser: cfg.boxParser ? cfg.boxParser : null, + constants: cfg.constants ? cfg.constants : null, + dashConstants: cfg.dashConstants ? cfg.dashConstants : null, + urlUtils: cfg.urlUtils ? cfg.urlUtils : null, + requestTimeout: !isNaN(cfg.requestTimeout) ? cfg.requestTimeout : 0, + errors: cfg.errors + }); + } loader.load(config); }