Separate UI from simulation

Separate UI from simulation

Requests for features in the spring code.

Moderator: Moderators

Post Reply
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Separate UI from simulation

Post by Jools »

Currently, if something happens that causes lag, the whole spring interface will become unresponsive, and the only way to deal with the situation is to kill the process in task manager.

Would it be somehow possible to separate the UI into an own thread, so that in such event the user can still control the interface, menues, pause, gamespeed etc, even when the simulation itself it lagged badly.

I tried to search for similar threads, apologies if this has already been suggested.
SirMaverick
Posts: 834
Joined: 19 May 2009, 21:10

Re: Separate UI from simulation

Post by SirMaverick »

Jools wrote:Would it be somehow possible to separate the UI into an own thread, so that in such event the user can still control the interface, menues, pause, gamespeed etc, even when the simulation itself it lagged badly.
Generally yes.
Afaik: Spring MT has own threads for GUI, but uses locks to access the simulation state. That means if the simulation lags bad it has to wait for the lock. You can prevent that by duplicating/caching the simulation state. Happy coding!
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Separate UI from simulation

Post by hoijui »

yeah, as knorke said, spring-multithreaded is pretty much that.

if you want more... wait a decade or two, and we'll be there, maybe. ;-)
it has been discussed in multiple dev meetings. it is a lot of work, and introduces new, very hard to debug possible problems.
threaded simulation + desync -> :*(
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Separate UI from simulation

Post by Tobi »

No, threads have absolutely nothing to do with this.

The solution is to do client side `prediction' of the UI.

So a unit would get a sim order queue, which is what it actually uses, but it would also have a client-side order queue, which is what is visible on the screen.

When the user gives a new order, the client-side order queue is updated immediately so that the user has immediate feedback, while the sim order queue has to wait for a roundtrip to the server before it gets to see the new order.

Same thing applies to menus / pause / gamespeed etc.: it needs client side `prediction' of the state the UI element will probably get after the roundtrip to the server.

To retroactively fit this into Spring is a lot of work, as nothing has been designed with this in mind.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Separate UI from simulation

Post by jK »

@Tobi
I assume he suffers more of local cpu lag (FPS) and not network lag.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Separate UI from simulation

Post by Jools »

Yes, I certainly suffer mostly from CPU lag.

This happens for example when I'm joining a game mid-game and the simulation needs to catch up, but then there's something else on my computer that needs attention (like skype call etc...): in those cases it would be nice to be able to pause spring even though it's busy.

I also get CPU-lag when I experiment with my forest fires gadget, but that's my own fault for making the near-infinite loops :)
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Separate UI from simulation

Post by Tobi »

Hmm, ok.

Then for sim UI things (giving orders, changing firestate/movestate, etc.) both (threading + prediction) would actually be needed, and for non-sim UI things the threading might be sufficient.
Post Reply

Return to “Feature Requests”