Game freezes when goes in background

Options
Hi,

I know this might be simple to fix but, my game freezes whenever it goes in background and comes back (Standalone, Android, iOS). I have also set Application.runInBackground as true. In photon connection state it shows PeerCreated. So is it something that I'm missing in photon settings.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Application.runInBackground does not work for Android and iOS. If you target mobile platform, you should manually disconnect before going background and reconnect when foreground again.

    But since the problem occurs with Standalons build also, I guess you have another issue.
  • vadim
    Options
    Hi,

    How do you know that it freezes and why do you think that photon is the reason?
    On some platforms execution may be paused in background but should be resumed after app comes to front.
    Can you debug the application?
  • RSEve
    Options
    I think that I am also having a similar issue and it seems really consistent. I also have the Application.runInBackground set true and I'm running on PC only.

    I'm running two clients locally. 50% of the time, everything is fine. 25% one client will stop updating when it doesn't have focus. The other 25%, it's both.

    When I have a debugger attached, the break point will not be hit until I focus the application. At that point, all the network traffic that happened in the meanwhile will be processed.

    It does seem really odd that it would be Photon freezing things because I wouldn't think you have that level of access. :) I started using Photon around the same time I started using 5.1 so I'm looking everywhere. I never noticed this using Unity network (old style).
  • Tobias
    Options
    PhotonNetwork sets Application.runInBackground = true;
    If that doesn't help, can you verify that other systems of your app run in the background? Does the physics engine continue to move things, e.g.?

    Photon does not work well with debuggers, because those stop all threads and the connection will time out while you look at values in memory. Otherwise, it should not stop the game from anything.