News for hackers. Stuff that matters.
Re:A tale of two clocks – Scheduling Web Audio with precision by flohofwoe on Sunday July 03, 2022 @05:51AM (#31966445)
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.

Re:A tale of two clocks – Scheduling Web Audio with precision by pistachiopro on Sunday July 03, 2022 @11:39AM (#31968505)
I 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.

Re:A tale of two clocks – Scheduling Web Audio with precision by flohofwoe on Sunday July 03, 2022 @01:03PM (#31969163)
It 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%2...)

Re:A tale of two clocks – Scheduling Web Audio with precision by taf2 on Sunday July 03, 2022 @09:02AM (#31967394)
Add 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...