[PATCH uxn5 v2] fix uxn screen evaluating too fast on high refresh rate devices
Export this patch
---
src/app.js | 11 ++++++++ ---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/app.js b/src/app.js
index 216bff7..a1b06b4 100644
--- a/src/app.js
+++ b/src/app.js
@@ -15,6 +15,8 @@ const emulator = new Emu()
const share = new ShareView(document.getElementById("share"));
+ const target_fps = 60;
+
emulator.init().then(() => {
emulator.console.write_el = document.getElementById("console_std")
emulator.console.error_el = document.getElementById("console_err")
@@ -43,11 +45,14 @@ emulator.init().then(() => {
// Animation callback
function step() {
emulator.screen_callback();
- window.requestAnimationFrame(step)
}
- emulator.screen.set_size(512, 320)
- window.requestAnimationFrame(step);
+ emulator.screen.set_size(512, 320);
+
+ setInterval(() => {
+ window.requestAnimationFrame(step);
+ }, 1000 / target_fps);
+
if (!isEmbed) {
// Support dropping files
--
2.42.0
uxn5/patches/.build.yml: FAILED in 17s
[fix uxn screen evaluating too fast on high refresh rate devices][0] v2 from [Nojus Raskevicius][1]
[0]: https://lists.sr.ht/~rabbits/public-inbox/patches/48663
[1]: mailto:nojusr@gmail.com
✗ #1132851 FAILED uxn5/patches/.build.yml https://builds.sr.ht/~rabbits/job/1132851