3 ms·
This really needs a (2013) in the title (or at least a "pre-Spectre/Meltdown"). The "up-and-coming" (back in 2013) high-resolution timer performance.now() exis
by flohofwoe 4y ago
This really needs a (2013) in the title (or at least a "pre-Spectre/Meltdown").
The "up-and-coming" (back in 2013) high-resolution timer performance.now() exists on all browsers for a long time by now, but is clamped to milliseconds on some browsers because of the Spectre/Meltdown mitigations. The web audio timer is also affected by this precision reduction, but I don't know what's the current situation across browsers (I was actually hoping that the article would talk about this).
Anti-fingerprinting settings can also heavily reduce timer precision.
In short: timing on the web platform is (currently) an incredible mess.
- taf2 4y agoAdd to that energy saving features that suspend tabs and you can get variable length, setTimeout(() => { console.log('timers'); }, 1); ... ... ... ... timers see: https://developer.chrome.com/blog/timer-throttling-in-chrome-88/ https://developer.chrome.com/blog/timer-throttling-in-chrome...
- pistachiopro 4y agoI believe all the major browser vendors now support the notion of "secure context," where you need to use TLS, <Cross-Origin-Opener-Policy: same-origin, Cross-Origin-Embedder-Policy: require-corp> headers, and maybe a couple more requirements. They say you regain access to high precision timers, as well as SharedArrayBuffers and anything else that got lost during the Spectre/Meltdown mitigations. It appears to work in my limited testing. This secure context makes it harder to support various random ad networks, but if you're deploying your app via the web and don't need to monetize it by ads, it's a way forward.
- flohofwoe 4y agoIt also doesn't work on popular web hosters that don't allow to change the web server configuration (like Github Pages). (there is a workaround however by injecting the required response headers on the client side, but who knows how long that's going to work: http://stefnotch.github.io/web/COOP%20and%20COEP%20Service%20Worker/ http://stefnotch.github.io/web/COOP%20and%20COEP%20Service%2...)