diff --git a/mgba.js b/mgba.js index b28b99291f..4ae96f2bc1 100644 --- a/mgba.js +++ b/mgba.js @@ -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 () {