Why my app is not closing even after a crash - iphone

I am working on an iPad app. Sometimes it get crashed (I know the reason) but I am wondering why the app does not close even after a crash! When the app crash I got some error related to crash in console but the app does not close. It even appear in the multitasking bar (I can see that when I press home button two times). I am wondering is there some kind of setting for this? or this is a normal behavior?

If you are running the App from Xcode, the debugger will still be attached so the crash will not terminate the process. You can use the Xcode debugger to take a look at the stack, inspect variables etc. Only when you stop the app in Xcode will the process be completely terminated.

#Mike Weller is correct.
It is typical behavior of the simulator to not close the app upon a crash as the debugger is designed to stop at the point of code where the crash occurs (for obvious reasons!).
If you want to check it on device for your satisfaction. Connect your device, run the app once on it via xcode. Close app (stop on xcode). Then disconnect the device.
The app will be now installed on your device like any other normal app. Run this app and do whatever causes it to crash. You will see that the app will close and you will be thrown back to the iphone springboard screen.
As for app appearing in the multitasking bar, it has already been mentioned here that the presence of the app in the multitasking bar does not mean that it is still running. This is vital difference in architectures between ios and android.
The multitasking bar is NOT a task manager. The ios philosophy is that the user does not need to know that an app is running or not. He only needs to know which apps he has run in the past.

The reason that it doesn't close, is probably that the app is actually not crashing.
Could it be so that the print you are seeing is an Exception that is printed to the log?
Could it be that you are catching this exception after it is printed?
Like this:
#try {
[test characterAtIndex:6];
}
#catch (NSException * e) {
NSLog(#"Exception: %#", e);
}
The above code would not crash, since the exception is caught. Catching an exception is telling the platform that you took care of the problem so the app does not need to crash.
There could be many other reasons, but with the info you provided this is my best guess.
You could post the log print that you are seeing, that would certainly give a better clue...

Related

how to Display an error message in case of app crash (or just freezes)?

I am building an in-house application. My manager told that my app freezes time to time and she has to restrat the whole iPad to restrat the app. How can I handle these kind of sudden app crashes?
How can I handle these kind of sudden app crashes?
Debug your application using Instruments, that will help you locate why the app freeze.
Besides, if it crashes, you can plug the phone on your Mac and retrieve the Crash Log, then analyze in which method it has crashed. See the documentation.

iPhone crash logs

I have an app in ad-hoc mode and it crash right after starts. I have access to Xcode and i try to find crash log like here: iPhone crash log?
But i have no crash log from this app. Why?
Right after app starts i can see Default.png and few second later it crash, i've never even see the mainViewController. How do get a crashlog? How to detect this error? I don't have an access to source code. I have only ad-hoc distribution.
Problem not occurs on every devices. AFAIK this is only 3GS problem. Strange.
Instead of looking for the crash log, try connecting your phone to xcode but look at the Console screen instead, run the app and you should see output on the console, see if you get an error message there.
For users who don't have access to Xcode or are running on a PC you can download Apple's iPhone Configuration Utility which also gives you access to the device console.

"Watchdog has expired" when I debug app with iPhone in Xcode

From yesterday, My iphone couldnot debug any apps.
In xcode, when I choose my iPhone as the debug target, and xcode build the app, link, and run into my phone, several sencond later, the xcode finish running in my iPhone. And the console below show "Watchdog has expired. Remote device was disconnected? Debugging session terminated."
It is iPhone4s, iOS version is 5.0.1, and had jailbreaked, and update Cydia a few days ago.
It could not work on my other MBP yet.
How can I recover it?
This is because of the bug in Cydia update and Jailbreaking.
Hope this helps.
Refer to this post:
App crashes with "Watchdog has expired." message. No stack trace or crash dump
Here is tc.'s answer from that post
"Watchdog has expired." could mean anything. The way the message is
worded suggests that the "local" GDB (running on your Mac) GDB timed
out waiting for data from the "remote" GDB (running on the phone).
Alternatively, "Watchdog has expired" might be from the phone's
console output shortly before it reboots.
What does it display if you disconnect the device while your app is
running? What if you power it off? What if you issue a hard reset
(Sleep+Home for 10 seconds)?
If it's causing the device to reboot, there's something seriously
wrong happening. Your app shouldn't be able to take the phone down,
but sometimes something slips through (IIRC, UIImagePickerController
on some version of 2.x had a problem where either your app would get
killed or the phone would reboot, depending on which kicked in first).
"Large set of bitmaps" sounds like it might be causing CoreAnimation
(or IOSurface or whatever) to run out of video memory.
I would hesitate to do drawing in a background thread unless you're
very careful about thread-safety (to a first approximation,
CoreAnimation is and UIKit isn't except a few functions that were made
"thread-safe" in 4.0).
Hope this helps you.

Application crashes after installing iOS 4.2

