I’m working on a game with JavaScript using Electron.js. I’m using the HTML <canvas>
element with 2d
context as renderer. At some point, I’ve noticed that the game runs quite slow (less than 30 FPS).
Every frame, a piece of code is run by requestAnimationFrame()
. I ran it through a profiler and it showed that my code is fine (takes around 2ms per frame) and that page repaints take much longer than I would expect (sometimes it’s more than 30ms per paint).
Why is this happening? Is it normal? And what can I do to lower the paint times?