Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App freezes on android when killed from Task Manager #1338

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

App freezes on android when killed from Task Manager #1338

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Labels
invalid This doesn't seem right

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

Reported in version: 2.0.1
Reported for operating system, platform: Android (All), All

Comments on the original bug report:

On 2014-02-02 19:23:45 +0000, Peter Jankuliak wrote:

To reproduce:

  • Open log output and start a SDL application
  • Pres the Home button
  • When in home screen, press and hold the home button till task manager shows up
  • Kill your application using swipe gesture
  • Observe in the log output that after few seconds the system terminates
    your app because it is not responding.

The issue is mostly annoying when app needs to run other services or do service cleanup after the main activity exits.

The freeze happens inside the SDLActivity.onDestroy function on line:

SDLActivity.mSDLThread.join()

and the reason is this:

When app goes to background, the call to SDL_PollEvent causes the main thread
to block for reasons explained in README-android.txt. This block is only
released when app goes back to foreground, which is when
SDLActivity.handleResume is called (not when a new message arrives!).

However, when SDL_PollEvent is blocked, it won't receive any messages pushed to
it using the SDL_PushEvent, so the line:

SDLActivity.nativeQuit() // which pushes SDL_QUIT message to the message queue

has no effect.

I'm guessing the proper solution would be to unblock SDL_PollEvent when a
message arrives in the queue. But as a fast workaround I propose to put this
code:

if (SDLActivity.mIsPaused) {
SDLActivity.mIsPaused = false;
SDLActivity.nativeResume();
}

inside the SDLActivity.onDestroy function right before the call to

SDLActivity.nativeQuit();

On 2014-02-20 18:53:41 +0000, Gabriel Jacobo wrote:

SDL already takes care of the case you mention inside Java_org_libsdl_app_SDLActivity_nativeQuit.

I was just testing this with testgles2.c on my Nexus 4 and it seems Android sometimes gives you a few seconds to finish up (in which case SDL completes the exit process cleanly in the test case you mentioned), and sometimes it just kills the app directly (you can see the kill message in the log), and you might not even get the "onDestroy()" message on the log. In either case, I'm pretty certain that there's no deadlock occurring.

So, I'm going to mark this as invalid given that it seems we are doing as best as we can to handle the quit from task manager situation.

If you'd like to suggest an alternative fix or improvement, feel free to reopen.

Thanks for the feedback!

@SDLBugzilla SDLBugzilla added bug invalid This doesn't seem right labels Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant