Hello!

  1. Implemented a 2D game and in Edge everything works smoothly and cool, but it hangs in Firefox, they said that you need to do it once or twice and everything was drawn, not in parts, to be honest, I was stumped about this. do here?
    Having specified from the teacher, I learned that memory loads anonymous functions — I brought it into a separate variable without each new creation, but this did not really solve my question.
    Thank.

  2. window.requestAnimationFrame - window.requestAnimationFrame , but when ctx.clearRect works, ctx.clearRect doesn’t remove trails, but when setTimeout is ok, what is the reason?
    this is not important here, everything is taken from the circuit.
    Thank you in advance.

Screen from Sublime

  • Are there any errors in the console? - Jean-Claude
  • @ Jean-Claude, the console is happy with everything, no errors. - recovery
  • The requestAnimationFrame is essentially different from setInterval only by its optimality for rendering, but no more. It turns out that you are doing something wrong and that is why there is a difference between the work of these functions. I do not know how now, but about a year ago I measured myself and in ff js worked two times slower than in chrome. ms has generally been a leader in the top of browsers for a long time, although some people still scold him out of old habit. - user220409
  • And if I correctly understand the code at the very top, then you do not correctly use requestAnimationFrame, it does not need to pass time, and it needs to be executed recursively. And if you use it not as it should and at the same time something else is drawn, then the problem is even more global than you think. - user220409

0