From 55bb9cd3d1d1f84b31ed6a5e00936d8068074028 Mon Sep 17 00:00:00 2001 From: Chili Johnson Date: Mon, 28 Nov 2022 12:53:00 -0800 Subject: [PATCH] Passes the tileSourceLoaderLimit option through the viewer constructor. --- src/openseadragon.js | 11 ++++++++++- src/viewer.js | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/openseadragon.js b/src/openseadragon.js index be45ac07..cb9a534c 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -312,6 +312,10 @@ * it is set to 0 allowing the browser to make the maximum number of * image requests in parallel as allowed by the browsers policy. * + * @property {Number} [tileSourceLoaderLimit=0] + * The maximum number of tile source requests to make concurrently. By default + * it is set to 0 allowing an unlimited number of concurrent requests. + * * @property {Number} [clickTimeThreshold=300] * The number of milliseconds within which a pointer down-up event combination * will be treated as a click gesture. @@ -792,7 +796,7 @@ function OpenSeadragon( options ){ requestFuncs: [], numRequests: 0, numActiveRequests: 0, - maxConcurrency: 50, + maxConcurrency: 0, }; /** @@ -1339,6 +1343,7 @@ function OpenSeadragon( options ){ //PERFORMANCE SETTINGS imageLoaderLimit: 0, + tileSourceLoaderLimit: 0, maxImageCacheCount: 200, timeout: 30000, useCanvas: true, // Use canvas element for drawing if available @@ -2339,6 +2344,10 @@ function OpenSeadragon( options ){ }, queueAjaxRequest: function (request, sendRequestFunc) { + if(!$.ajaxQueue.maxConcurrency) { + sendRequestFunc(); + } + var oldOnStateChange = request.onreadystatechange; var onCompleteRequest = function() { diff --git a/src/viewer.js b/src/viewer.js index 3928ee02..48a77bcc 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -394,6 +394,10 @@ $.Viewer = function( options ) { timeout: options.timeout }); + // TODO: Instantiating a viewer shouldn't have + // a side effect on the global queue + $.ajaxQueue.maxConcurrency = options.tileSourceLoaderLimit; + // Create the tile cache this.tileCache = new $.TileCache({ maxImageCacheCount: this.maxImageCacheCount