I'm making this app with which the user can record and play sound and send it to the server. However when it goes to the background and i kill the app (double tap on the home screen and remove it from there) it will crash when i try to open it back up with only this in the console:
sharedlibrary apply-load-rules all
Current language: auto; currently objective-c
Does anyone know why it is doing this and how i can solve this? If you need any more information just ask for it and I will provide it asap!
Thanks in advance!
As I understand you're running your app in debug mode (connected to Xcode). When you close the app via the home button the OS sends SIGKILL to the process and that is why the debug session is also terminated.
So your application doesn't crash.
Related
I have a map based and location based app which I put into the background. I then start a a game app (agent dash) after the game app has finished initializing I noticed that my app has been killed: 9 in the device log. Sometimes I get a memory warning message, sometimes not. But is it possible for one app to cause another to be terminated. If I run the my app on its own there is no problem. I run other apps in the foreground and no problem. Also if an app can cause mine to be terminated can I generate a restart? Thanks
Agent dash must be an memory intensive app, so when the iOS feels its running out of memory it generates memory warnings which each app needs to handle. It can even kill your app if it needs more memory. The primary thing iOS takes into consideration is that it wants to keep the app which the user is using alive. And no you can't restart your app pro grammatically the user will have to do it if he wants to.
So here is the issue I am facing. Certain portions of the application I am building open some c network sockets that allow connections to various servers/services. However, if the application goes to sleep, these socket connections are lost, and error out when trying to reload them. So what I want to do is basically notify the user when the app launches again, that the application needs to be restarted. The main question is, can I present them with a button that will kill the app by using exit(0) without my app getting rejected?
Apple says that the user should be in control of when the app is killed, and in this case I see that they are, but I am not sure of Apple's opinion on this. Has anyone else used this? Have you been rejected for this? Thanks in advance for any advice!
EDIT:
Thank you everyone for your advice. I am trying to take everything into consideration, but because the app needs to be submitted ASAP, I just need to know, if we can not get another solution, if the above proposed solution, will get rejected or not.
Your application delegate receives notifications when significant events affect the life of the application. Rather than ask your user to recreate a session, you should attempt to discontinue network operations and then resume them at the appropriate times in the application's lifecycle automatically.
You can gracefully kill network sockets (amongst other things) in any number of places as the application prepares to exit or enter the background via callbacks in your application delegate:
applicationWillResignActive:
applicationWillEnterBackground:
applicationWillTerminate:
Potentially reconstruct sockets in:
applicationDidBecomeActive
applicationWillEnterForeground
Have you tried not allowing the app to run in the background? Then it will be killed whenever the user exits to the home screen. This might be a bit aggressive, but would solve the problem. From Apple's opting out of background execution:
"If you do not want your application to remain in the background when
it is quit, you can explicitly opt out of the background execution
model by adding the UIApplicationExitsOnSuspend key to your
application’s Info.plist file and setting its value to YES.
When an application opts out, it cycles between the not running,
inactive, and active states and never enters the background or
suspended states.
When the user taps the Home button to quit the application, the
applicationWillTerminate: method of the application delegate is called
and the application has approximately five seconds to clean up and
exit before it is terminated and moved back to the not running state."
See also: How to prevent my app from running in the background on the iPhone
The documentation is pretty explicit about this, "There is no API provided for gracefully terminating an iOS application." See Technical Q&A QA1561
How do I programmatically quit my iOS application?.
To be blunt, terminating an app to cleanup a socket is just like dealing with memory management by forcing an app to exit instead of calling release.
What about bringing up a modal view controller telling the user to quit the application? You could make this view controller without any dismiss button, so the user is obligated to kill the app.
I got this error in console .can any one tell me What kind of error is this.."Terminating in response to SpringBoard's termination".
that's when the app gets terminated by the ios for high memory usage or the springboard crashes( springboard is application that manages the other applications...aka..home screen), or you quit the app
if you have the device jailbroken you can get that pretty often
did you get the springboard restart alert?
I had the same problem and accidentally it appeared that my code was still trying to do some action (in my case it was generating data for AudioUnit buffer) when I was quitting my app. I have just quit this generating in dealloc method and all looks much better. No warning.
I'm using the AsyncUDPSocket third party library in my iPhone app and for the most part it works great. I have a singleton instance of an AsyncUDPSocket that I use for all my network traffic. My app is registered for location tracking in the background and will wake up and send location update packet(s) over the network while running in the background. This all works smashingly running in the background, foreground, phone locked or unlocked, except when I do the following:
Start my app
Disable location tracking in my app settings
(so no background waking up)
Press the home button (app goes into background, socket is "freeze-dried" with rest of app)
Lock phone
Unlock phone
Resume app
Attempt to restart tracking and send something out the socket. As soon as I try, I get a SIGPIPE/EPIPE error and the app crashes.
I figured the best way to deal with this would be to close and release the socket whenever the application exits and background tracking is not enabled, but when I try [socket close] or [socket release] on the AsyncUDPSocket, I get various EXC_BAD_ACCESS errors. I've filed a bug with the dev team, but was wondering if anyone here could give some ideas on how to either avoid the SIGPIPE error entirely or other ways to keep the socket alive without releasing it. Thanks.
Great observation - yes, seems that after you send task to background and then lock the phone, sockets get dropped and next time you try to use it one gets bludgeoned with a SIGPIPE.
Ideas on how to deal with it here:
SIGPIPE crash when switching background task
(it's either set ignore for SIGPIPE for the whole app, or for the socket, or provide hanler for it)
ps. also - seems that setting to ignore SIGPIPE does not work with attached debugger, so compare with and w/o.
Just in case anyone's curious (which, judging by this question's stats, they're not), I was not able to determine what was causing the SIGPIPE error, but did eventually sort out my memory management issues (which were due to a faulty implementation of onUdpSocketDidClose in my delegate) so that I am able to reinitialize the socket each time the app restarts.
I have an APNS enabled application.
In Iphone4 when user press the HOME button application remains in cache.
Now in this condition when a push notification received after clicking on the VIEW button
the application starts running from the cache!!!.
I have found that it is invoking didReceiveRemoteNotification() and also the state of the application is UIApplicationStateActive rather than UIApplicationStateBackground
But in Iphone 3 it is working fine and invoking didLaunchingWithOptions().
What I want is when the application is not open(currently not running) , if a push notification received it will invoke the handler for push notification and launch the application from start.
any help or guidelines will be highly appriciated .
As far as I know, the application is in SUSPENDED state after tapping home button (after several transitions). So it is not executed (moreover it can be terminated in case system low memory warning).
Your possible solution is to set up the key "Application doesn't run in background" to imitate iOS3 behavior (in your .plist file).
Maybe this link will be useful for you:
iOS 4 backgrounding
If your phone is connected to your MAC and you are debugging then that is the thing that cause your problem, so try disconnect your iphone and try again, that will solve the problem.