Update speed too fast on pc. Vsync is on but it doesn't help (DEF-1785) (SOLVED)

I’m developing a very simple app. At the moment there are a few sprites bouncing on an empty blackground.

In the update function of every object I have:
pos.x = pos.x + self.speedx * dt * 100
pos.y = pos.y + self.speedy * dt * 100

On my Samsung S3 Neo, the game runs more or less 10 times slower, and to get a speed similar to my pc (Windows 10 on a Core2 Duo P8600) I have to use:
pos.x = pos.x + self.speedx * dt * 1000
pos.y = pos.y + self.speedy * dt * 1000

Moreover the same objects at a certain point in the code stop being animated manually and use this animation instead:
go.animate(go.get_id(), “position”, go.PLAYBACK_ONCE_PINGPONG, pos, go.EASING_INOUTCIRC, 1, 0, hai_vinto)
This animation, also, is more or less 10 times slower on my Samsung S3 Neo.

I’m using Defold 1.298 on pc and dmengine.apk 1.298 on mobile.

Can it be the other way around - that your PC is too fast? This can happen is you don’t have vsync set in the graphics driver. See

Thanks Sicher, you’re right, I tried the game on a different pc and the speed is correct (as slow as on my mobile phone).
Unfortunately my notebook is an ancient Lenovo T500 with a Mobile Intel® 4 Series Express graphics card. I’ve updated it to windows 10, but finding working graphics drivers was kind of a hack.
I’ve tried to update graphics drivers with a newer version, but until now, with no luck (they refused to install)
With the current version of the driver I’ve tried to set vsync always on but it doesn’t work.
Any help or suggestion would be appreciated.

1 Like

I checked variable_dt on my game.project and now speed between pc and mobile phone is comparable. Is this a good workaround for my problem with vsync? Since variable_dt is off by default I suppose it would be better to leave it off, what are the possible disavantages or drawbacks of having this on?

Thanks for amazing support.

1 Like

Hey!

The missing feature in Defold is to have software throttling of the update loop, which would make it maintain (more or less) 60 fps although vsync would be off. It should be able to run on setups like yours, but currently it’s not.
Variable dt makes the application follow the real world time closer, despite any speed ups or hick ups, but it also creates an uneven frequency of sampling. This is visually noticable when you deal with things like dynamics (physics and particles). Changing the increment (i.e. dt) gives different trajectories. By using a fixed dt you get closer to determinism and the exact same simulation every time you run it. There are other factors that make the simulations vary, such as different precisions on different target platforms. A variable dt can also cause instabilities for some algorithms in physics simulation, but in my experience it has to vary quite severely for that to be a real problem for the game.

2 Likes

Thanks for the explanation about variable dt. I think that I will use this during development, to have a consistent behaviour on windows, and then uncheck it when building release for android (which is my target platform).

2 Likes

Finally fixed in Defold 1.2.115

5 Likes