Bug 28027 - [XVS.iOS 3.9.483] VS never connects to the soft debugger on physical iOS devices
Summary: [XVS.iOS 3.9.483] VS never connects to the soft debugger on physical iOS devices
Status: VERIFIED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Debugger ()
Version: 3.9
Hardware: PC Windows
: Highest critical
Target Milestone: 4.0.0 (C6)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-03-13 20:14 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2016-05-10 17:04 UTC (History)
20 users (show)

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


Attachments
Logs files (23.44 KB, application/zip)
2015-03-13 20:14 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details
Log files for 16 trials on XVS 3.9.530 (118.55 KB, application/zip)
2015-03-21 13:57 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details


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:
Status:
VERIFIED FIXED

Description Brendan Zagaeski (Xamarin Team, assistant) 2015-03-13 20:14:27 UTC
Created attachment 10329 [details]
Logs files

VS never connects to the soft debugger on physical iOS devices


Regression status: REGRESSION between XamarinVS 3.9.347.0 (056cf9e) and XamarinVS 3.9.483.0 (978be3d)

## Steps to reproduce

1. Create a new "C# -> iOS -> Universal -> Single View "

2. Attempt to start debugging the app to a physical iOS device (tested on iPad Mini 2, iOS 8.0 and iPhone 4, iOS 7.1.2).

3. Wait a few minutes after the app launches on the device.

4. Attempt to stop debugging by clicking the stop button in the Visual Studo toolbar.



## Results

The app starts on the device, but Visual Studio never connects to the debugger. For example the "Output -> Show output from: Debug" window never displayy any text.



### Dialog error after step 4.

VS pauses a couple minutes after step 4, and then pops up the following error dialog:

> The debugger was unable to terminate one or more processes:
> 
> [N/A] Mono: The debugger is still attaching to the process or the process is
> not currently executing the type of code selected for debugging.
> 
> The debugger may be unstable now. It is recommended that you save all files
> and exit.




### Windows 8.1 64-bit, in VMWare Fusion 6.0.5 (2209127)
Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.51641

Xamarin   3.9.483.0 (978be3d)
Xamarin.Android   4.20.0.37 (9e05e39f02bafe8fc0b7ab025d99f3b446835ad4)
Xamarin.iOS   8.8.0.0 (702be5207a1446b066f4653f68739da13c045227)


### OS X 10.9.5, MacBook Air
Xamarin.iOS 8.8.0.2 (Business Edition)
Hash: ccfcd59
Build date: 2015-03-10 02:20:32-0400

Xcode 6.1.1 (6611), Build 6A2008a
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2015-03-13 20:36:22 UTC
The same steps to debug work successfully in Xamarin Studio 5.8 (build 443) on the Mac build host.
Comment 2 Brendan Zagaeski (Xamarin Team, assistant) 2015-03-13 20:57:24 UTC
The problem appears to be specific to OS X 10.9. I was not able to reproduce the problem when using an OS X 10.10 VM as the build host.
Comment 3 Brendan Zagaeski (Xamarin Team, assistant) 2015-03-13 21:36:59 UTC
## Partial workaround

1. Instead of step 4, quit the app on the device. VS will exit debugging mode immediately.

2. Set a breakpoint anywhere in the iOS app project. The breakpoint can be within a method that is never called.

3. Start debugging the app again.


## Additional notes

Based on my informal quick tests, it appears that it might be necessary to change the location of the breakpoint from time to time if you start and stop debugging several times.

The workaround doesn't stop the problem 100% of the time.

Perhaps the key effect of setting a breakpoint is to change the timing of the app startup process?
Comment 5 Mohit Kheterpal 2015-03-19 15:00:20 UTC
I have checked this issue and observed that this issue is worked fine now i.e. application deploy on device and when we click on stop button application stops on device without any error.

Hence closing this issue. 

XVS 3.11.143 
X.iOS 8.10.0.133 
Build Host 3.11.0.144
Comment 6 Brendan Zagaeski (Xamarin Team, assistant) 2015-03-21 13:56:22 UTC
I am still hitting this issue on 3.9.530 (77c6c15) + monotouch-8.8.2.2.pkg (f5d0c5e) with a Mavericks (OS X 10.9.5) build host.


