This is my fourth question in a few days but I get really frustrated with this
The problem is simple to describe: The flyCam is lagging around. I found some topics about that but in everyone the problem was that the performance was too bad. I have high enough FPS (between 80 and 120) and the cam is still lagging most times. Sometimes (even at lower FPS) it moves smoothly⌠And just when I am happy that it is finally working it begins to lag again. I checked background processes that my cause performance problems but found nothing heavy. Do you have any suggestions what I can do to solve this problem or at least to find out where it comes from?
Its hard to describe, I think I make a video to show what I mean. Wait some minutes pleaseâŚ
EDIT:
Okay⌠The video plan didnât work. The framerates drop down to 7 when I try to record what makes it not really usable for explanations⌠I try to describe it:
The game itself is running smoothly (around 100 FPS). Animations look nice and I can turn the camera in all directions without any problems. But whenever I try to move it, it moves normally for a short step, then it jumps a bit, then it moves normally again⌠Like it would look like with low fps but the application still displays me high fps and when I stop the camera everything works fine (itâs hard to watch the animations with the camera moving so I canât say how it is then). They problem occurs at every camera speed (I tried from 1f to 10f) and more often when I move along the X or Z axis. When I move in an angle in between it runs better (still not perfect though).
Could be like lag spikes due to garbage collection. Did you try to profile your app? You could monitor the memory and see if the lag spikes match with a garbage collection
It does not happen in other apps, also not in an app which bases on the same game but does not have any network operations (I have a local server and a local client, could that be the reason)?
How does the profiling thing work? (Sorry for the noob question)
Yeah, the fact that networking is required before the problem happens is a pretty good indicator that networking is the issue. For the future, you might choose to include important information like this in the beginning so that you can get help faster.
Yes, sorry I did not think about that earlier⌠I am using spiderMonkey. One thing I should add is that also in the âworkingâ mode I have a server but no clients connected to it. In the problematic version there is a client connected to the server but the server is not sending any messages. Does the connection itself has such a great impact on the performance? I could try how it works without the connection but then I have to write a way to construct the world (which is sent to the client), what takes some timeâŚ
@Smire said:
Yes, sorry I did not think about that earlier... I am using spiderMonkey. One thing I should add is that also in the "working" mode I have a server but no clients connected to it. In the problematic version there is a client connected to the server but the server is not sending any messages. Does the connection itself has such a great impact on the performance? I could try how it works without the connection but then I have to write a way to construct the world (which is sent to the client), what takes some time...
A connection not doing anything should not cause an issue⌠and indeed Iâve run SpiderMonkey many many many many times without the issues you describe.
So it must be something in the way your code is working then there is a connection in place (we canât really see it so itâs hard to say). Even GC shouldnât be an issue if nothing is sending any messages. Are you sending messages to the server every frame or something? (Note: that is not a good approach)
connection itself should create one lag while creating connection, but not periodical lags. maybe you are doing some unattended blocking operations. when lag happens, do fps drop? and when you insanely clicking with mouse, do whole window stops responding for that lag time ?
The server is sending some messages every five seconds, the lags appear about two or three times a second so that should not be the problem. The client is not doing anything with the messages it receives though (I disabled it to check if this was the problem). The client is not sending messages at all (except at the beginning).
The FPS are constant and clicking around does not have any effect.
Please tell me if you need any code, I just do not know what you could need. I know it canât be the update function. It is only calling for super and doing some update stuff every ten calls, but the lags still happen when I raise this to every 1000 calls (so the problem canât be there).
Have you treid a profiler? like visualvm, it can show you where time is spend, if using it correctly it will probably show a method that has a very high selftime/invocation count ratio.
The tip with the profiler helped me very much, thank you for that
Actually I found the reason: I had a second Thread running that controlled the server time and organized the server actions. This used 77 % of the performance (due to the profiler). Now I just let that Thread sleep a bit longer and the game runs much faster. Since it still uses 68 % of the performance I think I have to work some more on this⌠I still do not get why the FPS were that high anyway and why the other (clientless) version was running better but now both work.