Platforms are lagging time to time

Hey,
would some experienced person help me understand why objects that are being moved have a slightly lag?
They were lagging every 4-6sec with collider attached now without it its more like 10-15sec.
I can add to the project if some one want to check the code.

Hm, this seems like the same issue @Rafael_Vasco came across, and from your screenshot it looks as if you’re running Windows just like Rafael. Could you please add @sven (sven.andersson@king.com) and perhaps also me (bjorn.ritzl@king.com)?

I tested it on few phones, tablet and laptop. Got this everywhere.

Oh, so it’s not only on Windows? Well, add one or two of us and let us know and we’ll take a look.

A possible cause of platform-independent repeating lags is that the lua GC has too much to do. That depends completely on how many lua objects you create each frame. Please note that this is different from creating game objects in Defold through spawning. What I mean with lua objects is any data type in lua which is dynamically allocated, e.g. a table:

local t = {}

The nature of these types of lags is that the interval should be more or less constant over different platforms, but the length of the lag itself should be related to the strength of the CPU.

You could investigate using the available lua gc functions to see if it is in fact a GC hitch. Maybe @britzl or @Andreas_Jirenius has any tips on doing this.

Google: lua gc

Looking more closely, it seems unlikely to be GC considering how many scripts you have active. Check your scripts for any loops which creates objects for every iteration just in case. If your scripts has no loops, they should not be able to produce so many lua objects that the gc would stall the game. But you never know… :wink:

If you want to inspect the amount of memory Lua is using you can utilise the functionality of the collectgarbage function.

I’d also look into dynamic Lua table creation just as Ragnar is suggesting. It’s likely that you’ll find the problem there. Or perhaps you’re doing a lot of string manipulation?

I’ve added both email to the project, I have few scripts, globals(module) that store 2 tables and they are used time to time when I spawn new object. First table stores names of chunks(platforms/collections) that are randomly chosen second store 3chunks(platforms/collections) that are currently on screen.
Next one is for collection proxy management and one is for level management (its using both table in init when the collection proxy switch from menu to level) last one moves the platforms and check when they should be deleted.

So I basically create 3 chunks when level is loaded and than I check if the platform is off screen enough to delete it and spawn new chunk.

Hmm, I don’t see anything obviously wrong with the code. No tight loops with lots of table creations or anything like that. I’m not able to reproduce the issue on my Mac though. Did you see the problem on Windows as well as on device?

I see this on windows 8.1 and android. If you focus on platforms you should see little shakes every 4-8sec.

If you change the game_speed variable to 150-250 (in globals.lua) you can see it more clearly.

Ok, so I’ve managed to reproduce the issue. It seems to be related to the profiler. For me the hitches go away if I have the webprofiler running in a browser window. As soon as I close the webprofiler window the game starts to hitch again. It’s probably only an issue in debug builds. I’ll talk to the rest of the team tomorrow when we’re all back in the office again.

@britzl I think its not related only for debug because I have this build up on google play with release toggled and its hitching on any android device.

Hmm, yes, I could be wrong. Anyway, if I print the dt in player.script it get a high dt (around 0.1 instead of 0.016) when it hitches. I’ll look into it a bit more tomorrow.

1 Like

Weird, and today when I tested the game I’m no longer getting any dt spikes and no hitches…

@britzl if you have android phone I can add you to alpha testers and share a link to download the game from google play you will see the hitching clearly there.

I’ve tested the release build on all devices listed bellow and all of them experience hitching issue.

  • BlackBerry Passport
  • Pentagram Quadra 7
  • Samsung Galaxy S5
  • Samsung Galaxy Note4
  • Meizu MX4