3 ms·
> They made it difficult to get a good timing source in JS, so there’s that. No, they didn't. A while loop with a counter is a good timing source, and you can'
by roblabla 7y ago
> They made it difficult to get a good timing source in JS, so there’s that.
No, they didn't. A while loop with a counter is a good timing source, and you can't really prevent that without severely crippling everything's performance. Want a good timing source in your browser? Just follow those three easy steps:
1. Start a while loop in a webworker
2. In that while loop, incrementing a counter in a SharedArrayBuffer
3. In the main javascript, read that number from the SharedArrayBuffer.
Bam, a decent clock.
- deleted 7y ago[deleted]
- Filligree 7y agoDidn't they disable SharedArraybuffer for that reason?
- striking 7y agoYes and no? > Note that SharedArrayBuffer was disabled by default in all major browsers on 5 January, 2018 in response to Spectre. Chrome [re-enabled it in v67](https://bugs.chromium.org/p/chromium/issues/detail?id=821270 https://bugs.chromium.org/p/chromium/issues/detail?id=821270) on platforms where its site-isolation feature is enabled to protect against Spectre-style vulnerabilities. from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...