From d3754e7a86d0b4b5d7a58d152865bbc72dc0d427 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Thu, 30 Apr 2020 00:52:48 +0200 Subject: [PATCH] piggy-back off requestAnimationFrame --- src/ext/lib/ar-detect/AardGl.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ext/lib/ar-detect/AardGl.js b/src/ext/lib/ar-detect/AardGl.js index 7d55137..8deb0c6 100644 --- a/src/ext/lib/ar-detect/AardGl.js +++ b/src/ext/lib/ar-detect/AardGl.js @@ -308,6 +308,10 @@ class AardGl { // this.conf.resizer.setArLastAr(); } + async nextFrame() { + return new Promise(resolve => window.requestAnimationFrame(resolve)); + } + async main() { if (this._paused) { // unpause if paused @@ -369,7 +373,7 @@ class AardGl { } } - await this.sleep(this.settings.active.arDetect.timers.tickrate); + await this.nextFrame(); } this.logger.log('info', 'debug', `%c[AardGl::main] <@${this.arid}> Main autodetection loop exited. Halted? ${this._halted}`, _ard_console_stop);