Game Development Community

Game runs ok in simulator and on iPhone pushed through Xcode, but ...

by Geoff Rowland · in iTorque 2D · 02/19/2009 (1:56 pm) · 13 replies

So I have run into a strange error and am not quite sure how to go about debugging this.

The game is running fine in iTGB, runs fine in the Simulator and runs fine when running it through Build and Go in XCode. This installs the game onto the phone. If I try to launch the game on the phone by selecting the icon, it displays the default.png image for a few seconds, then exits back to the springboard. Any thoughts as to why this is happening or how to debug this (since it seems to run fine through Xcode) ?

#1
02/19/2009 (3:08 pm)
Check the crash log it generated when it trashed. Xcode - organizer and select the device when it is connected will offer you a list of all apps that ever died on your device including the callstack that trashed it
#2
02/20/2009 (5:28 am)
thanks, that is exactly what I was looking for.
#3
04/03/2009 (11:06 am)
this seems to be happening on our app again (only on the iPhone...2nd gen iPod touch doesn't have this problem) - crash log isn't super helpful as the exception code is:

0x8badf00d

has anyone else run into this? It doesn't happen when connect to Xcode, however trying to run the app on it's own, this seems to always happen.

A quick google search came up with this:

"There are quite a few places in Darwin/OSX that fill uninitialized memory with 0x8badf00d, in exactly the same way that AIX-influenced PowerPC CFM stuff filled memory with 0xdeadbeef.

They're memorable numbers that are unaligned and point to unmapped high memory, pretty much ensuring that you get an unhappy CPU if you use one as a pointer. Much better than 0."
#4
04/03/2009 (11:30 am)
0x8badf00d could mean the program accessed unallocated memory, which makes it even more baffling :/

This is what you'd call a Heisenbug - an error which changes its behaviour when run through a debugger. Is there some subtle difference in the project settings for Debug or Release build?
#5
04/03/2009 (11:47 am)
yeah, it is very strange.....this happens with both Debug and Release builds. Both run fine when run on the iPhone through Xcode, but both crash with 8badf00d when disconnected from the mac. frustrating (and the fact it runs ok on the 2nd gen iPod touch...but crashes on both of the 2nd gen iPhones we have)
#6
04/03/2009 (12:06 pm)
use setdbgparamters() and use torsion or another debugger to check the output from a Mac/PC, then you could at least see the last few things that get called.
#7
04/10/2009 (6:41 am)
looking at the console log, the game is taking too long to launch (the timer is disabled when running through xcode, that is why we don't see the crash)

Fri Apr 10 09:35:17 unknown SpringBoard[23] <Warning>: com.ourgame failed to launch in time

would exec-ing a large number of scripts + gui controls in our main.cs cause this? I can't seem to get consistent results when testing (commenting out gui controls, etc)

Over on the Apple forums they say this happens when trying to do too much in ApplicationDidFinishLaunching, which looks like it contains the main game loop in torque.

#8
04/29/2009 (11:18 am)
Has anyone else run into this problem or found a solution? Today out of nowhere my game began doing the exact same thing, I'm not certain how to go about fixing it.
#9
04/29/2009 (11:24 am)
have you looked at the log through xcode? Do you see "failed to launch in time"?

We changed our game to load as little as possible at the start of our game and this has fixed the problem. We added a splash image as the very first thing that loads in our game and is the only thing that is loaded - no GUI controls. The user is required to touch the image, and once they do, the rest of our GUI loads.

What happens is that Xcode disables the watchdog timer, so your game launches ok when launched through Xcode. However when disconnected, there is a 30 second limit before the game will automatically exit back to the springboard.
#10
04/29/2009 (12:07 pm)
Thanks for the quick reply!

I am not entirely sure how to look at the log through xcode?

Also, how can I manually changed when things are loaded, is the problem more with scripts or art assets?
#11
04/29/2009 (12:15 pm)
You can load up your game while having the USB cable connected to your device. Don't use the Build&GO option in Xcode, but have Xcode open. If you go to Window->Organizer in Xcode you should see a Console tab. Hit that, then press the Reload button to get an update. When the game crashes, hit Reload again and you should be able to see if there is a problem with the game taking too long to load.

This same screen (organizer) is how you can look at your crash logs on the device.

We changed the way things are loaded by using custom datablocks (major script change) as well as making script changes to only load the GUI elements that are needed.

That being said, we have found the performance of the GUI system to be fairly poor on the iPhone so are probably going to move everything into a scene, and use behaviors to control user interaction.
#12
04/29/2009 (12:33 pm)
@Geoff Can you perhaps provide a writeup on how you changed the way things were loaded and used custom datablocks? It sounds like something I'd be interested in doing down the road.
#13
04/29/2009 (12:34 pm)
I couldn't get the gui to work in the way that I wanted, so mine loads in the scene already just as images.

I found the crash report, my exception code is the same as you listed yours above: 0x8badf00d

I don't see anywhere in the crash log that says 'failed to launch in time' but it does say 'failed to launch'.