Why the game keeps freezing?

Guzzz

  • *
  • Posts: 496
 It's not very often but my game sometimes freezes without any visible reason. I'm totally sure that no calculation is happening or anything difficult. FPS never drops lower than 40 and usually stays around 50-55. Why is it freezing?  I've solved all the crashes in my game and now I'm trying to figure out why is it freezing.

p.s. To be honest apart from my own game I very rare see freezing app or game on my iPhone, but google search showed me that people often complain about freezing games and apps. Is it really that often?

« Last Edit: September 17, 2019, 02:47:03 pm by Guzzz »
Watch my new game http://www.hitandcrash.com based on my comic strip https://www.instagram.com/hitandcrash

HeadlessD is my dungeon-crawling game on iOs and Android. Made in Stencyl. https://www.headlessd.com/

JeffreyDriver

  • *
  • Posts: 2151
Is it just freezing on a specific platform? E.g Android? Is there any consistency to it?
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

Guzzz

  • *
  • Posts: 496
So far I've tested only on iPhone and I haven't noticed any consistency.
Watch my new game http://www.hitandcrash.com based on my comic strip https://www.instagram.com/hitandcrash

HeadlessD is my dungeon-crawling game on iOs and Android. Made in Stencyl. https://www.headlessd.com/

JeffreyDriver

  • *
  • Posts: 2151
Difficult to diagnose if it's inconsistent. Maybe there's background processes causing it? Try quitting all apps and turn off data/wifi. See if it still happens.
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

merrak

  • *
  • Posts: 2507
Could be garbage collection running in the background.

vicevicebingo

  • Posts: 55
no why. it is stencyl.
if the maker of stencyl also
don't know why issue works,
then you should wait for 10 years of
the people adding complaints to your game.

lel, nothing is embarrassing
if you are innocent isn't that right?

« Last Edit: September 19, 2019, 12:57:04 am by vicevicebingo »

Guzzz

  • *
  • Posts: 496
I think it's because of some background processes. When my phone is fully charged and I haven't used it for a few hours, meaning it's not warm, I don't get any freezing.  After all it's a not a new phone (iPhone7). Will have to check on Android.

BTW what is garbage collector?
Watch my new game http://www.hitandcrash.com based on my comic strip https://www.instagram.com/hitandcrash

HeadlessD is my dungeon-crawling game on iOs and Android. Made in Stencyl. https://www.headlessd.com/

merrak

  • *
  • Posts: 2507
BTW what is garbage collector?

The garbage collector will periodically scan everything that is using memory and look for anything that isn't in use anymore. For example, suppose you make a list attribute for a scene, then the scene changes and the attribute is no longer needed. All the memory that the attribute is using can be used for something else. The garbage collector will identify it and return the memory the list claimed back to the pool of available memory.

Without garbage collection, you'd have to manage memory yourself. This is very challenging because if you don't get it perfect, you will have memory leaks. Your game would just keep using more and more memory, that couldn't be reclaimed, until the OS ran out. The downside to garbage collection is that it takes time. If there happens to be a lot of garbage to sift through, it may take a few frames to manage, which will be noticeable as quick lag stutters.

Guzzz

  • *
  • Posts: 496
Thanks merrak!
Sounds like completely innocent thing. Could it be the reason of a freeze?  Sometimes it freezes when nothing is happening. Literally I have FPS of 59 or 60 when it freezes. Soon Im gonna be able to test the game on android, will see how it goes.
Watch my new game http://www.hitandcrash.com based on my comic strip https://www.instagram.com/hitandcrash

HeadlessD is my dungeon-crawling game on iOs and Android. Made in Stencyl. https://www.headlessd.com/

merrak

  • *
  • Posts: 2507
Thanks merrak!
Sounds like completely innocent thing. Could it be the reason of a freeze?  Sometimes it freezes when nothing is happening. Literally I have FPS of 59 or 60 when it freezes. Soon Im gonna be able to test the game on android, will see how it goes.

I'd say it's enough of a possibility to be worth the time checking out. Other than primitive variables (like numbers), just about any kind of attribute or variable you use will need to be cleaned up by garbage collection. It's not always obvious where excessive garbage is coming from since background routines in your game can create it. A problem I once ran into in my own game was collision detection. Collision detection creates a lot of Vector objects for use in its calculations. These Vectors (which can number into the millions) then have to be disposed of. The result was lag, but the lag didn't occur when the collision calculations ran--rather, slightly afterward when the Vectors were being cleaned up.

About a month ago I wrote up a walkthrough of sorts using hxScout to diagnose and fix a garbage collection problem. It's here if you're interested in checking it out: http://community.stencyl.com/index.php?topic=41034.msg309240#msg309240