Sudden app crash! x(

Hi,

I recently got my MacBook Pro and been moving my dev from a previous iMac to this one and finally now that I did all the steps to make provisioning profile and certificate and whatnot, now that I build and deploy on my devices, I get a very random app crashes.

I didn’t touch the code and if I build with the iMac, I don’t see the crash but when I build with the MacBook Pro, it does random crashes, sometimes before even loading the game, sometimes 2 seconds after game is running sometimes 10 seconds after it.

I checked the crash logs and apparently it quits with “signal code 9”. I googled it and apparently it’s sign of memory leak but I’m no John Carmack but my game doesn’t crash after 2 seconds of running.

How can I investigate this?

What errors are you getting in your console log??

If you mean Xcode’s log, all I could get form that is that my app exited with signal code 9.

How can I further help?

Current Apple’s developer’s section is different from what we have on Corona’s blog tutorial on how to make certificate and other stuff and I had to figure it out by myself, can it somehow be related?

I have no idea what to check.

Current Apple’s developer’s section is different from what we have on Corona’s blog tutorial on how to make certificate and other stuff and I had to figure it out by myself, can it somehow be related?

I have no idea what to check.

The Current iOS build guide should be up to date with what the current Apple developer portal is:
 

http://docs.coronalabs.com/guide/distribution/iOSBuild/index.html

Wow, I could not find this guide with google. Wish you guys would redirect people from the old guide to this one. Thanks.

I tested the build with a new iPad 4th Generaiton but it did not fail like 2 iPod touches I tested before, with no lag whatsoever. Could it be that I still have a problem but since iPad is way stronger, the problem won’t show itself?

I have access to the iPod again and I can see the the seconds after the launch of the game, it gets memory warning from the iOS and seconds after that it gets closed. It even caused the device to restart itself.

I copied the log here below and strange thing is, during running of my game Skype and Mail are also reported to have unusual memory usage are also killed with signal code 9:

Jul 2 10:03:31 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: Called vertical\_sixty\_seconds's enterScene. Jul 2 10:03:31 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: loadNextWave: Loaded next random wave from wave:1, with wave index of: 1 Jul 2 10:03:31 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: loadNextWave: We are going to make 1 food(s). Jul 2 10:03:32 Aidins-iPod MobileMail[76] \<Warning\>: Received memory warning. Jul 2 10:03:33 Aidins-iPod SpringBoard[51] \<Warning\>: Received memory warning. Jul 2 10:03:34 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: Received memory warning. Jul 2 10:03:37 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 1 Jul 2 10:03:37 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: foodManager: No more foods on the screen, loading next wave. Jul 2 10:03:37 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: loadNextWave: Loaded next random wave from wave:1, with wave index of: 3 Jul 2 10:03:37 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: loadNextWave: We are going to make 2 food(s). Jul 2 10:03:39 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 2 Jul 2 10:03:40 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 3 Jul 2 10:03:41 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 4 Jul 2 10:03:42 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 5 Jul 2 10:03:43 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 6 Jul 2 10:03:43 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 7 Jul 2 10:03:44 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 8 Jul 2 10:03:45 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 9 Jul 2 10:03:46 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 10 Jul 2 10:03:46 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: foodManager: No more foods on the screen, loading next wave. Jul 2 10:03:47 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: loadNextWave: We passed current time phase, changed wave to: 2 Jul 2 10:03:47 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: loadNextWave: Loaded next random wave from wave:2, with wave index of: 8 Jul 2 10:03:47 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: loadNextWave: We are going to make 3 food(s). Jul 2 10:03:47 Aidins-iPod UserEventAgent[12] \<Notice\>: jetsam: kernel termination snapshot being created Jul 2 10:03:48 Aidins-iPod wifid[13] \<Error\>: WiFi:[394436028.077205]: Disable WoW requested by "spd" Jul 2 10:03:48 Aidins-iPod com.apple.launchd[1] (UIKitApplication:com.apple.mobilemail[0xd8f1][76]) \<Notice\>: (UIKitApplication:com.apple.mobilemail[0xd8f1]) Exited: Killed: 9 Jul 2 10:03:48 Aidins-iPod com.apple.launchd[1] (UIKitApplication:com.skype.skype[0x2ab3][77]) \<Notice\>: (UIKitApplication:com.skype.skype[0x2ab3]) Exited: Killed: 9 Jul 2 10:03:48 Aidins-iPod SpringBoard[51] \<Warning\>: Application 'Mail' exited abnormally with signal 9: Killed: 9 Jul 2 10:03:48 Aidins-iPod SpringBoard[51] \<Warning\>: Memory level is not normal (2). Delaying auto-relaunch of 'com.apple.mobilemail' for 30 seconds. Jul 2 10:03:48 Aidins-iPod SpringBoard[51] \<Warning\>: Application 'Skype' exited abnormally with signal 9: Killed: 9 Jul 2 10:03:48 Aidins-iPod SpringBoard[51] \<Warning\>: Memory level is not normal (2). Delaying auto-relaunch of 'com.skype.skype' for 30 seconds. Jul 2 10:03:49 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 11 Jul 2 10:03:49 Aidins-iPod ReportCrash[253] \<Notice\>: Saved crashreport to /Library/Logs/CrashReporter/LowMemory-2013-07-02-100349.plist using uid: 0 gid: 0, synthetic\_euid: 0 egid: 0 Jul 2 10:03:50 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 12 Jul 2 10:03:51 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 13 Jul 2 10:03:51 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 14 Jul 2 10:03:52 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 15 Jul 2 10:03:53 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 16 Jul 2 10:03:54 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 17 Jul 2 10:03:54 Aidins-iPod UIKitApplication:com.revengfulninjas.superhungrymonsters[0xef10][248] \<Notice\>: AudioStreamBasicDescription: 2 ch, 44100 Hz, 'lpcm' (0x00000C2C) 8.24-bit little-endian signed integer, deinterleaved Jul 2 10:03:54 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 18 Jul 2 10:03:55 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 19 Jul 2 10:03:55 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: foodManager: No more foods on the screen, loading next wave. Jul 2 10:03:56 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: loadNextWave: Loaded next random wave from wave:2, with wave index of: 8 Jul 2 10:03:56 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: loadNextWave: We are going to make 3 food(s). Jul 2 10:03:57 Aidins-iPod SHM\_20130701\_2346[248] \<Warning\>: comboCounter = 20 Jul 2 10:03:58 Aidins-iPod com.apple.launchd[1] (UIKitApplication:com.revengfulninjas.superhungrymonsters[0xef10][248]) \<Notice\>: (UIKitApplication:com.revengfulninjas.superhungrymonsters[0xef10]) Exited: Killed: 9 Jul 2 10:03:58 Aidins-iPod UserEventAgent[12] \<Notice\>: jetsam: kernel termination snapshot being created Jul 2 10:03:58 Aidins-iPod SpringBoard[51] \<Warning\>: Application 'SHM\_20130701\_2346' exited abnormally with signal 9: Killed: 9

What can I do?

Thanks.

I built the SimplePool sample code from Corona with my game’s provisioning profile and tried to run it but as soon as I tap on it, it quits, saying this in the console of Xcode:

Jul 2 10:23:52 Aidins-iPod com.apple.launchd[1] (UIKitApplication:com.revengfulninjas.superhungrymonsters[0x51da][358]) \<Error\>: (UIKitApplication:com.revengfulninjas.superhungrymonsters[0x51da]) posix\_spawn("/var/mobile/Applications/C03E1B9B-43E6-40AD-B0CA-8E8238548DE3/SHM\_20130701\_2346.app/SimplePool", ...): Permission denied Jul 2 10:23:52 Aidins-iPod SpringBoard[51] \<Warning\>: Unable to obtain a task name port right for pid 358: (os/kern) failure Jul 2 10:23:52 Aidins-iPod com.apple.launchd[1] (UIKitApplication:com.revengfulninjas.superhungrymonsters[0x51da][358]) \<Warning\>: (UIKitApplication:com.revengfulninjas.superhungrymonsters[0x51da]) Exited with code: 1 Jul 2 10:23:53 Aidins-iPod SpringBoard[51] \<Warning\>: Unable to send activation event to \<SBApplication: 0x3f5340\> com.revengfulninjas.superhungrymonsters animate statusBarOrientation = 1 activate: safe animationStart = 0 deactivate: : (ipc/send) invalid destination port Jul 2 10:23:53 Aidins-iPod SpringBoard[51] \<Warning\>: Application 'SimplePool' exited abnormally with exit status 1

Tried the horse animation sample, same behavior, with this console log:

Jul 2 10:25:50 Aidins-iPod com.apple.launchd[1] (UIKitApplication:com.revengfulninjas.superhungrymonsters[0xaa84][388]) \<Error\>: (UIKitApplication:com.revengfulninjas.superhungrymonsters[0xaa84]) posix\_spawn("/var/mobile/Applications/C03E1B9B-43E6-40AD-B0CA-8E8238548DE3/SHM\_20130701\_2346.app/HorseAnimation", ...): Permission denied Jul 2 10:25:50 Aidins-iPod SpringBoard[51] \<Warning\>: Unable to obtain a task name port right for pid 388: (os/kern) failure Jul 2 10:25:50 Aidins-iPod com.apple.launchd[1] (UIKitApplication:com.revengfulninjas.superhungrymonsters[0xaa84][388]) \<Warning\>: (UIKitApplication:com.revengfulninjas.superhungrymonsters[0xaa84]) Exited with code: 1 Jul 2 10:25:50 Aidins-iPod SpringBoard[51] \<Warning\>: Unable to send activation event to \<SBApplication: 0xd6c8960\> com.revengfulninjas.superhungrymonsters animate statusBarOrientation = 3 activate: animationStart = 0 deactivate: : (ipc/send) invalid destination port Jul 2 10:25:50 Aidins-iPod SpringBoard[51] \<Warning\>: Application 'HorseAnimation' exited abnormally with exit status 1

Damn, I tried both sample apps on the iPad but the both work fine. What is wrong?!

I formated the iPod touch 4G, synced it again and copied my game, same behavior. As soon as the game starts, it gets low memory warning and then quits after a like 1-2 seconds.

And also Mail and is getting closed with Signal code 9.

I don’t know what else to do.

This may be related to audio because if I don’t interact with the game, it won’t quit but if I do, and that causes sound effect playback, it will soon crash.

I simply playback audio with audio.play, do I have to clean afterwards or something?

I’m testing the game on several other devices and it has only this problem on one of deices that is iOS 5.1.1. Is there any known Corona bugs with this version?

Tell us a bit more about your iPod?  What generation?  How much memory does it have?  How much memory is your app using?  Are you trying to handle low memory warnings?

Thanks Rob for the reply.

My iPod is a 4th generation 8Gb iPod Touch. I honestly don’t know about it’s memory because I think they are all the same between iPods and they only differ on their storage, correct me if I’m wrong.

I’m not sure about how much memory my app is using, I tried the profiler from spriteloq and it showed it’s using more than 100mb! I honestly have absolutely no idea what causing so much memory because my game is very simple. Maybe that profiler is wrong.

You asked about how I handle low memory warning, I honestly don’t know how I can get these warnings and how to handle them.

Let me know how I can help to help you further.

Thanks again, much appreciated.

For the low memory situation, see:

http://docs.coronalabs.com/api/event/memoryWarning/index.html

100MB is a lot for an older device.  But let’s get some real information instead of depending on profilers and such. 

local function memoryWarning(event) &nbsp;&nbsp;&nbsp; print("\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*") &nbsp;&nbsp;&nbsp; print("") &nbsp;&nbsp;&nbsp; print("\* lowMemory warning - texture memory in use: ", system.getInfo("textureMemoryUsed")/(1024\*1024) .. "MB", " lua memory: " .. collectgarbage("count") .. "KB") &nbsp;&nbsp;&nbsp; print("") &nbsp;&nbsp;&nbsp; print("\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*") &nbsp;&nbsp;&nbsp; return true end &nbsp; Runtime:addEventListener("memoryWarning", memoryWarning)

When you get the memory warning, the memory information will print in your console log.

Thanks for the comprehensive reply, Rob.

Yep, problem is the memory usage:

Jul 3 13:52:54 Aidin-Zolghadrs-iPod SuperHungryMonsters\_rob[1357] \<Warning\>: \*lowMemory warning - texture memory in use: 108.265625MB lua memory: 363.8388671875KB Jul 3 13:52:54 Aidin-Zolghadrs-iPod SuperHungryMonsters\_rob[1357] \<Warning\>: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

But what’s strange is why texture memory is over 100MB. I have two big objects that each have 9 frame animations, I have like 10 small objects that each have 3 frame animations, 3 backgrounds, and some small graphics for combo’s. That’s all.

How can I further track down the bug?

Finally some hope at the end of the tunnel.

Hi Aidin,

What is the overall canvas size of these “big objects” you mention? Are you using dynamic image selection to pick smaller versions for device(s) with smaller screens? Texture memory can get out of control really fast if you’re not careful…

Brent

To add to Brent’s post, what is your config.lua like?

Can you post some of your display.newImageRect() calls?  Are you using sprites/image sheets?  How big are they?

What size are the images you are loading.   Keep in mind that a 1030 x 1030px image is really 2048x2048x4 in memory or 16MB just for that one image.  If your image is bigger than 2048 on each side, say 2050x2050, just for fun, then it’s really a 4096x4096x4 sized memory or 64MB.  It doesn’t take much for those images to blow out the memory on older devices.

One of the reasons why we suggest using the @2x and@4x graphics is that for older devices, you can use smaller images to conserve memory.  Loading in an @4x sized graphic and scaling it down to an appropriate graphic for a smaller screen eats up memory and processing time.