Sudden app crash! x(

Thanks Ron and Brent for the replies.

I checked that line Rob posted after each chunk that I load images and I can see that problem lies with those big images, each of those calls takes about 53MB of Texture Memory ™.

I do use ImageRect and specify multiple resolution with @ identifier. ( I just do @2x for now but will do the @4x for Retina devices as well).

Each of those big objects are in fact 3 image sheets that I load and turn them visible and invisible with “isVisible” flag, due to different gameplay circumstances.

Here is the section I load them:

function M.new(monsterType, xPos, yPos) -- Creating monsters local newMonster = display.newGroup() local sheetData = { width = 105, height = 430, numFrames = 9, -- The params below are optional; used for dynamic resolution support sheetContentWidth = 945, -- width of original 1x size of entire sheet sheetContentHeight = 430 -- height of original 1x size of entire sheet } local animationSequenceData = { { name = "idle", frames = { 1, 2, 3, 3 }, time = 1000, loopCount = 0 }, -- { name = "chew", frames = { 4, 5, 6, 7, 8, 8 }, time = 400, loopCount = 1 }, -- { name = "chew", frames = { 4, 7, 8, 8 }, time = 200, loopCount = 1 }, -- { name = "chew", frames = { 4, 6, 8, 8 }, time = 200, loopCount = 1 }, { name = "chew", frames = { 8, 9, 8, 9, 8, 8 }, time = 500, loopCount = 1 }, -- { name = "chew", frames = { 8, 8 }, time = 200, loopCount = 1 }, } if "Purple" == monsterType then local mySheet --============================== Phase 1 ============================== -- -- phase1:Sprite mySheet = graphics.newImageSheet("monster\_purple\_phase\_1.png", sheetData ); newMonster.phase1 = display.newSprite(mySheet, animationSequenceData) newMonster:insert(newMonster.phase1) -- Adding body part to the display group. -- phase1:Offset newMonster.phase1:setReferencePoint(display.TopLeftReferencePoint) newMonster.phase1.x = newMonster.x newMonster.phase1.y = newMonster.y -- phase1:Animation newMonster.phase1:setSequence( "idle" ) newMonster.phase1:play() --============================== Phase 2 ============================== -- -- phase2:Sprite mySheet = graphics.newImageSheet("monster\_purple\_phase\_2.png", sheetData ); newMonster.phase2 = display.newSprite(mySheet, animationSequenceData) newMonster:insert(newMonster.phase2) -- Adding body part to the display group. -- phase2:Offset newMonster.phase2:setReferencePoint(display.TopLeftReferencePoint) newMonster.phase2.x = newMonster.x newMonster.phase2.y = newMonster.y -- Making it invisible since we play phase 1 by default newMonster.phase2:setSequence( "idle" ) newMonster.phase2:play() -- newMonster.phase2.isVisible = false --============================== Phase 3 ============================== -- -- phase3:Sprite mySheet = graphics.newImageSheet("monster\_purple\_phase\_3.png", sheetData ); newMonster.phase3 = display.newSprite(mySheet, animationSequenceData) newMonster:insert(newMonster.phase3) -- Adding body part to the display group. -- phase1:Offset newMonster.phase3:setReferencePoint(display.TopLeftReferencePoint) newMonster.phase3.x = newMonster.x newMonster.phase3.y = newMonster.y -- Making it invisible since we play phase 1 by default newMonster.phase3:setSequence( "idle" ) newMonster.phase3:play() -- newMonster.phase3.isVisible = false

Please note that I’m showing 1x version here but that 53MB memory I mentioned earlier was from Corona simulator running the game for iPhone 4.

So my imagesheet is 945x430 in 1x and 1850x860 in 2x which I believe will take the 2048x2048 texture. (I’m not sure if it’s the case for iPod touch 4G as well, please correct me if I’m wrong.)

I can’t calculate precisely how much memory it will take but I think 2048*2048*4 which is about 16MB and since I load three of them for each monster, that is about that 53MB I reported.

So that’s the problem?

On the side note, I have another question as well, if this code is this bad, why iOS 6 won’t close my game and iOS 5 does?

I just saw that Rob asked for my config.lua file, here it is:

application = { content = { --xAlign = "center", --yAlign = "center", --xAlign = "left", --yAlign = "top", width = 320, height = 480, scale = "letterbox", fps = 60, imageSuffix = { ["@2x"] = 2, -- images with "@2x" appended will be used for iPad 3 } }, }

Actually on @2x devices, each of your three images are going to be 2048x1024x4.  Round each side up to the nearest power of two.

The problem with the iPod Touch 4 is that it has a retina display (640x960) so it wants to use your @2x graphics, but it only have 256M of memory as opposed to the iPhone 4 which has the same screen at 512M of memory.  Generally you can expect to have 25-50% of the memory available to you depending on the combination of memory size and operating system size.  I would think you probably are only going to have 50-75mb free on that device.

Those image sheets should be around 8MB each.  Do you have other images you are loading? Backgrounds? Multi-layer’ed backgrounds?  Audio?

Rob, why 8MB?

2048 x 2048 x 4 = 16.7MB and I load 6 of these which makes it 99.6MB and added with the background and other stuff I think it gets to that 106MB that I posted earlier, but you mentioned that each of these should take 8MB. Am I missing something? My best guess is that you referred to their 1x size.

So the only way I think to solve this is to not to load all these at the same time and just load one for each object and when they need, I load the new one and kill the previous one but since this happens like 20 times in a game session, wouldn’t it make the game hiccup or stutter?

And when I want to load the new image, should I load the file into the previous variable that held the previous image? Does that automatically make the previously loaded image deleted from memory or I should nullify it first?

Thanks.

You round each side up to the nearest power of two, so the 860px side rounds up to 1024 so you end up with a 2048x1024x4 texture (and the x4 is for the Red, Green, Blue and Alpha channels of the image)

Yes, that’s how I calculated in my last post.

Would you, or anyone else, please reply my two questions in my last post pelase?

Thanks.

How much audio are you using?  The three sprites are not taking up that much memory.  Perhaps its backgrounds or other items.   You probably could run into some delays particular on older devices. 

I would use the same variable and yes, you need to remove it/nil it out or else you’re not freeing up the memory.

I removed some space from height of my sprite sheet and it is now 1890x860 in 2x mode but the size they take is now around 50MB!

So since I removed space from height of my sprite, they should still use 2048x2048 because it’s the smallest power of 2 that is bigger than 1890x860 but it’s now almost half than before which was 1890x1720.

To rephrase my question, since both of the previous and the new size are in the 2048x2048 boundary, they should both consume same amount of texture memory, right? But I’m seeing that it uses less memory in the smaller texture case.

Does iPod touch 4G uses this “smallest power of 2 size” ? Apparently not, or I’m missing something here.

I think you are missing a key part of the math. You treat each side separately. 1890 rounds up to 2048 as does 1720 making it a 2048x2048 block. 1890 rounds up to 2048 but 860 only rounds up to 1024. 2048x1024x4 is 8mb.

Oh, you are absolutely right.

I think I assumed it as it was the case with fixed function graphic cards.

Thanks man.

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?!