SDL2 Android Exiting (again)

Hi there!

I am currently working on a port of the L?VE engine to Android which
went surprisingly smooth due to SDL2. Fantastic work, seriously!

The code can be found at

https://bitbucket.org/MartinFelis/love-android-sdl2

Up to now I was simply calling the exit() function at the end of the
main function which worked great. From the discussions in

https://forums.libsdl.org/viewtopic.php?p=40814&sid=e42666970053c2a3282e0d6a3568373d

and the bug description in

https://bugzilla.libsdl.org/show_bug.cgi?id=2378

I felt adventurous to exit the app nicer by removing the exit() call.
The app does get destroyed, however when switching to the task manager I
can still see the App. When clicking on it it tries to resume the app
which results in a segfault as SDL_main is not running anymore.

Is this a bug or a misunderstood feature?

Thanks!
Martin

2014-02-07 20:34 GMT-03:00 Martin Felis :

I felt adventurous to exit the app nicer by removing the exit() call.
The app does get destroyed, however when switching to the task manager I
can still see the App. When clicking on it it tries to resume the app
which results in a segfault as SDL_main is not running anymore.

Is this a bug or a misunderstood feature?

Thanks!
Martin

It may be a bug, does handleNativeExit get called after the native side
ends?–
Gabriel.

Yes it gets called. Also as a result onDestroy() gets called.

(Sorry for possible double post - used wrong email address)On 08.02.2014 00:58, Gabriel Jacobo wrote:

2014-02-07 20:34 GMT-03:00 Martin Felis <martin at fysx.org
<mailto:martin at fysx.org>>:

I felt adventurous to exit the app nicer by removing the exit() call.
The app does get destroyed, however when switching to the task manager I
can still see the App. When clicking on it it tries to resume the app
which results in a segfault as SDL_main is not running anymore.

Is this a bug or a misunderstood feature?

Thanks!
Martin

It may be a bug, does handleNativeExit get called after the native side
ends?

Yes it gets called. Also as a result onDestroy() gets called.On 08.02.2014 00:58, Gabriel Jacobo wrote:

2014-02-07 20:34 GMT-03:00 Martin Felis <martin at fysx.org
<mailto:martin at fysx.org>>:

I felt adventurous to exit the app nicer by removing the exit() call.
The app does get destroyed, however when switching to the task manager I
can still see the App. When clicking on it it tries to resume the app
which results in a segfault as SDL_main is not running anymore.

Is this a bug or a misunderstood feature?

Thanks!
Martin

It may be a bug, does handleNativeExit get called after the native side
ends?

Hope it is okay to bump.

Does not calling exit() work for other people?

For me it switches to Home but in the task manager the App is still
available and when switching to it it results in a segfault.

This is also for the case when modifying testgles.c to exit the main
render loop after e.g. 1000 frames.On 08.02.2014 11:20, Martin Felis wrote:

On 08.02.2014 00:58, Gabriel Jacobo wrote:

2014-02-07 20:34 GMT-03:00 Martin Felis <martin at fysx.org
<mailto:martin at fysx.org>>:

I felt adventurous to exit the app nicer by removing the exit() call.
The app does get destroyed, however when switching to the task manager I
can still see the App. When clicking on it it tries to resume the app
which results in a segfault as SDL_main is not running anymore.

Is this a bug or a misunderstood feature?

Thanks!
Martin

It may be a bug, does handleNativeExit get called after the native side
ends?

Yes it gets called. Also as a result onDestroy() gets called.

(Sorry for possible double post - used wrong email address)


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Just tried it in the emulator and it seems I need to rephrase my problem:

The app does quit (also in the task manager), however when pressing the
"recent apps button" that is available on newer (i.e. >= 4.0) devices
the SDL2 App is still listed but cannot be switched to due to the segfault.

