diff --git a/code/status_bar.js b/code/status_bar.js
index 00e998d8..8aef2bb3 100644
--- a/code/status_bar.js
+++ b/code/status_bar.js
@@ -2,6 +2,8 @@
// gives user feedback about pending operations. Draws current status
// to website. Updates info in layer chooser.
+window.renderUpdateStatusTimer_ = undefined;
+
window.renderUpdateStatus = function() {
var progress = 1;
@@ -41,28 +43,6 @@ window.renderUpdateStatus = function() {
t += '...unknown...';
}
-/*
- if(mapRunsUserAction)
- t += 'pausedIdle';
- else if(window.requests._quickRefreshPending)
- t += 'refreshing';
- else if(window.activeRequests.length > 0)
- t += window.activeRequests.length + ' requests';
- else {
- // tooltip with detailed tile counts
- t += '';
-
- // basic error/out of date/up to date message
- if (window.statusErrorMapTiles) t += 'Errors';
- else if (window.statusStaleMapTiles) t += 'Out of date';
- else t += 'Up to date';
-
- t += '';
-
- }
-*/
t += '';
//request status
@@ -72,16 +52,26 @@ window.renderUpdateStatus = function() {
t += ' ' + window.failedRequestCount + ' failed'
+ //it's possible that updating the status bar excessively causes some performance issues. so rather than doing it
+ //immediately, delay it to the next javascript event loop, cancelling any pending update
+ // will also cause any browser-related rendering to occur first, before the status actually updates
- $('#innerstatus').html(t);
- //$('#updatestatus').click(function() { startRefreshTimeout(10); });
- //. ⟳';
+ if (window.renderUpdateStatusTimer_) clearTimeout(window.renderUpdateStatusTimer_);
- if(progress == 1 && window.activeRequests.length > 0) {
- // we don't know the exact progress, but we have requests (e.g. chat) running, so show it as indeterminate.
- progress = -1;
- }
+ window.renderUpdateStatusTimer_ = setTimeout ( function() {
+ window.renderUpdateStatusTimer_ = undefined;
+
+ $('#innerstatus').html(t);
+ //$('#updatestatus').click(function() { startRefreshTimeout(10); });
+ //. ⟳';
+
+ if(progress == 1 && window.activeRequests.length > 0) {
+ // we don't know the exact progress, but we have requests (e.g. chat) running, so show it as indeterminate.
+ progress = -1;
+ }
+
+ if (typeof android !== 'undefined' && android && android.setProgress)
+ android.setProgress(progress);
+ }, 0);
- if (typeof android !== 'undefined' && android && android.setProgress)
- android.setProgress(progress);
}