- Home /
Coroutines stop when another game goes fullscreen
Hello, I have built a quite complex application using unity, its not a game, but a full blown application that needs the 3D features of unity.
One of the features is sending messages to a gameserver of another game.
When I am on windows (any app) or looking at the unity itself, everything runs smoothly, however, if I tab into the game (that runs fullscreen), it stops sending messages after about 1 or 2 seconds.
What could cause this? I have "run in background" setting activated.
Answer by ThePunisher · Feb 09, 2013 at 10:48 PM
What do you mean it stops sending messages? What kind? Does it start sending messages again if you tab back to the application? Where/When do you send these messages?
My suggestion would be that you try sending your messages in an Update loop instead of a coroutine. Not sure why you made it a coroutine. If it's some sort of heartbeat or information update that happens from the start of the application to the end then it's worth putting it on an Update loop.
$$anonymous$$y problem is that it acts like if the "run in background" option is disabled, but it isnt.
You're not giving me enough information at all... You need to answer some of the questions I asked you for me to be able to help.
I am sending messages to a gameserver via sockets. I am also displaying them on screen inside unity. I have it sending framecounts so I know if unity is running. It will send for example a message saying 400 framecounts, and then i go ingame (other game in fullscreen), it stops sending, i stay 30 $$anonymous$$utes in the other game and exit out, and unity resumes from the 400th frame, meaning, it stopped completely.
This happens in coroutines aswell as Update(), I have "run in background" set to true in both code and project settings.
Its made in coroutines because of the easier wait for seconds, but I have also tried in Update() with delays using Time.time - lastUpdate > timeout for example.
The D3Device is lost when you $$anonymous$$imize the unity window to go to something else, meaning it's not rendering. If you have some sort of logic based on that it would explain why you stop getting the updates.
Go take a look at your Unity log (output_log) under your GameExeName_data folder and you will be able to see nothing but a repeated message saying "D3Device was lost, trying to recover", etc. Hope that helps.
Would that explain why coroutines also stop running?