2 ms·
The timer basically runs in another thread, and once it’s finished it’s callback/frame goes into the queue, it does not go into the queue before the time you ga
by jayflux 8y ago
The timer basically runs in another thread, and once it’s finished it’s callback/frame goes into the queue, it does not go into the queue before the time you gave. The reason the time can’t be accurate is because other “frames” could be ahead of it in the queue after the timer has finished.
- asknthrow 8y agoI don't think this is correct. AFAIK they both run in the UI thread (which is why running your timer in a webworker turns out to be more accurate as only the callback is affected by queue length of scheduled calls in the UI thread). Although this article https://www.html5rocks.com/en/tutorials/audio/scheduling https://www.html5rocks.com/en/tutorials/audio/scheduling is about sheduling audio specifically, it is the go-to resource for accurate web timing (and although not explicitly mentioned, the metronome is supposed to run in a webworker).