You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A comment from a puzzlescript dev that I just stumbled across on discord:
It's weird that in firefox it's like 3x times slower, hard to nail the gamefeel for all browsers alike. Sorry to those who played on Chrome!
Apparently key_repeat_interval acts differently across browsers? So I made a test file: key_repeat_interval.txt. I set up a situation with key_repeat_interval that should have taken 10 seconds, and manually timed it (with my phone's stopwatch) in each browser. In firefox it took 10.03 seconds, but in chrome it took 13.21 seconds. that's much much slower than it should be!
(I observed similar results for realtime_interval.txt -- 10.00 seconds in firefox versus 14.17 seconds in chrome. I did not test again_interval but I would guess it has similar issues)
I suspect this happens because puzzlescript uses setTimeout(loop,17) to draw frames; as far as I know requestAnimationFrame is the "correct" way to run a HTML canvas game's mainloop. I don't know where I first heard that but I did a bit of searching and found some web resources that seem to agree:
this tutorial talks a little bit about why you would want requestAnimationFrame instead of setInterval
MainLoop.js, a game loop library that looks well-thought-out, and uses requestAnimationFrame
The text was updated successfully, but these errors were encountered:
this timing discrepancy seems like strong enough motivation to revive #924 / #925, so I did that: #948 is the new PR. I tested #948 locally and the discrepancy was fixed:
## results from key_repeat_interval.pz, after #948
firefox: 10.16 seconds
chrome: 10.13 seconds (yay)
## results from realtime_interval.pz, after #948
firefox: 10.13 seconds
chrome: 10.08 seconds (yay)
sorry to spread this conversation across 4 different places! I'll leave this thread here, focused on the bug, and I'll talk about requestAnimationFrame more as a reply to #925
A comment from a puzzlescript dev that I just stumbled across on discord:
Apparently
key_repeat_interval
acts differently across browsers? So I made a test file: key_repeat_interval.txt. I set up a situation withkey_repeat_interval
that should have taken 10 seconds, and manually timed it (with my phone's stopwatch) in each browser. In firefox it took 10.03 seconds, but in chrome it took 13.21 seconds. that's much much slower than it should be!(I observed similar results for realtime_interval.txt -- 10.00 seconds in firefox versus 14.17 seconds in chrome. I did not test
again_interval
but I would guess it has similar issues)I suspect this happens because puzzlescript uses
setTimeout(loop,17)
to draw frames; as far as I knowrequestAnimationFrame
is the "correct" way to run a HTML canvas game's mainloop. I don't know where I first heard that but I did a bit of searching and found some web resources that seem to agree:requestAnimationFrame
instead ofsetInterval
requestAnimationFrame
The text was updated successfully, but these errors were encountered: