Game loop randomly slowing down for one iteration ?

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
macnomad2
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 63
Joined: Sat Oct 28, 2006 10:04 pm

Game loop randomly slowing down for one iteration ?

Post by macnomad2 » Tue Mar 11, 2014 5:25 pm

Hello
I am using the game loop from game academy for "yet an other game" on iOS
http://forums.runrev.com/viewtopic.php? ... 037#p79876

Works well except for random performance issue.
While my game runs I have usually a 60 milliseconds duration for one loop (not a fast action game, but still, and I don't need less)
When the game runs on an actual device, sometimes, randomly, this goes to 200 milliseconds and then comes back to normal, at the next iteration.
This can be seen on the screen because sprites are slowing down abnormally then going to normal again.
It is independent of any action from the player and happens even if nothing is touched.

Where can it come from and how to prevent it ?

Is it background processing on the iPhone/iPad that I can't control (from iOS or some sort of garbage collection) ?
It seems for example that it happens more often if I have wifi on (my game does not use it).
It seems also to be more frequent with iOS 7.
Of course I can't and I don't want to control the user's environment.

Any ideas ?
Thanks

splash21
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 369
Joined: Sun Dec 19, 2010 1:10 am
Location: UK
Contact:

Re: Game loop randomly slowing down for one iteration ?

Post by splash21 » Tue Mar 11, 2014 10:40 pm

Hi, macnomad2. Does the game loop always perform the exact same tasks on every iteration? If there's any code you can post, maybe someone will spot something..
LiveCode Development & Training : http://splash21.com

macnomad2
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 63
Joined: Sat Oct 28, 2006 10:04 pm

Re: Game loop randomly slowing down for one iteration ?

Post by macnomad2 » Tue Mar 11, 2014 11:12 pm

Thanks, I will post some code, but yes, globally a sprite simply moves at each iteration and calculations are the same.
I measured the random delays but could not find any internal reason.
It really seems that the delays come because iOS or the engine is doing something else in the background sometimes, depending on whats going on.
For example, once my phone rang while I was playing and the game started to go slow just before.
Can I see the « system messages » on iOS, so I could pause the game just in time ? It seems it happens before LC sends a message like suspend.
I wonder if it happens to other people.

Post Reply

Return to “Games”