-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Trying to simulate application destruction. eg: onDestroy() called while application is running.
Step to reproduce:
- put the app in background, and swipe out the app . onDestroy() is called.
On emulator, behavior is expected:
SDLThread is still running. We send the quit event. Wait (Eg. thread.join()). Stop/Cleanup everything and ends.
We reach the end of Main C Thread and onDestroy(), with the two following message:
Finished main function // C Thread
SDLActivity thread end // Activity thread
On a real device (at least the recent on I have), this is different:
onDestroy() is called, but it may never reach the end of onDestroy(). the app gets killed within 1/2/3 ms.
which is not enough to cleanly terminate things.
Android_SendLifecycleEvent(SDL_ANDROID_LIFECYCLE_DESTROY); is called.
also Android_OnDestroy().
but it gets killed within Android_ResumeAudio(); because it may be relatively long.
event if I comment it out, it goes more or less longer, but never reach the end of onDestroy().
This is bad, because if you end by saving a file. you may get something half saved and corrupted.
And also, this means the onDestroy() part is useless. so we could remove it and simplify internal code:
Things that can be removed:
- Android_OnDestroy
- SDL_ANDROID_LIFECYCLE_DESTROY
- nativeSendQuit
- Android_Destroyed variable
I mean, onDestroy() behavior seems unreliable / undefined, so maybe, we could just ignore any implementation there. and let the onDestroy() be empty.