Jump to content

How to keep game running when browser is minimized/out of focus?


eggborne
 Share

Recommended Posts

I have asked around about this and haven't had much success; it was suggested that the framework I'm using has its own version of this functionality. So here I am!
 
I know it's best for most games to automatically pause when focus is lost, but I'm working on a cellular automata and I want it to continue running at all times. Is this possible?

Link to comment
Share on other sites

So you're saying the simulation would still be frozen when not in focus, but would "catch up" on all its operations when the user brought the window back into focus? Wouldn't there be a point where so many update() calls (i.e. many hours' worth) would hang the browser?

Link to comment
Share on other sites

I assumed you meant the browser limiting calls to setInterval or requestAnimationFrame when it's not focused, which is what at least most desktop browsers do. In that case the simulation would update less frequently but would do bigger chunks at once to keep up.

 

If the program stops completely when you lose focus it's probably your browser or some non-pixi framework. Check if there's any listeners for "blur" events. (On chrome F12 > Elements > event listeners)

Link to comment
Share on other sites

Thanks for the replies, guys. I seem to constantly come here with non-Pixi problems.
 
Upon further inspection it seems that the game runs very slowly when the browser is blurred (I am using setTimeout), a tiny fraction of the normal speed -- it took about a minute to update 50 times, when it normally would have updated 3600 or so in that span.
 
Do you know of any way to control this?

Link to comment
Share on other sites

Thanks for the replies, guys. I seem to constantly come here with non-Pixi problems.

 

Upon further inspection it seems that the game runs very slowly when the browser is blurred (I am using setTimeout), a tiny fraction of the normal speed -- it took about a minute to update 50 times, when it normally would have updated 3600 or so in that span.

 

Do you know of any way to control this?

 

Nope, this is by design. You will have to compensate.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...