So my Flappy Blurrr example does properly distinguish and handle
onPause vs. onDestroy(). And this was what I was alluding to earlier
when I warned about his use of global/static variables in his sample
code because these are the things that will screw you up if you don’t
use them properly and fail to distinguish between these two events.
However in practice, just for quick suspend/resume testing (hitting
Square) in a small test app, Android isn’t that wildly random for
testing just the suspend/resume part. I don’t think I’ve ever seen it
call onDestroy just toggling with that button, nor should it since
Android users would be really annoyed their apps completely restart
the very first time they hit Square/Circle. (Though I still find it
incredible that Android still makes the default behavior to restart
your app on an orientation change. I used to get tons of misdirected
confusion/blame/hate from developers about that at a previous job.)
-EricOn 3/31/16, Michael Labb? wrote:
Guys,
In reproducing the black screen bug, you are not discerning between
onPause() and onDestroy() in the Android lifecycle.By default, SDL2 (both 2.0.3 and 2.0.4) freezes the application when it goes
into the background with onPause(). When it resumes, very few resources
need to be recreated since you are un-suspending a process.When onDestroy() is called, application resources are destroyed and need to
be recreated.Unless overridden by developer settings, it is non-deterministic when
onDestroy() is being called, so trying to reproduce black screen bugs
without knowing whether it has or not is a waste of time.In developer options, you can select ?Do not keep activities? which will
force onDestroy() on backgrounding. However, it is called as soon as
onPause() is called, overriding any asynchronous events such as writing
saves to a cloud or whatever, so it is not the same as testing the true
lifecycle of an Android app.But at any rate, this ?it works for me?, ?it does not work for me?, needs to
take into account the fact that onDestroy() may or may not be getting
called, invalidating all your tests.The resume code path for SDL2 is very different if onDestroy() was called
while or during the application backgrounding.Michael Labb?