Skip to content

Commit

Permalink
mgba: tentative fix for unlimited fps (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
avivace committed Dec 10, 2024
1 parent 284ddf1 commit 362ec8b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions mgba.js
Original file line number Diff line number Diff line change
Expand Up @@ -5542,12 +5542,18 @@ var mGBA = (function () {
setTimeout(func, delay);
},
requestAnimationFrame: function (func) {
if (typeof requestAnimationFrame === "function") {
requestAnimationFrame(func);
return;
if (typeof requestAnimationFrame === "function") {
var now = Date.now();
if (Browser.nextRAF === 0) {
Browser.nextRAF = now + 1e3 / 60;
} else {
while (now + 2 >= Browser.nextRAF) {
Browser.nextRAF += 1e3 / 60;
}
}
var delay = Math.max(Browser.nextRAF - now, 0);
setTimeout(func, delay);
}
var RAF = Browser.fakeRequestAnimationFrame;
RAF(func);
},
safeCallback: function (func) {
return function () {
Expand Down

0 comments on commit 362ec8b

Please sign in to comment.