| Summary: | SDL error when the user closes an app manually. | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Giorgos <giorgos_gs> |
| Component: | events | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED WONTFIX | QA Contact: | Sam Lantinga <slouken> |
| Severity: | critical | ||
| Priority: | P2 | CC: | icculus |
| Version: | HG 2.0 | Keywords: | target-2.0.0 |
| Hardware: | iPhone/iPod touch | ||
| OS: | iOS 5 | ||
(Sorry if you get a lot of copies of this email, we're touching dozens of bug reports right now.) Tagging a bunch of bugs as target-2.0.0, Priority 2. This means we're in the final stretch for an official SDL 2.0.0 release! These are the bugs we really want to fix before shipping if humanly possible. That being said, we don't promise to fix them because of this tag, we just want to make sure we don't forget to deal with them before we bless a final 2.0.0 release, and generally be organized about what we're aiming to ship. Hopefully you'll hear more about this bug soon. If you have more information (including "this got fixed at some point, nevermind"), we would love to have you come add more information to the bug report when you have a moment. Thanks! --ryan. That isn't an error, that's iOS (or the simulator) killing your process as the user asked him to do. The debugger is stopping at this point to catch the signal, but it's not a bug. If it's not running in the debugger, the app's process would quietly go away at this point. You can't detect this case, there isn't an Objective-C message you can use for it; the process just goes away. It's not an SDL limitation. You _can_, however, notice when your app is starting up, because you'll be back at the start of main(). Take note of it if you have to clean up something from a previous run that got killed. --ryan. FYI, you should be able to detect this by handling the mobile app events, as described in README-ios.txt:
==============================================================================
Notes -- Application events
==============================================================================
On iOS the application goes through a fixed life cycle and you will get
notifications of state changes via application events. When these events
are delivered you must handle them in an event callback because the OS may
not give you any processing time after the events are delivered.
e.g.
int HandleAppEvents(void *userdata, SDL_Event *event)
{
switch (event->type)
{
case SDL_APP_TERMINATING:
/* Terminate the app.
Shut everything down before returning from this function.
*/
return 0;
case SDL_APP_LOWMEMORY:
/* You will get this when your app is paused and iOS wants more memory.
Release as much memory as possible.
*/
return 0;
case SDL_APP_WILLENTERBACKGROUND:
/* Prepare your app to go into the background. Stop loops, etc.
This gets called when the user hits the home button, or gets a call.
*/
return 0;
case SDL_APP_DIDENTERBACKGROUND:
/* This will get called if the user accepted whatever sent your app to the background.
If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops.
When you get this, you have 5 seconds to save all your state or the app will be terminated.
Your app is NOT active at this point.
*/
return 0;
case SDL_APP_WILLENTERFOREGROUND:
/* This call happens when your app is coming back to the foreground.
Restore all your state here.
*/
return 0;
case SDL_APP_DIDENTERFOREGROUND:
/* Restart your loops here.
Your app is interactive and getting CPU again.
*/
return 0;
default:
/* No special processing, add it to the event queue */
return 1;
}
}
int main(int argc, char *argv[])
{
SDL_SetEventFilter(HandleAppEvents, NULL);
... run your main loop
return 0;
}
|
Hi, I have an ipad 2 running the latest iOS. This error happens on the simulator too. My game runs fine with SDL2 but when the user presses the ipad hard button and leaves the app and then double presses the ipad hard button to see the apps running. then click the app icon for some seconds until it shows the minus icon over it. Then Click the minus icon to remove it from memory. Then an error happens: -------------------------------------------- Thread 1, Queue : com.apple.main-thread #0 0x381d6628 in __semwait_signal () #1 0x3402eb20 in nanosleep () #2 0x003fe6f6 in SDL_Delay at /Users/Crazysoft_Mac/PROJECTS/OpenGL/SDL_20/Xcode-iOS/SDL/../../src/timer/unix/SDL_systimer.c:143 #3 0x0033f9bc in SDL_main at /Users/Crazysoft_Mac/PROJECTS/OpenGL/iPad/The Odyssey/main.mm:1421 #4 0x0043cc48 in -[SDLUIKitDelegate postFinishLaunch] at /Users/Crazysoft_Mac/PROJECTS/OpenGL/SDL_20/Xcode-iOS/SDL/../../src/video/uikit/SDL_uikitappdelegate.m:106 #5 0x37317932 in __NSFireDelayedPerform () #6 0x31832a32 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ () #7 0x31832698 in __CFRunLoopDoTimer () #8 0x3183126e in __CFRunLoopRun () #9 0x317b44a4 in CFRunLoopRunSpecific () #10 0x317b436c in CFRunLoopRunInMode () #11 0x32c8d438 in GSEventRunModal () #12 0x31ab9cd4 in UIApplicationMain () #13 0x0043cb7c in main at /Users/Crazysoft_Mac/PROJECTS/OpenGL/SDL_20/Xcode-iOS/SDL/../../src/video/uikit/SDL_uikitappdelegate.m:60 -------------------------------------------- It detects the error on "was_error = nanosleep(&tv, &elapsed);" I use in my main look this code: -------------------------------------------- //Cap the frame rate if( fps.get_ticks() < 1000 / FRAMES_PER_SECOND )//1000=1sec { SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() ); } -------------------------------------------- How can this be fixed? How can I catch this EXIT event? thanks, Giorgos