From 5e713df81e49d87c1e6f82507c28a8416681c900 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Tue, 3 Oct 2017 22:33:21 -0400 Subject: [PATCH] limit wait time for baselayer (#14047) --- .../tile_map/public/maps_visualization.js | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/core_plugins/tile_map/public/maps_visualization.js b/src/core_plugins/tile_map/public/maps_visualization.js index df4a4e70fb556..a6ac81cca7374 100644 --- a/src/core_plugins/tile_map/public/maps_visualization.js +++ b/src/core_plugins/tile_map/public/maps_visualization.js @@ -255,16 +255,28 @@ export function MapsVisualizationProvider(serviceSettings, Notifier, getAppState }; } - _doRenderComplete(resolve) { - if (this._baseLayerDirty) {//as long as the baselayer is dirty, we cannot fire the render complete event - setTimeout(() => { - this._doRenderComplete(resolve); - }, 10); + _doRenderCompleteWhenBaseLayerIsLoaded(resolve, endTime) { + if (this._baseLayerDirty) { + if (Date.now() <= endTime) { + setTimeout(() => { + this._doRenderCompleteWhenBaseLayerIsLoaded(resolve, endTime); + }, 10); + } else { + //wait time exceeded. If the baselayer cannot load, we will still fire a render-complete. + //This is because slow or unstable network connections cause tiles to get dropped. + //It is unfortunate that tiles get dropped, but we should not drop the render-complete because of it. + resolve(); + } } else { resolve(); } } + _doRenderComplete(resolve) { + const msAllowedForBaseLayerToLoad = 10000; + this._doRenderCompleteWhenBaseLayerIsLoaded(resolve, Date.now() + msAllowedForBaseLayerToLoad); + } + addSpatialFilter(agg, filterName, filterData) { if (!agg) { return;