Occasional stuttering/lag

Hi Guys, I created my first Project with defold and did the Tutorial. Then I was playing around with some mechanics and grafics. So I created a custom “Hero” and some Gui elements.

The Game runs fluent but sometimes on Windows (even more on Android) there is a noticable lag.

I did a screenshot of the Web profiler as i read in some other Threads and the Frames are pretty red :frowning:

At first I thought it would be too much “message spamming” but there are mostly collision messages so i dont think they are the Problem.

Another hint from you guys was that there could be to big textures the parts of the hero are mostly 300x400 and one is 1150x600 (but much transparent space)

What could be the Problem?

Thank you in advance!

Can’t see the full list in the screenshot, but it looks like 90% of the time it’s just waiting for vsync. Do you have the framerate set to 60 in your game.project file?

Exactly my thought. It takes 1.25ms to render your scene so the slowness is not caused by too my stuff to render. As for messages, in the Counter section you can see that you generate 0 messages on the selected frame and GameObject.dispatchMessages takes 0.05ms.

Here is my game.project file:

[project]
title = Klaus Attack

[bootstrap]
main_collection = /main/main.collectionc

[input]
game_binding = /input/game.input_bindingc

[physics]
scale = 0.02

[script]
shared_state = 1

[display]
update_frequency = 60
variable_dt = 0
samples = 0
width = 1280
height = 800
fullscreen = 0

soo by update_frequency=60 i think its 60fps but that shouldn’t be false.
And you are right its taking 31ms from 36ms for Vsync but isn’t that quite normal?

I now testet
update_frequency=30 -> it runs overall slower but the little lags dont vanish
update_frequency=120 -> no noticable change in anything

Judging from your first screenshot with profiler info it seems like every frame takes around 30 ms, meaning more or less 30 FPS, not 60 fps (ie 16ms per frame). What if you tick “Variable dt” in game.project and try again?

@sicher, do you have any ideas?

I’m having the same problem and its REALLY annoying.

Have you also tried the webprofiler to try to gain some insights?
What platform are you on?

2 Likes

I’m still very new to Defold and this is happening on every project I run, it’s like every second the game “hangs” for 5 frames.

What platform are you running on? What hardware (cpu/gpu)? Are drivers up-to-date?

To have any reasonable chance to fix this issue we need more information about your setup.

3 Likes

Oh sorry :slight_smile:
I’m on a 64bit windows 10 system with a MSI gtx 980

Update:
My main moniter is running 144hz and apparently the game runs faster on that moniter which is very weird.

3 Likes

@Lord_Squirrel Are you creating a lot of tables/functions in your update() functions? Lag like that can sometimes be caused by the garbage collector kicking in if you allocate too many items too fast.

3 Likes

Yes, good tip! Lua table creation is costly.