From fccf5e35c47f993fdec629c6458ffc5138dcf76f Mon Sep 17 00:00:00 2001 From: Troy Crosley Date: Wed, 14 Dec 2022 10:23:26 -0500 Subject: [PATCH] gl.js: use performance timer Use performance.now instead of Date.now, which may provide a higher-resolution time (depending on the browser's Spectre mitigation settings). Add performance.timeOrigin so that the returned value is still relative to the Unix epoch. --- js/gl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/gl.js b/js/gl.js index cf2a972f..0431802b 100644 --- a/js/gl.js +++ b/js/gl.js @@ -615,7 +615,7 @@ var importObject = { return Math.floor(Math.random() * 2147483647); }, now: function () { - return Date.now() / 1000.0; + return (performance.timeOrigin + performance.now()) / 1000.0 }, canvas_width: function () { return Math.floor(canvas.width);