Why do I always get a laggy movement in Windows?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By BeLuckyDaf
:warning: Old Version Published before Godot 3 was released.

Hello,

So, I am using

set_pos(Vector2(get_pos().x + 100 * delta, get_pos().y))

So it must move very smoothly, and it does in Linux and probably Mac.
But in windows I always get a laggy movement, a freezy one. If I described correctly.
And it’s about all Godot games.

Recorded a video on a motion test demo.

Where did you put this? Also, which kind of computer are you running Windows on?

Zylann | 2016-10-12 00:13

Oh I’ve got pretty much good computer, enough to play GTA V in 60fps. It does not freeze constantly, but occasionally, like every 1-2 seconds I get 0.25 second freeze

BeLuckyDaf | 2016-10-12 02:04

Is it a laptop? If so, make sure you run Godot with the dedicated graphic card.
If not, I’m not sure what’s going on. Is your Linux machine the same as your Windows machine? (dual-boot)

Zylann | 2016-10-12 13:08

No it’s a PC with no dedicated graphics card, and these lags only appear in godot games. I had the same problem with unity but then the problem was the unity editor, when I launched exported unity games it worked smooth. But since godot does not export games by compiling them I can’t solve it this way again…
Just to clarify, the game runs in max fps but lags appear every 1-2 seconds

BeLuckyDaf | 2016-10-12 14:19

I don’t know if I can call them lags, because it’s possible to play and a regular user might not even notice them but for me they are obvious.

BeLuckyDaf | 2016-10-12 14:22

Can you capture this lag in a video? I get lag too in my game but it’s not really periodic and depends on what is on screen. I get a regular lag on Android but it’s not that bad (it’s actually frame dropping). I also get another form of lag making the screen extremely shaky but it only happens 5% of the time on launch (probably a different issue).

Zylann | 2016-10-12 17:33

Could be the graphics card, some Windows drivers seem to have problems with OpenGL, are official drivers or those that comes with the OS?

eons | 2016-10-12 21:51

I always install the latest Nvidia drivers.

BeLuckyDaf | 2016-10-13 01:54

Happens with the Motion Test demo too?

Can you provide more code? isolated lines don’t say much

eons | 2016-10-13 18:37

Happens even if this is the only code in the project, except for set_process(true) in _ready.

BeLuckyDaf | 2016-10-13 18:57

As requested, captured on a video. You can see all the lags on that video.

BeLuckyDaf | 2016-10-14 13:45

It says the video doesn’t exists.

Zylann | 2016-10-14 20:07

Oops, sorry. Fixed, try again

BeLuckyDaf | 2016-10-15 11:59

Hmm yeah, this is minor frame dropping. I have the same thing on my game on Windows. It runs smoothly most of the time but if you pay attention frames get dropped pretty often, at random frequencies. I found that removing full-screen images such as backgrounds improves the situation a little, but that’s ridiculous given the amount of drawn stuff involved…

I tried to launch a Java game I made 4 years ago with a now obsolete library (Slick2D), and although the game has 3 layers of fullscreen sprites + polygon-based level walls, props, enemies, particles and projectiles with dynamic collisions, it doesn’t drops ANY frame and runs at a solid 60 fps (Could be caused by the fact the library implemented an interesting frame smooth algorithm? Even turned off it runs very well)

On the other hand, Godot drops frames too easily… when I profile my game I just see spikes on the total frame time that exceed the 60 fps barrier randomly. I thought it was my scripts doing too much unoptimized stuff (which I know i do) but they barely reach more than 3% of the frame time, at most, according to the profiler, in debug mode (yeah I also tried on built game, better but still frame drops).

So yeah… no idea what’s going on :confused:

EDIT: I remember I had such issues with SFML, trying to get my own frame smooth done right. But I found something that seemed to work well, and it turns out to also work in Godot:
Disable vsync, set target FPS to 60. If you still have frame drop, increase to 120.
Yeah, that sounds stupid, but it solves the problem for me O.O
Well that’s on PC, Android would be worth trying.

Zylann | 2016-10-15 12:04

thanks for your replies, but there are frame drops anyway. Not that much, but after some time they appear again…

BeLuckyDaf | 2016-10-15 13:56

Is an old bug that affect old and some new GPUs too on Windows, maybe related to OpenGL support, I don’t think there will be a fix in the 2.x.

Driver-related jitter in motion test · Issue #2043 · godotengine/godot · GitHub

ps: I don’t know if anyone tested with a c++ module for the movement, an acceptable solution for optimization (if works, of course)

eons | 2016-10-15 15:50

This is, actually, the only reason why Godot is not my primary engine yet

BeLuckyDaf | 2016-10-15 18:58