Debugging on the iPhone/iTouch
by Nate Gertsch · in iTorque 2D · 08/07/2009 (3:50 pm) · 10 replies
Hello everyone,
I'm in the process of debugging an iPhone game using iTBG 1.2. I've been very happy with iTBG so far and it has been relatively painless converting over to the iPod touch I'm using for testing. However, I've come to the unhappy situation where I have a section of my game that runs fine in TGB and on the simulator but crashes on the actual iPod. I'll start loading the level, and it will go black and exit the program. I'm still working on trying to figure out what is actually going wrong and I realized that my knowledge of debugging on the iphone itself is pretty limited. I figured I should ask the people here what they do when debugging as they're probably the most knowledgeable about debugging torque games on the iphone. Is there a log that is generated somewhere or a means of seeing what exactly caused my game to crash. Xcode merely says that my program ended with exit code 0 which doesn't mean very much to me.
How do you go about debugging on the iphone?
I'm in the process of debugging an iPhone game using iTBG 1.2. I've been very happy with iTBG so far and it has been relatively painless converting over to the iPod touch I'm using for testing. However, I've come to the unhappy situation where I have a section of my game that runs fine in TGB and on the simulator but crashes on the actual iPod. I'll start loading the level, and it will go black and exit the program. I'm still working on trying to figure out what is actually going wrong and I realized that my knowledge of debugging on the iphone itself is pretty limited. I figured I should ask the people here what they do when debugging as they're probably the most knowledgeable about debugging torque games on the iphone. Is there a log that is generated somewhere or a means of seeing what exactly caused my game to crash. Xcode merely says that my program ended with exit code 0 which doesn't mean very much to me.
How do you go about debugging on the iphone?
#2
08/10/2009 (2:28 pm)
Xcode does have a very nice debugger and after poking around with it I found that the organizer was generating a crash log when my application died which told me a lot. I still wish that I could have set breakpoints in the script files themselves but I can understand if that's not technically possible to do with interpreted files. The organizer window in xcode indicated that my app was crashing due to "low memory" which I really fail to understand. All my art assists are below 300k and the scene starts with only a dozen or so scene objects. I still have to figure out what exactly is going on here but at least I have a starting place.
#3
You can debug script, look at TIDE, or Torsion (win)
You could be leaking memory lots too...
need more details to help you out more tbh.
08/10/2009 (2:42 pm)
Ignore the size you see for your art assets, as they'll be expanded in size on a per pixel basis compared to your png/jpg etc - Also there is PVR compression to take into account. Are you using large images at all?You can debug script, look at TIDE, or Torsion (win)
You could be leaking memory lots too...
need more details to help you out more tbh.
#4
I don't think I'm leaking memory as I can see the memory being used using the debugger and it's fine until I load the main game level which triggers the low memory crash. I suspect that one of the assets I load there is causing the problem as I can load the level if I remove all the graphics. I just have to narrow down which are the problematic areas and then see what makes them different from the assets I can load with no problem.
Thanks for the tips, I'm pretty new at this. I'll post a more detailed question when I've had time to take a good crack at it myself.
08/10/2009 (5:15 pm)
Thanks for mentioning TIDE, I hadn't heard about that one before.I don't think I'm leaking memory as I can see the memory being used using the debugger and it's fine until I load the main game level which triggers the low memory crash. I suspect that one of the assets I load there is causing the problem as I can load the level if I remove all the graphics. I just have to narrow down which are the problematic areas and then see what makes them different from the assets I can load with no problem.
Thanks for the tips, I'm pretty new at this. I'll post a more detailed question when I've had time to take a good crack at it myself.
#5
Because after loading, anything thats not pvr will have BMP size (width * height * 4Bytes * 1.33 for mipmapping) or generally: 1.5MB of 512x512, 6MB of 1024x1024 with texture side lengths having to be power of 2
you only have 22mb of VRAM at hand for all your stuff
08/10/2009 (5:33 pm)
300k in BMP size?Because after loading, anything thats not pvr will have BMP size (width * height * 4Bytes * 1.33 for mipmapping) or generally: 1.5MB of 512x512, 6MB of 1024x1024 with texture side lengths having to be power of 2
you only have 22mb of VRAM at hand for all your stuff
#6
08/11/2009 (2:57 pm)
So I ran my program with the Xcode memory monitor tool and I discovered that my program is using 55MB when it starts up which seems abnormally high to me. Switch between menus takes me up to 59MB at which point the game will crash out. It seems that my problem might not be that the mainscreen takes significantly more memory but more that it is already close too much and the game screen pushes it over. I suppose I need to go through and convert every my pngs to PVRs though the artist on my team doesn't like the idea of converting everything squares.
#7
08/11/2009 (4:30 pm)
Sounds like you are loading all of your assets on startup, try just loading what you need for each level and deleting them when you are done with them.
#8
switch (%backgroundType)
{
case 1:
background.setImageMap(Background1);
case 2:
background.setImageMap(Background2);
...
case 99:
background.setImageMap(Background99);
}
Does that load Background1-99 or just the background I need? It seems to my newbie self that that would only load one background but I could be not understanding how Torque handles assist loading. Does torque load an asset when I first reference it or does it simply grab everything from the data directory?
I load most of my assets like this as I have many different types of images I need but only need a few on screen at a time.
08/11/2009 (4:51 pm)
So if I'm doing something like this on level start up,switch (%backgroundType)
{
case 1:
background.setImageMap(Background1);
case 2:
background.setImageMap(Background2);
...
case 99:
background.setImageMap(Background99);
}
Does that load Background1-99 or just the background I need? It seems to my newbie self that that would only load one background but I could be not understanding how Torque handles assist loading. Does torque load an asset when I first reference it or does it simply grab everything from the data directory?
I load most of my assets like this as I have many different types of images I need but only need a few on screen at a time.
#9
1) if background.setImageMap(Background1); works, then Background1 is already loaded. So yes, your assets are already loaded. Whenever the .cs file that the imageMapDatablock(Background1) is in is exec()ed, that asset is loaded.
1)
This:
08/11/2009 (5:18 pm)
2 things:1) if background.setImageMap(Background1); works, then Background1 is already loaded. So yes, your assets are already loaded. Whenever the .cs file that the imageMapDatablock(Background1) is in is exec()ed, that asset is loaded.
1)
This:
%bg = Background @ %backgroundType; background.setImageMap( %bg );will replace your whole case statement (and should be faster too).
#10
Thanks for your help everyone and keep an eye open for Cosmic Defense (working title, and no it's not another tower defense game) on the app store in the not too soon but not too distant future.
08/11/2009 (5:43 pm)
Thanks, I thought I was avoiding loading everything at once but I see I was loading all my assets at startup. I'll go back and revise how I do my loading.Thanks for your help everyone and keep an eye open for Cosmic Defense (working title, and no it's not another tower defense game) on the app store in the not too soon but not too distant future.
Associate Craig Fortune
Run -> Debugger
XCode actually has a very nice debugger.