Sign in to follow this  
AgentC

Client/server multiplayer and app on background

Recommended Posts

AgentC    2352
Generally, an Android / iOS app should do as little processing as possible when minimized to the background. And on iOS it's explicitly forbidded from doing any GPU calls during that time. However, to stay in sync properly in a client/server multiplayer game, the app (client) should still receive and execute any commands sent by the server.

How do you / how would you handle this?

I guess the most problematic thing is if the server changed the whole level or map while the client is on the background, which means the client would have to load a CPU-only representation of the map, and only after being maximized would be able to actually load the map's models / textures to the GPU. Spawning a new game object is the same problem, but in lesser scale.

Easier, but uglier method would be to buffer all network packets until maximized again, but this could lead to huge memory use.

Share this post


Link to post
Share on other sites
Mussi    4407
I'd just buffer the requests to load to the GPU when it's not available and then execute them when it is. IIRC there's no guarantee your service will stay in memory, so you'll have to make sure you can restore your program's state using the storage device and some callback function.

Share this post


Link to post
Share on other sites
TechnoGoth    2937
I would say you wouldn't keep the client in synch while it inactive. You might have have a separate alerting component depending on the game that relies on polls every 5 minutes or hourly. But the generally I would have the client app resynch with the server when it is resumed or restarted. You shouldn't have it do anything when it isn't the active application.

I would say any app the needed constant server connectivity and had to run processor intensive activities when it is running in the background is poorly designed and likely to be uninstalled quickly once users find out it is killing their battery life.

Share this post


Link to post
Share on other sites
frob    44908
These are basic engine design issues.

Your engine computing logic should be completely separate from rendering. Not being active, and therefore not rendering, should be a non-issue for a game designed like that. If your engine cannot do separate the simulation from rendering, you'll need to overhaul your engine to make it so.

Networking similarly should be completely separate. If you are not active you should stop sending messages. If or when then player resumes the app you should be able to request the state back from the network. If your game engine does not handle shutting down networking like that, you'll need to overhaul your engine to make it do so.

Of course, your simulator and other processing should also be paused, so you'll have no need either to render or to communicate. If your engine doesn't pause, effectively either saving what can be saved and discarding the rest, then your game design is flawed for the mobile space. Your engine will need to be redesigned with mobile devices in mind. Edited by frob

Share this post


Link to post
Share on other sites
AgentC    2352
Thanks for the answers!

Regarding logic-rendering separation, it's quite easy is to simply skip rendering when not appropriate. It's also easy to ensure that for example a headless server can do collision detection properly even when the geometry data only resides on the CPU and not on the GPU. However it can be tedious to design an engine's graphics resources so that they're safe to call at whatever time, and that the changes made during an "unsafe" period are properly reflected back to the GPU once it is available again.

But yes, indeed it's best to request a full update when returning to the app and not care at all of what happens in the meanwhile.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this