0026572277199c1d6873b958e0382e381f5cd460
max
  Wed Oct 16 08:52:08 2024 -0700
fixing a bug where setTimeout was run with seconds instead of milliseconds. Due to how the page loads, that bug had no effect in most circumstances, as the timer was immediately stopped afterwards. For mysterious reaons this bug is only visible when you open a new private browser window and only on first page load, no caches. No redmine yet, email from Lou.

diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c
index 5e3358f..cdf90c5 100644
--- src/hg/hgTracks/hgTracks.c
+++ src/hg/hgTracks/hgTracks.c
@@ -10182,32 +10182,39 @@
 	// erase the highlight cartvar if it has no overlap with the new virt chrom
 	cartRemove(cart, "highlight");
 	}
     }
 }
 
 static void setupTimeWarning()
 /* add javascript that outputs a warning message if page takes too long to load */
 {
 char *maxTimeStr = cfgOption("warnSeconds");
 if (!maxTimeStr)
     return;
 
 double maxTime = atof(maxTimeStr);
 struct dyString *dy = dyStringNew(150);
-dyStringPrintf(dy, "var warnTimingTimer = setTimeout( function() { hgtWarnTiming(0)}, %f);\n", maxTime);
+
+// The idea of the timer below is that if the page takes a ton of time to load, the message will come up while the page still builds
+// However, due to gzip compression of the page and also most of the time spent in the CGI itself, the timer only starts
+// when most of the work has been completed. So the timer is only useful if what takes long is our own hgTracks javascript
+dyStringPrintf(dy, "var warnTimingTimer = setTimeout( function() { hgtWarnTiming(%f)}, %f);\n", maxTime, maxTime*1000);
+// In most cases, since the timer does not work well in practice, the following will always work: 
+// once the page is ready, we check how long it took to load.
 dyStringPrintf(dy, "$(document).ready( function() { clearTimeout(warnTimingTimer); hgtWarnTiming(%f)});\n", maxTime);
+
 jsInline(dy->string);
 dyStringFree(&dy);
 }
 
 
 void tracksDisplay()
 /* Put up main tracks display. This routine handles zooming and
  * scrolling. */
 {
 char titleVar[256];
 char *oldPosition = cartUsualString(cart, "oldPosition", "");
 boolean findNearest = cartUsualBoolean(cart, "findNearest", FALSE);
 cartRemove(cart, "findNearest");
 
 boolean positionIsVirt = FALSE;