I was not able to reproduce it in the emulator as I cannot get the
"recent apps button" to show up. :(On 12.02.2014 21:03, Martin Felis wrote:

Hope it is okay to bump.

Does not calling exit() work for other people?

For me it switches to Home but in the task manager the App is still
available and when switching to it it results in a segfault.

This is also for the case when modifying testgles.c to exit the main
render loop after e.g. 1000 frames.

On 08.02.2014 11:20, Martin Felis wrote:

On 08.02.2014 00:58, Gabriel Jacobo wrote:

2014-02-07 20:34 GMT-03:00 Martin Felis <martin at fysx.org
<mailto:martin at fysx.org>>:

I felt adventurous to exit the app nicer by removing the exit() call.
The app does get destroyed, however when switching to the task manager I
can still see the App. When clicking on it it tries to resume the app
which results in a segfault as SDL_main is not running anymore.

Is this a bug or a misunderstood feature?

Thanks!
Martin

It may be a bug, does handleNativeExit get called after the native side
ends?

Yes it gets called. Also as a result onDestroy() gets called.

(Sorry for possible double post - used wrong email address)


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

This is the best I could do: https://hg.libsdl.org/SDL/rev/56e9c709db7e Let
me know how it works for you.

The background behind this is that Android doesn’t want you terminating
your app yourself so badly that even if you do, the static variables we
keep never get wiped unless we do that manually. So, you exit your app, it
finishes successfully, you run it again…and all the previous variables
keep their previous values…which at least in my opinion is bona fide
strange bug generator.

All of this doesn’t solve the “problem” of the app appearing in the task
stack after you exit. Apparently, from a quick google (and this is news to
me), the task stack shows recent apps whether they are still open or not
(though removing an app from that by swiping it away does seem to close it
effectively).

2014-02-12 17:26 GMT-03:00 Martin Felis :> Just tried it in the emulator and it seems I need to rephrase my problem:

The app does quit (also in the task manager), however when pressing the
"recent apps button" that is available on newer (i.e. >= 4.0) devices
the SDL2 App is still listed but cannot be switched to due to the segfault.

I was not able to reproduce it in the emulator as I cannot get the
"recent apps button" to show up. :frowning:

On 12.02.2014 21:03, Martin Felis wrote:

Hope it is okay to bump.

Does not calling exit() work for other people?

For me it switches to Home but in the task manager the App is still
available and when switching to it it results in a segfault.

This is also for the case when modifying testgles.c to exit the main
render loop after e.g. 1000 frames.

On 08.02.2014 11:20, Martin Felis wrote:

On 08.02.2014 00:58, Gabriel Jacobo wrote:

2014-02-07 20:34 GMT-03:00 Martin Felis <martin at fysx.org
<mailto:martin at fysx.org>>:

I felt adventurous to exit the app nicer by removing the exit()

call.

The app does get destroyed, however when switching to the task

manager I

can still see the App. When clicking on it it tries to resume the

app

which results in a segfault as SDL_main is not running anymore.

Is this a bug or a misunderstood feature?

Thanks!
Martin

It may be a bug, does handleNativeExit get called after the native side
ends?

Yes it gets called. Also as a result onDestroy() gets called.

(Sorry for possible double post - used wrong email address)


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Gabriel.

Thanks for the reply!

Your change allows the app to restart properly, which is somewhat better.

However maybe this:

http://stackoverflow.com/questions/13385289/remove-app-from-recent-apps-programmatically
could do the trick?

I do not have much experience with Android programming and simply added

Intent clearRecentAppIntent = new Intent(Intent.ACTION_MAIN);
clearRecentAppIntent.addCategory(Intent.CATEGORY_HOME);
clearRecentAppIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
clearRecentAppIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(clearRecentAppIntent);

to the SDLActivity.onDestroy() function right after super.onDestroy().
However it does not do as I had hoped for, but maybe I am doing
something wrong here.On 12.02.2014 22:17, Gabriel Jacobo wrote:

This is the best I could
do: https://hg.libsdl.org/SDL/rev/56e9c709db7e Let me know how it works
for you.

The background behind this is that Android doesn’t want you terminating
your app yourself so badly that even if you do, the static variables we
keep never get wiped unless we do that manually. So, you exit your app,
it finishes successfully, you run it again…and all the previous
variables keep their previous values…which at least in my opinion is
bona fide strange bug generator.

All of this doesn’t solve the “problem” of the app appearing in the task
stack after you exit. Apparently, from a quick google (and this is news
to me), the task stack shows recent apps whether they are still open or
not (though removing an app from that by swiping it away does seem to
close it effectively).

2014-02-12 17:26 GMT-03:00 Martin Felis <@Martin_Felis
mailto:Martin_Felis>:

Just tried it in the emulator and it seems I need to rephrase my
problem:

The app does quit (also in the task manager), however when pressing the
"recent apps button" that is available on newer (i.e. >= 4.0) devices
the SDL2 App is still listed but cannot be switched to due to the
segfault.

I was not able to reproduce it in the emulator as I cannot get the
"recent apps button" to show up. :(

On 12.02.2014 21:03, Martin Felis wrote:
> Hope it is okay to bump.
>
> Does not calling exit() work for other people?
>
> For me it switches to Home but in the task manager the App is still
> available and when switching to it it results in a segfault.
>
> This is also for the case when modifying testgles.c to exit the main
> render loop after e.g. 1000 frames.
>
> On 08.02.2014 11:20, Martin Felis wrote:
>> On 08.02.2014 00:58, Gabriel Jacobo wrote:
>>>
>>>
>>>
>>> 2014-02-07 20:34 GMT-03:00 Martin Felis <martin at fysx.org
<mailto:martin at fysx.org>
>>> <mailto:martin at fysx.org <mailto:martin at fysx.org>>>:
>>>
>>>
>>>     I felt adventurous to exit the app nicer by removing the
exit() call.
>>>     The app does get destroyed, however when switching to the
task manager I
>>>     can still see the App. When clicking on it it tries to
resume the app
>>>     which results in a segfault as SDL_main is not running anymore.
>>>
>>>     Is this a bug or a misunderstood feature?
>>>
>>>     Thanks!
>>>     Martin
>>>
>>>
>>> It may be a bug, does handleNativeExit get called after the
native side
>>> ends?
>>
>> Yes it gets called. Also as a result onDestroy() gets called.
>>
>> (Sorry for possible double post - used wrong email address)
>> _______________________________________________
>> SDL mailing list
>> SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
>> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>>
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>

_______________________________________________
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org