Skip to content

Commit 43a8b38

Browse files
committed
mgba: tentative fix for unlimited fps (#30)
1 parent 284ddf1 commit 43a8b38

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

mgba.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -5543,11 +5543,17 @@ var mGBA = (function () {
55435543
},
55445544
requestAnimationFrame: function (func) {
55455545
if (typeof requestAnimationFrame === "function") {
5546-
requestAnimationFrame(func);
5547-
return;
5546+
var now = Date.now();
5547+
if (Browser.nextRAF === 0) {
5548+
Browser.nextRAF = now + 1e3 / 60;
5549+
} else {
5550+
while (now + 2 >= Browser.nextRAF) {
5551+
Browser.nextRAF += 1e3 / 60;
5552+
}
5553+
}
5554+
var delay = Math.max(Browser.nextRAF - now, 0);
5555+
setTimeout(func, delay);
55485556
}
5549-
var RAF = Browser.fakeRequestAnimationFrame;
5550-
RAF(func);
55515557
},
55525558
safeCallback: function (func) {
55535559
return function () {

pages/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ let stats_data = useFetch(stats_url).data;
3636
</div>
3737
</div>
3838
<div class="col-12 lg:col-3 xl:col-3"></div>
39-
39+
4040
<div class="col-12 lg:col-6 xl:col-4">
4141
<div class="card mb-0">
4242
<div class="flex justify-content-between mb-6">

0 commit comments

Comments
 (0)