Bug 51421 - System.Environment.Exit hangs when android:enables is set on TextView
Summary: System.Environment.Exit hangs when android:enables is set on TextView
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler (show other bugs)
Version: 7.0 (C8)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Marek Habersack
URL:
Depends on:
Blocks:
 
Reported: 2017-01-11 18:42 UTC by Jeremy Kolb
Modified: 2017-06-29 13:31 UTC (History)
3 users (show)

See Also:
Tags: bb
Is this bug a regression?: ---
Last known good build:


Attachments
Sample project duplicating the bug. (39.14 KB, application/zip)
2017-06-26 14:07 UTC, Tom Opgenorth
Details

Description Jeremy Kolb 2017-01-11 18:42:57 UTC
See: https://github.com/MvvmCross/MvvmCross/issues/1538

I think this may be a Xamarin bug.  The repro test project is at https://github.com/lauxjpn/ExitTest02
Comment 1 Marek Habersack 2017-01-13 09:58:34 UTC
I might be a bad interaction between Mono and Dalvik/Art/Java, I'll investigate. But, in general, it's better to call Activity.Finish() in the launcher activity to quit the Android app - much safer.
Comment 2 Tom Opgenorth 2017-06-26 14:06:19 UTC
I can confirm this behaviour. Repeating the reproduction steps here:

1. Open the attached project in Visual Studio for Mac
2. Set a break point in the Android project in the `SomeActivity.OnBackPressed` method.
3. Run the application
4. Click the "Disable" button
5. Click on the system back button
6. The app will hang.

All this said, it would be more appropriate to call `Activity.Finish()` than to call `System.Environment.Exit()`
Comment 3 Tom Opgenorth 2017-06-26 14:07:05 UTC
Created attachment 23116 [details]
Sample project duplicating the bug.
Comment 4 Jonathan Pryor 2017-06-29 13:06:42 UTC
Why is `Environment.Exit()` being called in the first place? Normally the Android process should not be exited by user code; Android will kill the process when necessary.
Comment 5 Jeremy Kolb 2017-06-29 13:31:26 UTC
No idea why the user is doing this.  It was originally a bug filed with MvvmCross and I punted it here.

Note You need to log in before you can comment on or make changes to this bug.