Bug 20449 - Clicking "Stop Debugging" does not always attempt to kill the app
Summary: Clicking "Stop Debugging" does not always attempt to kill the app
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Debugger ()
Version: 3.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: 4.0.0 (C6)
Assignee: Bugzilla
Depends on:
Reported: 2014-06-06 19:49 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2016-05-10 17:05 UTC (History)
9 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Brendan Zagaeski (Xamarin Team, assistant) 2014-06-06 19:49:16 UTC
Clicking "Stop Debugging" does not always attempt to kill the app.

## Steps followed

1. Create a new single view iOS storyboard application.

2. Launch the application on a the "iPhone Retina (3.5-inch) iOS 7.1" simulator

3. Wait until the Visual Studio status bar says "Debugging session started" and the iOS Simulator is brought to the foreground.

4. Click the "Stop Debugging" button.

5. Repeat steps 2-4 several times (6 in the screen capture).

6. Wait about 5 minutes.

7. Kill the app by quitting it manually on the iOS Simulator.

(Screen capture attached)

## Results

As seen in the attached logs, on the last attempt from the screen capture, Visual Studio never sends the `CommmandUrl=KillApplication` command to the server.

The corresponding "Debugger session killing SingleView1" message also never appears in the Visual Studio logs.

_After_ the app has been manually terminated, Visual Studio sends the `KillApplication` command.

## Version information

Windows 8.1 (VMWare)

OS 10.9.3
Comment 3 Brendan Zagaeski (Xamarin Team, assistant) 2014-06-06 19:58:52 UTC
One more note: clicking the "Stop Debugging" button as soon as possible after the app appears on the simulator seems to make it a bit easier to reproduce the problem.
Comment 4 Mohit Kheterpal 2014-06-09 06:33:57 UTC

*** This bug has been marked as a duplicate of bug 9179 ***
Comment 5 Brendan Zagaeski (Xamarin Team, assistant) 2014-06-10 02:00:21 UTC
My reading of bug 9179 is that in that case, the app is not yet running when "Stop Debugging" is clicked. So as I understand it, the requested enhancement would allow the "Stop Debugging" button to cancel the deployment.

This bug (20449) is a bit different. In this bug, the application _is_ running, and only _sometimes_ the "Stop Debugging" button fails to send the `KillApplication` command to quit the app.

The fact that when the button doesn't work, VS _does_ eventually send the `KillApplication` command _after_ the app is manually terminated also sounds familiar. I thought I had heard about a similar bug where the build server or the iOS app was getting stuck, and so VS kept waiting for it and never sent the `KillApplication` command. But I can't seem to find that now. My vague recollection is that Dean was working on that.

One bug that is similar is bug #15267.

Comment 7 Corrado Cavalli 2015-04-06 13:34:46 UTC
I'm hitting the same issue using latest stable release, but it was happening even before build 533.
Very often (3 out of 5) when i click stop button, Visual Studio hangs and after a few seconds (10/20) this message appears: http://cd8ba0b44a15c10065fd-24461f391e20b7336331d5789078af53.r23.cf1.rackcdn.com/xamarin.vanillaforums.com/FileUpload/98/2f146cdfae4e873350b587257fe3a5.png

Closing the simulator immediately releases Visual Studio and it become responsive again.
I can reproduce it quite easily so if you need assistance just contact me.
Hope you understand that this is quite annoying since relaunching the simulator each time takes a lot of time.
Comment 8 Brendan Zagaeski (Xamarin Team, assistant) 2015-04-06 14:02:14 UTC
@Corrado Cavalli, the issue you're hitting is slightly different from this bug. I believe you're hitting Bug 28027 (which is a regression between 3.9.347 and 3.9.483: downgrading to 3.9.347 stops the problem in my tests). I have added you as an affected customer on that bug.
Comment 9 Corrado Cavalli 2015-04-06 14:42:58 UTC
@Brendan Zagaeski Are you sure? I'm running 3.9.533 so regression should be fixed right? 
The issue happens on simulator (haven't tried on device) and I have no problem debugging so i presume debugger is attached
Comment 10 Brendan Zagaeski (Xamarin Team, assistant) 2015-04-06 14:58:45 UTC
Yes. Bug 28027 is REOPENED (meaning it is _not_ fixed). It still occurs for me on every version Xamarin has so far released after 3.9.483. In short, I believe the patch that was committed for Bug 28027 has not completely fixed the problem (see my comments on Bug 28027).

See also "Dialog error after step 4" in bug 28027, comment 0 which shows precisely the same error message you're reporting in comment 7. That error message is _not_ part of the symptoms for bug 20449 (the bug on this page).

Bug 20449 (the bug on this page) is about a different symptom. In Bug 20449, when you stop debugging, Visual Studio successfully exits debug mode with _no_ error dialog, but the app keeps running on device.

In Bug 20449, the VS debugger also successfully connects to the running app, so breakpoints work. I'd guess that in you're case, breakpoints do not work correctly in the cases where clicking "stop debugging" causes and error message. (In contrast, this failure of breakpoints _is_ one of the symptoms of Bug 28027.)

Bug 20449 is also a _much_ older bug (filed in June, 2014), so its behavior is unlikely to have changed between 3.9.347 and 3.9.483. And I would bet that if you downgraded to 3.9.347 (the release just before WatchKit support), the problem you're currently seeing would stop.
Comment 11 Corrado Cavalli 2015-04-06 15:31:33 UTC
Thanks for clarification Brendan, hope you'll fix it asap, this is a very annoying issue. Contact me if you need further info/support.
Comment 12 Joaquin Jares 2015-09-16 09:20:49 UTC
This should be fixed in the latest alpha update