I recently installed iOS 4.2 for my iPod after then my application started to crash.
The scenario is: I launch my application wait until it's up and running then hit the iPod home button then launch my application again, my application starts again for seconds then crashes.
my application is a job search engine, so in all of its navigation pages it's communicating with internet server.
I think the problem has to do with applicationDidEnterBackground, applicationWillEnterForeground, or applicationDidBecomeActive methods. I do not have an code in these methods and I do not know if I need to, to prevent the crash.
I do not understand what happens after I hit the home button and my application goes to the background:
will it still be running in the background (because of the multithreading thing in iOS4.2).
Sometimes when I relaunch my application it goes to last page I left in before hitting the home button and sometime it starts from the home page.
I do not understand what's going on, I just want it every time it starts to start in the home page.
I was just about to submit my application to the Apple Store just before I updated to iOS4.2 and the crash starts to happen. I'd really appreciate if someone can help me with this issue that I'm not even able/or know how to debug.
Thanks a lot in advance.
Regards,
You can set the Info.plist key ApplicationDoesNotRunOnBackground to make sure the app is completely terminated.
Xcode / Organizer will show your device crash logs.
Xcode -> COMMAND+CONTROL+O -> Device Logs or you (making sure the device is connected) can select the iPod from the list of devices, then choose Device Logs.
You don't need to have any code in the applicationDidEnterBackground, applicationWillEnterForeground, or applicationDidBecomeActive delegates, so that's not making your app crash.
I would definitely check out some of those logs in Organizer. Maybe post some of them here, or pastie.org

Unknown and unreproducible crash causes App Store rejection

After submitting our application several times, we continue to receive the following response:
Thank you for submitting My App to the
App Store. We've reviewed your
application and determined that we
cannot post this version of your iPad
application to the App Store because
My App is crashing on iPad running
iPhone OS 3.2 and Mac OS X 10.6.2. My
App crashes upon launch.
Unfortunately, crash logs have not
been generated.
However, resigning the same build with the AdHoc entitlements and loading the build onto the device yields no such crash. After a number of attempts, the application simply does not crash as reported by the reviewer. Furthermore, the reviewer does not provide any useful logging that may have been generated by SpringBoard such as an exit status or event if it had worked properly for any other device. There are no calls to explicitly exit or quit the application in the code line and yet the application terminates on startup.
What might cause an application to terminate in such a manner?
Under what conditions is an application tested that might not be found under a development environment?
Could it be a result of a signing issue that the submission validation system is simply unable to catch?
Thanks in advance.
After fighting with this for weeks, the application has finally been approved. The key: signing corruption. Hence why the application would start (or at least appear to start by showing the splash screen) and then suddenly vanish without a crash log. It failed Springboard's preflight sighing check.
A good tool to keep in mind to check for signing issues. It tells if the application has a valid signing:
codesign -vvvv MyApp.app
When I built the application, I would cp it to a network storage device where our product manager would pull it down and submit it to Apple. If decompressed on the NAS, the code signing was valid. But if you coped the compressed application back off the NAS and validate it, it would fail.
The lesson: make use of the new XCode utility to submit applications.
A few suggestions:
Try to use the leaks tool of the static analyzer to see if there are any memory leaks or problems your not seeing.
Does your app use a web service? This happened to me one time because the day Apple was reviewing the app the web service went down. That cause a crash. If thats the case you would want to add something to catch that.
Finally, In the logs Apple sent you did they send you the dsym file? If they did you can run atos from the command line and it will convert the address to symbols. That will show you what thread and symbol it's crashing on.
Be sure you test with a variety of settings: with Wifi disabled/enabled, with 3G disabled, Airplane mode on/off, location services disabled, etc.
As a last resort, assume there is a problem in your code that executes at startup. Remove half your startup code, set your release date in the far future (just in case it gets approved), then resubmit and see if they have the same problem. If not the problem is in the half you removed... it's a binary search.
I think you have two options: try harder to reproduce the defect using the tools other people are mentioning or to catch those crashes in the field.
PLCrashReporter will trap on an uncaught exception and store all relevant information. Next time your app is run, it can send the crash report that you can then symbolificate and view a stack trace of.
Ouch! That's a tough one. I've had this kind of thing happen before, but it seemed it was reproduce-able when I switched to a different device (iPhone 3G vs 3Gs, etc.). In your case though, it sounds like you're iPad only, so that might not help. There's a difference between 3G and Wifi, I suppose, but I would be really surprised if that was causing a crash on one and not the other.
One thing you could try if you think Apple's not doing their part is to change the binary name and re-submit it under another app name/record. See if you get the same response. If you get the same reviewer, you might, but I think there's a good chance you would get a different reviewer with a new app. Just set your app release date to some time in the distant future and it will never actually show up in the app store if they approve it. If the new app comes back rejected for the same reason, you've got work to do, but if they do in fact approve it, then I would get on the phone with them and point out the discrepancy.
My approach would be to make sure that the compilation is absolutely clean both in the static analyzer (this is NOT optional, it will save you time!) and for the build itself. Then set everything as described on CocoaDev' NSZombie page. Then make sure you have an iPod running 3.2 (actual hardware, not simulator) and test, test, test. Do it with network available and not available, with the device nearly full and freshly restored, every other variation you can think of. Run it with the debugger active and as a release build disconnected. Use Leaks, Instruments and all the other tools to peek in there and get a better feel for what is happening. If you exhaust every possibility you are going to have to beg for more detail from Apple but I bet you find a problem - one of the most important things in debugging an issue like this is to try to forget everything you think you know for sure and start at the beginning.