If I'm reading the Wrench history correctly, the proper commit is included in 3.9.530, so perhaps there's another code path that hits the same problem?


To collect more detailed statistics on this, I tried debugging the project 15 more times after step 4.


After each "success" attempt, I stopped the debugging session using the "stop debugging" button. After each "FAIL" attempt, I manually quit the app on the device so that VS would exit debugging mode.

## Results

(I'll attach the log files from all of these trials in the next comment.)

Trial 1: FAIL
Trial 2: FAIL
Trial 3: success
Trial 4: success
Trial 5: FAIL
Trial 6: FAIL
Trial 7: FAIL
Trial 8: FAIL
Trial 9: FAIL
Trial 10: FAIL
Trial 11: FAIL
Trial 12: FAIL
Trial 13: FAIL
Trial 14: FAIL
Trial 15: success


Trial 16: failed with a different error in the `mtbserver.log`:

> [21-Mar-2015 13:47:55] Exception: Exception type: System.InvalidOperationException
> Failed to get the Debug Proxy instance for this session
>   at Mtb.Server.Commands.DebugApplication.get_DebugProxy () [0x00000] in <filename unknown>:0 
>   at Mtb.Server.Commands.DebugApplication.StartDebugProxy (MonoTouch.Tools.Tools.Mtouch mtouch) [0x00000] in <filename unknown>:0 
>   at Mtb.Server.Commands.DebugApplication.StartProxy (MonoTouch.Tools.Tools.Mtouch mtouch) [0x00000] in <filename unknown>:0 
>   at Mtb.Server.Commands.DebugApplication.HandleRequest (ILoggingHelper logger, System.Object commandRequestState) [0x00000] in <filename unknown>:0 
>   at Mtb.Server.BaseCommand.OnRequest (System.Net.HttpListenerContext context, System.Object commandRequestState) [0x00000] in <filename unknown>:0 
>   at Mtb.Server.Listener.OnRequest (System.Object state) [0x00000] in <filename unknown>:0 



## Version information

Testing device: iPhone 4, iOS 7.1.2

XamarinVS 3.9.530 (77c6c15) + monotouch-8.8.2.2.pkg (f5d0c5e).

OS X 10.9.5
Comment 7 Brendan Zagaeski (Xamarin Team, assistant) 2015-03-21 13:57:37 UTC
Created attachment 10441 [details]
Log files for 16 trials on XVS 3.9.530
Comment 9 Brendan Zagaeski (Xamarin Team, assistant) 2015-03-21 14:33:50 UTC
Shoot. It looks like the "unique" feature of my environment is _not_ the OS X version of the build host after all.

Here's hoping this problem won't prove to be too difficult to reproduce when investigating it.


## Results on OS X 10.10 Yosemite VM with the same Xamarin versions as comment 6

Trial 1: FAIL
Trial 2: FAIL
Trial 3: FAIL
Trial 4: success
Trial 5: FAIL
Trial 6: FAIL
Trial 7: FAIL
Trial 8: FAIL
Trial 9: success
Trial 10: FAIL
Trial 11: FAIL
Trial 12: FAIL
Trial 13: FAIL
Trial 14: FAIL
Trial 15: FAIL
Trial 16: success
Comment 10 Saurabh 2015-03-24 02:38:31 UTC
I have checked this Issue with latest builds of C4SR3 but I am not seeing the behaviour mentioned in Comment#6 and Comment#9. Debugger successfully gets connected and stop after clicking on Stop button

Build Host Log using Maverick(10.9.4): https://gist.github.com/saurabh360/4a0a913f7284cc341452
Build Host Log using Yosemite(10.10.2): https://gist.github.com/saurabh360/534526e340e1cf9b4c23

Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.51641
Xamarin   3.9.534.0 (bb0518b)

Xamarin.iOS 8.8.2.3
Comment 11 Saurabh 2015-03-24 09:19:48 UTC
An update to Comment#10

I had tried it on C4SR4 builds and every time I am getting same behaviour. Debugger gets connected successfully every time and gets disconnected after clicking on Stop button.
Comment 12 Brendan Zagaeski (Xamarin Team, assistant) 2015-03-31 18:01:26 UTC
For any customers seeing similar issues, here are a few additional questions to answer to help confirm whether it's the same problem:

- Does deploying to an iOS simulator succeed (at least most of the time)? (In my tests for this bug, deploying to the simulator always succeeded.)

- Does the problem happen every time you attempt to deploy to an iOS device, or does it occasionally succeed? (As noted in comment 6 and comment 7, I saw successful launches on about 3/16 attempts.)

- Does the app launch on the device but then the VS debugger never connects to the app? (For my tests, the answer was "yes, the app launched successfully, but the VS debugger never connected.")


If any of these points are different in your tests, please file a new bug report (see also [1]), mention the answers to these three questions, and then feel free to contact Xamarin support (for example, via contact@xamarin.com) or add a comment on this bug to provide a link to the new bug report. Thanks!

> [1] https://kb.xamarin.com/customer/portal/articles/1910343-when-and-how-should-i-file-a-bug-report-
Comment 13 Brendan Zagaeski (Xamarin Team, assistant) 2015-04-01 05:13:51 UTC
Two more important points as a follow-up to comment 12:

- Be sure to check all of the questions using a "new from template" Unified, Universal, Single View app.

- Does adding breakpoints at a few different locations in the app help the debugger to connect successfully? (In my tests, this did seem to help (see comment 3).)
Comment 14 Alexandre Pepin 2015-04-01 09:17:56 UTC
I'm having the same problem. To answer questions of comment 12 :

- Yes, but it fails sometime. It fails less than deploying to the device
- Occasionally succeed about same ratio than you
- Yes

Adding breakpoint doesn't seem to help the debugger to connect
Comment 15 Alexandre Pepin 2015-04-10 09:04:01 UTC
It seems to also happen with the iOS simulator
Comment 17 Rolf Bjarne Kvinge [MSFT] 2015-05-04 04:11:10 UTC
To get some debug information:

* Add "-v -v -v -v" to the additional mtouch arguments and rebuild.
* Fetch the iOS device log for a failed debug attempt and attach it here.
Comment 18 Lukas Ekström 2015-05-07 17:10:16 UTC
I confirm that I also experience this problem
Comment 19 Alexandre Pepin 2015-05-13 15:43:25 UTC
@Rolf Bjarn Kvinge"
Where are the "iOS device log" that you want?
Comment 20 Rolf Bjarne Kvinge [MSFT] 2015-05-19 06:36:24 UTC
@Alexandre, there are several ways:

1. Open Xcode (on the Mac), menu Window -> Devices -> select your device on the left, and then click the small triangle on the left side of the right pane (where your device's info shows up).

2. Open Xamarin Studio (on the Mac), menu View -> Pads -> iOS Device Log -> click Connect.

3. From a terminal (on the Mac), execute "/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mtouch --logdev" (if you have multiple devices connected you'll have to pass "--devname <device name>" as well).

There should be a way to get it from within VS as well, but I don't know that.
Comment 22 Brendan Zagaeski (Xamarin Team, assistant) 2015-09-04 14:37:31 UTC
The new SSH-based build host (part of the new XamarinVS 4.0 "Cycle 6 Preview" Alpha versions) fixes this problem for me. I tried starting and stopping an app at least 20 consecutive times, and it worked correctly 100% of the time.



I am accordingly marking this bug as "resolved fixed" against the XamarinVS 4.0 target milestone. Since I was the original reporter of this problem, this specific bug report will not be reopened unless I myself hit the same problem again. Any reports of similar problems on XamarinVS 4.0 or higher may be filed separately.



In particular, if any customer with a Business license or higher comes across this bug while attempting to solve a similar problem on XamarinVS 4.0 or higher, please contact Xamarin Support via email [1]. The support team will request additional details, and then file a new bug if appropriate.

[1] https://kb.xamarin.com/customer/portal/articles/1632104-how-do-i-contact-xamarin-for-support-



If you have an Starter, Trial, or academic license, feel free to file a new bug report directly.



Thanks!

Brendan
Xamarin Customer Support