Bug 61250 - Intermittent hang (pause, freeze) during `Xamarin.AndroidTools.AndroidSdk.IsInstalled.get()` when opening Xamarin.Android project in Visual Studio 2015
Summary: Intermittent hang (pause, freeze) during `Xamarin.AndroidTools.AndroidSdk.IsI...
Status: VERIFIED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Android ()
Version: 4.9.0 (15.6)
Hardware: PC Windows
: --- major
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2018-03-06 03:28 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2018-03-27 01:17 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: Yes
Last known good build: 4.8.0.760 (fc93f3f5b)


Attachments
Test case (19.68 KB, application/zip)
2018-03-06 03:28 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) 2018-03-06 03:28:55 UTC
Created attachment 26204 [details]
Test case

Intermittent hang (pause, freeze) during `Xamarin.AndroidTools.AndroidSdk.IsInstalled.get()` when opening Xamarin.Android project in Visual Studio 2015

I was able to hit this issue both on my physical Windows computer and in a Hyper-V VM.




## Regression status: regression in the Xamarin 15.6 Release, only in Visual Studio 2015

> GOOD: Visual Studio 2017 version 15.6
> BAD:  Visual Studio 2015 Tools for Xamarin version 4.9.0.749 (9b0fce36d) in Visual Studio 2015
> GOOD: Visual Studio 2015 Tools for Xamarin version 4.8.0.760 (fc93f3f5b)



## Steps followed to test

1. Unzip the attached test case.

2. Open the .sln file in Visual Studio 2015, and restore the NuGet packages.

3. Quit Visual Studio 2015.

4. Open the .sln file once more in Visual Studio 2015.

5. Repeat steps 3 and 4 several times.




## BAD Results with Visual Studio 2015 Tools for Xamarin version 4.9.0.749 (9b0fce36d)

The IDE hangs while loading the solution.



### Reproducibility

Number of times I repeated steps 3 and 4 until I saw the symptom, across 5 independent trials of steps 1 – 5:
> Hyper-V VM:        1  1  1  1  2
> Physical machine:  1  2 12  1  9

I suspect it is easier to hit the problem on the VM because the VM is slower.

Testing note: On the first and fourth trials on the physical machine, the Main Thread got stuck in a different Call Stack, in `Xamarin.Android.Tasks.Aapt.Execute()`.  This different symptom might require a separate fix.

Additional note: Unlike some project load hangs we've seen in the past, repeating steps 3 and 4 again after the first observed hang does _not_ necessarily hang again.



### Call Stack of the Main Thread

> [Managed to Native Transition]
> Xamarin.AndroidTools.dll!Xamarin.AndroidTools.AndroidSdk.IsInstalled.get()
> Xamarin.VisualStudio.Android.dll!Xamarin.VisualStudio.Android.Services.AndroidToolsSdk.IsInstalled.get()
> Xamarin.VisualStudio.Android.dll!Xamarin.VisualStudio.Android.Commands.AndroidCommandUI.IsAndroidInstalled.get()
> Xamarin.VisualStudio.Android.dll!Xamarin.VisualStudio.Android.Commands.StartAvdManager.QueryStatus(Clide.Commands.IMenuCommand command)
> Clide.dll!Clide.Commands.VsCommandExtensionAdapter.OnBeforeQueryStatus(object sender, System.EventArgs e) Line 96
> 	at C:\projects\clide\src\Clide\Commands\VsCommandExtensionAdapter.cs(96)
> Microsoft.VisualStudio.Shell.11.0.dll!Microsoft.VisualStudio.Shell.OleMenuCommand.OleStatus.get()
> Microsoft.VisualStudio.Shell.14.0.dll!Microsoft.VisualStudio.Shell.OleMenuCommandService.Microsoft.VisualStudio.OLE.Interop.IOleCommandTarget.QueryStatus(ref System.Guid commandGroup, uint nCmdId, Microsoft.VisualStudio.OLE.Interop.OLECMD[] oleCmd, System.IntPtr oleText)
> Microsoft.VisualStudio.Shell.14.0.dll!Microsoft.VisualStudio.Shell.Package.Microsoft.VisualStudio.OLE.Interop.IOleCommandTarget.QueryStatus(ref System.Guid guidGroup, uint nCmdId, Microsoft.VisualStudio.OLE.Interop.OLECMD[] oleCmd, System.IntPtr oleText)



## GOOD Results with Visual Studio 2015 Tools for Xamarin version 4.8.0.760 (fc93f3f5b) in Hyper-V VM

I was _unable_ to hit the issue with the previous go-live version of the Visual Studio 2015 Tools for Xamarin.

I completed 30 repetitions of steps 3 and 4 Hyper-V VM.  The solution load was successful _every_ time.  I observed _no_ hangs.




## GOOD Results with Visual Studio 2017 version 15.6 in Hyper-V VM

I was _unable_ to hit the issue in Visual Studio 2017.

I completed 30 repetitions of steps 3 and 4 in 2 different conditions in the Hyper-V VM:

(a) Using the default Android SDK configuration as installed by the Visual Studio Installer.

(b) Using the same manually installed Android SDK configuration that I used in the Visual Studio 2015 tests.

The solution load was successful _every_ time.  I observed _no_ hangs.




## Testing environment info

Microsoft Visual Studio Enterprise 2015
Version 14.0.25431.01 Update 3
Microsoft .NET Framework
Version 4.7.02046

Xamarin   4.9.0.749 (9b0fce36d)
Xamarin.Android SDK   8.2.0.15 (HEAD/22d97e153)

Windows 10 Version 1703 (OS Build 15063.786), 64-bit
US English locale
US Eastern time zone
User Name: "Windows User"

Android SDK Path: C:\android-sdk

Java 8u131 (1.8.0_131), 64-bit



### Physical machine

Android SDK Tools 25.2.5
Android SDK Build-tools 25.0.3
Android SDK Platform-tools 25.0.5
Android SDK Platform 25 version 3
Android SDK Platform 23 version 3
Android SDK Platform 16 version 5
Android SDK Platform 10 version 2


### Hyper-V VM

Android SDK Tools 26.1.1
Android SDK Build-Tools 26.0.3
Android SDK Platform-Tools 27.0.1
Android SDK Platform 26 version 2
Comment 2 Brendan Zagaeski (Xamarin Team, assistant) 2018-03-27 01:17:33 UTC
Fixed in Visual Studio 2015 Tools for Xamarin by non-public commits:
xamarin/VisualStudio/d15-6@de2fa7c036d082a95558c6ba5cbcec253b69c2c4
xamarin/XamarinVS/d15-6@1deea9870e107eaf913ab7af68a480eca7b437bc




## Verification status: verified fixed in the Xamarin 15.6.3 Release

GOOD: Visual Studio 2015 Tools for Xamarin version 4.9.0.752 (0faa808ee)

I performed 20 repetitions of steps 3 and 4, across 2 independent trials on the Hyper-V VM environment from Comment 0.  I hit no hangs on any of the repetitions.