Hi, here a tough one
I’m dealing with an intermittent issue with performwithdelay, it seems that once in a while, it takes more time than expected, and I’m not talking about millisecond, I’m talking about between 2 and 4 second extra delay.
Context: I’m doing a board turn base game, and sometime, before you can play your next move, some events have to happen, Item appear on the board once in a while, enemy spawn, etc.
I put print() statement all over my code so I could try to find where the lag occurred, because I know I could be the cause of this extra delay. I’ve been searching for a long time and now I am out of idea. The problem is that this issue happen intermittent. sometime in the early stage of the game, sometime not, etc.
Here’s an simplified example:
local function someFunction() local delay = 2000 local loot = true print('promptLoot or updateBoard in ' .. delay) if loot then timer.performWithDelay(delay, promptLoot) else timer.performWithDelay(delay, updateBoard) end --[[ more code]]-- end local function updateBoard() print('update board') end local function promptLoot() print('promptLoot') end
The output will be:
12:00:00 \> promptLoot or updateBoard in 2000 12:00:04 \> promptLoot
so where does this extra 2 second come from? I know this isn’t all my code and It’s hard to tell. But what could delay my performwithdelay function so much?
is there anything like: the timer would start late because its a function called within a function called within a function, for example?
could it be that there is a mix between different timers?
could it be that I use too much memory and memory texture that sometime, it cause a delay with performwithdelay?
We are at the last phase of making a great game but it won’t be great if there is a lag with performwithdelay.
if anybody have a hint, please let me know.
Also, what is an acceptable memory usage? is this too much?
> memory = 1327kb and texture 34.6 ?
(i should mention that it lags on the simulator, on an android device and on an iphone6)

