So, this is lovely. After spending pretty much every spare moment I have had this past month, my iPad game is finally around 95% complete. So I load it up in xcode to test it, install it on both of my iPads and it runs great... except for some random crashing that is. Every time I play it, it will crash.. eventually. It is rock solid in Windows, runs with no problems at all. It uses the same game routines all throughout but for whatever reason, it just chokes.. sometimes after playing for 2 minutes, sometimes after 10 minutes. There is no pattern to it that I can see. I load all my graphics, sound, etc at the beginning. I'm using types for enemies, explosions, bullets, etc. I am also using an mp4 background music track, wav files for sound effects, and png files for graphics. I have been through the code several times and just don't see any issues with how the code is working. Are there any known issues that I should be aware of?
Thanks. :rant:
Are you using Shoebox files ?
Nope, loading all as stand-alone files. The only thing I did find was when it I ran it with leaks instrument there were a couple of small audio leaks.
Sounds like there's a memory leak somewhere. Maybe if you left the pc version running long enough you'd encounter the same issue?
I've played the game hundreds of times on the PC, sometimes up to half an hour and have not had the program crash yet. The iPad version will crash every time, usually within the first couple of minutes but it has taken up to 15 minutes or so a few times.
It would be time to start putting in some debug statements, disable sound & music etc etc to find the source of the problem
I disabled the background music but that didn't seem to help. The error that xcode is reporting is EXC_BAD_ACCESS. The only objects being released should be the types after a delete command but that should terminate the loop when called. I have even added another field called .status to the type that I set to 1 then delete the type at the end of the loop just to be sure but that hasn't helped either. Even so, this loop is called many times and fails at random.
Is it a Jailbroken phone or a proper one ?
QuoteIs it a Jailbroken phone or a proper one ?
It's an iPad.
Can you try loading in only the graphics you need at the time you need them?
QuoteIt's an iPad.
Ah yes!
It might be also worth commenting out areas of code (ie dont call title routine etc)
Like MrTAToad mentioned, put log statements in your code (STDOUT for iPad?).
Perhaps place one at the start (and end?) of each function, and find out what function is the last one that ran before the crash.
Maybe to see if it's a memory issue, try hard booting each crash, then rerun it to see if it crashes at about the same time.
Play the same level and/or load the same resources etc.
This wont be conclusive or anything, just looking for a pattern.
No, it's not jailbroken. It's a progressive linear arcade game so loading images and sounds later is not really an option. I did take a screenie of what xcode has to say and if I m reading this correctly then it seems it may be an issue in the collision routine... ?
[attachment deleted by admin]
I wonder it is related to the FOREACH with TYPE issue from this thread: http://www.glbasic.com/forum/index.php?topic=5967.0
My collision routine uses a few of these.
My game used to crash if I used ANIMCOLL with a NON-ANIM sprite vs ANIMATED sprite.
I haven't known FOREACH to cause run-time problems. Ampos's suggestion is possible though and would be a bug.
What version of GLB are you using?
Debugging your code with some sort of output should be your main priority, as is trying to reduce the program to the minimum - memory problems are the worst to fix as crashes will appear at different places every time code is changed.
My version is 9.040. I just installed the 9.052 beta. I'll give that a whirl. Log files sound like a great idea but I'm not sure how to implement log files for an iPad app. Thanks all for your suggestions!
Still crashes on the beta. I'll go now and start trying to add some debugging crap into the code. What I don't understand is why it works without issue on Windows? If it was a problem with how I have coded something then it seems that the issue should have popped up in Windows at some point... Oh well, I will remove the collision detection stuff first.
Ipad 1 has only 256meg of memory, of which almost of 50% is used by the system. Memory leaks simply run out of memory quicker on the iPad than a desktop.
I have an iPad1 and an iPad2 also and it crashes on both. I don't *think* it is a memory leak.
Are you loading and unloading sounds?
If yes just try to load all of your sounds at the beginning and forget about to unload it...
Hope it helps!
Cheers
Loading all sounds at the beginning.
Yes, it seems to crash in the collision routine.
So, now every time you do a SPRCOLL or ANIMCOLL, (write a wrapper function: mySPRCOLL), please STDOUT the parameters you pass. Then with these parameters make a small program that loads the 2 sprites/animations and does only this one ANIMCOLL call. It will surely crash as well. Please post me the code and the 2 files then.
I'm so sorry.
Thanks very much for the reply. I'll have to work on that tomorrow night. Really appreciate the help on this one. :)