[SDL] iOS Minimize App Problem / Proposal

Brian Barnes ggadwa at charter.net
Mon Nov 7 10:50:26 PST 2011


Take a look at this:

http://forums.libsdl.org/viewtopic.php?t=7596&sid=a27489538cb3fe3018ed1511bb60bb81

I've gotten around to this part in dim3, and it's a problem.  What 
basically needs to happen is my app needs to go dead; it doesn't need to 
run a loop polling the SDL event loop (which isn't supposed to be 
legal.)  It needs to be sent away as quickly as possible and be dead 
until it receives an event to wake up.

Also, there's no way to get the memory low, "please unload everything" 
event.

You need to respond to these events in a timely fashion and one misqueue 
and your app will crash (it catches GPU usage in the background).

That said, I understand how tricky or hacky this kind of change could be 
as right now SDL is a polling model, and I'd also *assume* android might 
need or could benefit from the same thing.

While the original reply is fine, I wouldn't mind a single "catch all" 
callback mechanism to handle these special cases.  An API that like is 
generic and therefor more future proof.  An API like:

void SDL_SetSystemEventHook(SDL_SystemEventHook handler);

And basically you'd define:

void myHandler(int event,void *data) { // do your stuff }
SDL_SetSystemEventHook(&myHandler);

"event" could be:

SDL_SYSTEMEVENT_WILL_RESIGN (data = NULL)
SDL_SYSTEMEVENT_DID_RESUME (data = NULL)
SDL_SYSTEMEVENT_LOW_MEMORY (data = NULL)

(or maybe something less iOS-ie.)  Obviously, the data is for structs or 
whatever if some calls require it in the future.

What do you guys think?

[>] Brian



More information about the SDL mailing list