2
\$\begingroup\$

I set Frame Per Second of 60 for my game. But after 1 minute it gets to a significantly lower value - around 8 FPS.

Does pausing the canvas drawing restores the FPS to higher value? If it does, how much time is enough to pause the game in order to get 60 FPS again?

\$\endgroup\$
3
  • \$\begingroup\$ Usually, 30 FPS is optimal \$\endgroup\$ Mar 11, 2016 at 0:53
  • \$\begingroup\$ What makes you believe pausing would increase the framerate? \$\endgroup\$
    – Peethor
    Mar 11, 2016 at 6:07
  • \$\begingroup\$ the logic behind the question is: if you stop all the drawing on the canvas then it will ease on the game in order to make it smoother next time you resume it..but thats why i asked because i was not sure about my idea. \$\endgroup\$ Mar 11, 2016 at 22:01

2 Answers 2

1
\$\begingroup\$

I don't think you have the proper approach to your issue.

Typically, if a game starts to go slower and slower, it's because you add stuff to it over time and it's not able to process everything in a timely fashion. If there is too much stuff from the beginning, the frame rate will be low but constant from the beginning.

Even if "pausing" a game to "let the frame rate catch up" or to "restore the FPS" seems to work to solve your current issue, it will not fix the underlying problem. It is not a good solution and your players will really not like that.

I suggest you use a JavaScript profiler (I did not test this one myself, but it could be useful to you) to inspect the behaviour of your code, and from there determine what's causing the issue.

\$\endgroup\$
5
  • \$\begingroup\$ I think you are trying to say that the work being done by the game is increasing over time. Probably by new objects being spawned or the game not finishing async tasks in time. The profiler is not a solution in itself but a means to determine the origin of the problems. I couldnt quite make that out on the first read, but could be me. Also you might explain how pausing should only ever decrease the framerate and not increase it, unless rendering is causing starvation somewhere else in the application. \$\endgroup\$
    – Niels
    Mar 11, 2016 at 15:18
  • \$\begingroup\$ @Niels Yes, this is what I'm trying to say ;) If you can find a better wording, you're more than welcome to suggest an edit :) \$\endgroup\$
    – Vaillancourt
    Mar 11, 2016 at 15:19
  • \$\begingroup\$ re-reading your post i think it might be as simple as adding a paragraph after your first sentence, drawing more attention to it. \$\endgroup\$
    – Niels
    Mar 11, 2016 at 15:24
  • \$\begingroup\$ after analyzing it on on the profiler I think the major cause of this is because the script is too 'heavy' to process(the main loop has about 21000 code lines which consists 298 'for' loops,and too many calculations) \$\endgroup\$ Mar 11, 2016 at 22:10
  • \$\begingroup\$ @user3785971 It looks like you're on the right path to find your issue :) \$\endgroup\$
    – Vaillancourt
    Mar 11, 2016 at 22:16
0
\$\begingroup\$

It does restore(very slowly) the FPS but it wasn't the correct approach to my problem. The correct approach is to use webgl in order to utilize GPU.

\$\endgroup\$
1
  • \$\begingroup\$ Oh wow! Thanks for coming back here to post an answer after so long! If this answer is actually the one that solves your issue (instead of mine), feel free to unaccept mine and accept yours instead :) \$\endgroup\$
    – Vaillancourt
    Jun 9, 2018 at 23:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .