From 25d82a45649b9710b84e263732805ae45f04ec05 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) --- src/ui/public/vis_maps/maps_renderbot.js | 40 +++++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/ui/public/vis_maps/maps_renderbot.js b/src/ui/public/vis_maps/maps_renderbot.js index 1e64f1810428a..30a660499a05d 100644 --- a/src/ui/public/vis_maps/maps_renderbot.js +++ b/src/ui/public/vis_maps/maps_renderbot.js @@ -229,14 +229,46 @@ module.exports = function MapsRenderbotFactory(Private, $injector, serviceSettin } }; } - - _doRenderComplete() { + + _doRenderCompleteWhenBaseLayerIsLoaded(resolve, endTime) { if (this._paramsDirty || this._dataDirty || this._baseLayerDirty) { - return; + 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(); } - this.$el.trigger('renderComplete'); } + + _doRenderComplete() { + const msAllowedForBaseLayerToLoad = 10000; + const resolve = () => { + this.$el.trigger('renderComplete'); + }; + this._doRenderCompleteWhenBaseLayerIsLoaded(resolve, Date.now() + msAllowedForBaseLayerToLoad); + } + + + + + + + + + + + + + + } function addSpatialFilter(agg, filterName, filterData) {