Really need help with a crashing app on iphone/pad

I’m at a total loss and need some help please folks!

I’ve written a game which crashes at seemingly “random” points on a device but is fine in the sim. The inconsistent crash points are making me think this is probably memory related but I can’t tell for sure.

I’m using the console window in xcode to write various statements at runtime to try to isolate problematic code. However, there’s a delay of a second or so before statements appear. I have tried setting the buffer to ‘no’ but no difference.

I’ve also looked at the crash reports but I can’t understand to a point where they are helpful.

What I’m after are some general pointers about how to diagnose runtime crashes.

Can anyone help?
Does anyone else have these kinda problems? [import]uid: 8353 topic_id: 4709 reply_id: 304709[/import]

Even if there is a delay in the debug output to console you should still be able to see the last printed statement before the crash, no?

I would litter the code with positioned statements: print( “DEBUG MAIN.LUA 1” ) print( “DEBUG MAIN.LUA 2” ) etc

You should be able to see the last print before the crash. And then position the debug markers to find the exact point of the crash. Find that point and start doing print statements on any variables that are used.

Since the crashes seem “random” I’d focus on putting debug statements into the timers and event handlers since they might be firing in the background at what may seem to be random points.

Most of my “works on sim but crashes on device” problems have been with file names. Corona sim not case sensitive, but device is case sensitive on require modules. Or sometimes device doesn’t like it if I have a lua module or directory which uses a reserved name.

Good luck, hope you sort it out. [import]uid: 11393 topic_id: 4709 reply_id: 14918[/import]

Thanks for replying.

I’ve tried adding debug statements but, like I said, the app crashes and it is definitely NOT printing the last few statements. This is making it impossible to trace the problem. :frowning:

I’d read about the filenames and I’ve checked all file names in the app.

I don’t know what else to try! [import]uid: 8353 topic_id: 4709 reply_id: 14936[/import]

Do you keep version backups? Or better yet use version control? If so, go back to the last version that didn’t crash like this and then see what’s different.

If not, back up the code and then start stripping out bits until it stops crashing, and then gradually add stuff back in to see what exactly is causing the crash. And then start keeping version backups (ie. save off a separate copy after hitting milestones) and/or start using Dropbox or SVN or something. [import]uid: 12108 topic_id: 4709 reply_id: 15067[/import]

@jhocking, thanks for the reply.

Yes, I use SVN for source control and whilst your comments are correct, I see this approach as a last resort. Actually in the absence of anything else I have been doing this “trial and error” approach to ripping out code and putting it back for a couple of days.

I’m really looking for some decent debug / diagnostic support in the toolset. I can spend days messing around disabling/enabling code but I shouldn’t have to. For example, if the dSYM files were available then I would be able to read a symbolicated crash report which would *tell* me exactly where the code crashed rather than the needle in a haystack approach.

As well as my immediate short-term problem, I’m also wondering how on earth I will be able to support an app in users tell me it crashes… [import]uid: 8353 topic_id: 4709 reply_id: 15071[/import]

Well I would first see how many versions back I need to go. If it’s only a couple versions back then comparing against older versions is probably the most efficient way forward, but if you have to go back a long while then probably too much has changed for this to be an efficient approach.

Also you said:
I’ve also looked at the crash reports but I can’t understand to a point where they are helpful.

Could you post those crash reports? They probably won’t be any more meaningful to us either, but you never know.

What is a dSYM file? Is that like a dump of the terminal output?

Actually for that matter is there a way to see the terminal output when testing on device? It hadn’t occurred to me until just now to even look into that; I’m guessing that’s what you’re talking about with the console window in xcode. [import]uid: 12108 topic_id: 4709 reply_id: 15076[/import]

Yes, the console window in the xcode organizer is where you can see your “print” statement outputs. If your device is plugged in then you can watch this output in near real-time while your app is running.

dSYM files contain the symbols necessary for a crash report to become human readable. It is a natural output of the compilation/linking process if you’re coding in objective-c, etc. Unfortunately because the Corona SDK compiles “in the cloud” us Corona developers never get to see the dSYM files which means we can’t ever make sense of iDevice crash reports. If you Google you’ll find a ton of info about it.

IMO, this is a major problem in terms of building supportable apps.

I have raised a request on the features forum for the Ansca guys but no response… [import]uid: 8353 topic_id: 4709 reply_id: 15078[/import]

I agree that on device debug options should be better.

Do you need to do anything special to enable print statement outputs in the xcode console? I’ve never been able to get it to work.

I also set the buffer to no, but I don’t see anything there. [import]uid: 10835 topic_id: 4709 reply_id: 15080[/import]

If you run app in iOS emulator you can also see the output statements in the Mac OS console inside Applications->Utilities. I usually use this since it’s a bit more convenient than deploying on device.

It can get a bit noisy with other background apps printing in there as well but you can filter them out.

I think “debug on device” is in the roadmap. I hope it makes it to the next build as debugging native UI is brutally difficult without it. [import]uid: 11393 topic_id: 4709 reply_id: 15081[/import]