Bug Report: OHB Timer
BotB Academy Bug Reports and Feature Requests
Level 20 Criticist
post #119422 :: 2020.04.19 12:42pm
  Flaminglog, xterm and Lincent liēkd this
I don't know if it's just me, but all the time, since the dawn of time, the entry period timer on OHBs will countdown at one rate while I'm on that screen, but when I refresh suddenly it'll be way faster. I can't trust that timer at all.

e.g. load the page with 60min left at ohb start, then wait on that screen while making the song until it says 30min left. When I refresh, it'll say something like 10min left.

Using latest firefox in win7. I'm often tabbed out of the browser or in a different tab.
Level 30 Chipist
post #119424 :: 2020.04.19 12:44pm
i can agree that this is an issue in firefox, i experienced it as well before.
im usually using chrome tho, and its not a problem here
Level 25 Chipist
post #119432 :: 2020.04.19 2:56pm
yes I can confirm it's been happening to me ever since I switched to firefox so I'm pretty sure it's a firefox specific thing, not really sure how the countdown is calculated maybe it's some kind of bug in javascript on FF
Level 25 Chipist
post #119441 :: 2020.04.19 4:06pm
  tennisers, kleeder and xterm liēkd this
alright for some reason when looking in developer tools in firefox the code in /js/jquery.init.js was missing for some reason but I managed to take a look at it by just opening it in the browser

anyways, the countdown code works by using setInterval, which is pretty inaccurate for timing and since firefox is trying to be clever by slowing down processing cycles in inactive tabs, the setInterval delay is actually being increased by the browser depending on processes and things

here's the actual code, run after document.ready

the same issue is also described in this stackoverflow question

== note: this could be a way to do this, might not be the best way and I haven't actually tested it, or know it will work ==

one way to fix this would be to base the timer off timestamps, get a UTC timestamp from the back-end php script and keep the setInterval. then every time HandleCountdownTimers is called, instead of decrementing the time by one, compare the php timestamp to Math.floor(Date.now() / 1000); which gets the UTC timestamp in seconds. Find the second difference and return <length of compo in seconds> - <difference between timestamps> then parse seconds, minutes, hours, etc.

asynchronous javascript stuff just can't really be relied upon for precise timing
Level 26 Mixist
post #119447 :: 2020.04.19 5:52pm
yeah i've been having this problem as well. the workaround is to make a note of the timestamp underneath the ohb icon, which i believe is when entries are due. that, or, refresh the page whenever you've been tabbed away
Level 28 Hostist
post #119449 :: 2020.04.19 7:12pm
  Flaminglog liēkd this
could use the browser Date object . . .
Level 28 Hostist
post #124125 :: 2020.07.29 12:38pm
  Flaminglog, tennisers, sasami, big lumby, xterm, charlotte, Xyz, argarak, damifortune, RazerBlue6 and kleeder liēkd this
now using the browser Date object . . .

LOGIN or REGISTER to add your own comments!