Bug 52695 - [Cycle 9] Visual Studio hangs in `AndroidErrorsManager.AddWarning()` while opening solutions in certain cases related to the settings in "Tools > Options > Xamarin > Android Settings"
Summary: [Cycle 9] Visual Studio hangs in `AndroidErrorsManager.AddWarning()` while op...
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: General ()
Version: 4.3.0 (C9)
Hardware: PC Windows
: High blocker
Target Milestone: C9SR0
Assignee: Bugzilla
: 52904 ()
Depends on:
Blocks: 52832
  Show dependency tree
Reported: 2017-02-22 23:43 UTC by Bob Baldwin
Modified: 2017-03-30 02:24 UTC (History)
12 users (show)

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

Xamarin logs for last 7 days (111.72 KB, application/x-zip-compressed)
2017-02-23 13:38 UTC, Bob Baldwin
Xamarin zip logs last 7 days (116.68 KB, application/x-zip-compressed)
2017-02-23 14:56 UTC, Bob Baldwin
Android SDK Manager screen shot (86.09 KB, image/png)
2017-02-23 20:26 UTC, Bob Baldwin
Android SDK (72.83 KB, image/png)
2017-02-23 21:03 UTC, Hrvoje
Android SDK Manager snapshot (72.83 KB, image/png)
2017-02-23 21:03 UTC, Hrvoje

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 Bob Baldwin 2017-02-22 23:43:29 UTC
Solution is hung saying "(loading..)." and the PCL project says "(initializing)".  The other projects are also hung saying "(loading)"

Solution should load just like cycle 8 would load with no problems.  How do I downgrade?

# Actual behavior

# Supplemental info (logs, images, videos)

Windows 10 Ent, 16GB RAM, 512 GB SSD, VS 2015 Update 3

Completely unusable for development work.  Unable to workaround.  Critical!
Comment 1 Bob Baldwin 2017-02-22 23:50:12 UTC
It looks like Cycle 9 was released today into stable channel so when VS prompted me an update was available I installed it.  How do I downgrade until you have a fix available?  I need to downgrade Windows VS and MAC XS.
Comment 2 Jose Gallardo 2017-02-23 12:52:30 UTC
Hi Bob,

I'm sorry to hear you're facing this issue. We haven't seen it on our side and we would love to help you finding a workaround and identifying what's the root cause of the issue.

In order to be able to help, we need more information. Can you please share the Xamarin logs? As it seems like VS is hanging, I would suggest to reopen VS and send the logs from the menu "Help - Xamarin - Zip logs (7 last days)" (Please attach that zip file into this bug report).

Do you see the same behavior with an application created from scratch? 

If not, can you please put together a sample repro solution?

For Downgrading information, please refer to the following article:

Comment 3 Bob Baldwin 2017-02-23 13:38:17 UTC
Created attachment 19922 [details]
Xamarin logs for last 7 days
Comment 4 Bob Baldwin 2017-02-23 13:40:50 UTC
Hi Jose,

When this happened it created empty log files, however, I did attach them to this bug.

Unfortunately, I had to downgrade in order to get back to work.  I'll try and upgrade another machine later today to try and reproduce.

Thx...Bob Baldwin
Trabon Solutions
Comment 5 Bob Baldwin 2017-02-23 13:42:17 UTC
I forgot to mention VS was also hanging when creating a new PCL Xaml Project.
Comment 6 Bob Baldwin 2017-02-23 14:55:56 UTC
Okay, in the interest of getting this figured out, I updated to Cycle 9 again and rebooted my workstation.  This is same workstation as before.

I then tried to open my solution and VS hung, so I ended the VS task. I then restarted VS and tried to create a new solution from scratch and it hung with the message "Creating project App2..."

I then ended the VS task and tried opening my existing solution again and this time it loaded just fine so clearly this issue is intermittent but not limited to this workstation as this is also happening on one of our VM based development workstations.

I then twice tried to create a new solution from scratch and they loaded just fine.

I then rebooted the workstation and tried to load one of the new solutions I just created and VS is hanging again.

Unfortunately, as this is clearly an intermittent issue, I can't consistently reproduce!
Comment 7 Bob Baldwin 2017-02-23 14:56:50 UTC
Created attachment 19923 [details]
Xamarin zip logs last 7 days

this is newer logs than first attachment
Comment 8 Bob Baldwin 2017-02-23 15:15:13 UTC

Please let me know asap what other info you may need from us. For now, we'll leave Cycle 9 on my workstation so can assist with troubleshooting.

This is critical issue with us and we need at least a workaround ASAP!

Thx Bob Baldwin
Trabon Solutions
Comment 9 Steve Hayles 2017-02-23 16:12:50 UTC
Just to confirm that it's not a 'one-off' I had exactly the same issue after upgrading to Cycle 9 a few hours ago.

I have probably lost the relevant logs by now, my workaround was a simple downgrade back to the previous version of Xamarin for VS2015.

New projects were unaffected but attempting to open 2 of my existing solutions caused an indefinite hang at the 'preparing solution' stage.
Comment 10 Jose Gallardo 2017-02-23 17:41:58 UTC

Thanks for the details.

We're still trying to reproduce this issue, but unfortunately without success yet.
We've tried using several solutions created with C8, but it didn't help.

It sounds like there is something particular in your solutions that is not nicely handled by our extension causing the hang.

If any of you can share us your code, that would be ideal, or at least if you can describe how the solution is, what projects do you have, what kind of elements are you using, etc.

Also, a useful try would be to remove some of the projects from the .sln file (i.e. remove the UWP or iOS project, and leave just the Android one and the PCL) to see if that makes the solution loadable.
That way we can identify at least what kind of project is the culprit of the hang, and get focused on it.

Thanks again
Comment 11 Bob Baldwin 2017-02-23 18:13:43 UTC
Hi Jose,

We're currently evaluating Xamarin so have no "real" code (yet).

One of the first "evaluation" apps we created was Phoneword which is a basic app described in detail within your Forms Getting Started section.

This was successfully coded, built, and emulated using Cycle 8 and now the Phoneword solution cannot be opened (hangs) with Cycle 9 update.

HOWEVER, this is ALSO happening (at least for us) during new project creation not just when opening existing solutions.

Here are the steps we're doing:
1. Open VS 2015 Update 3 with Xamarin Cycle 9 installed.
2. Click New Project.
3. Under Visual C# templates, select "Cross Platform".
4. Select "Cross Platform App (Xamarin.Forms or Native)".
5. Make no other changes and click OK button using default app project name of AppN.
6. From the New Cross Platform App dialog, select Blank App and set UI Technology to Xamarin.Forms and Code Sharing Strategy to Portable Class Library (PCL). Leave MS Azure "Host in the cloud" unchecked.
7. Click OK.

VS hangs displaying the notification "Creating project 'AppN'".

Again dev workstation is Windows 10 Pro laptop w/16GB RAM and 500GB SSD with 100GB free.  VS 2015 is on Update 3.  Cycle 9 is installed.

This has happened once on our VM based dev workstation but happens virtually every time on the laptop.

Hope this helps.
Comment 12 Bob Baldwin 2017-02-23 18:39:18 UTC

This should help...

I manually edited the existing Phoneword.sln file and removed the Droid project.  I then tried to open the Phoneword solution and it opened just fine.

HOWEVER, I then copied back in the Droid project and then it also opened just fine.  But then I exited VS and restarted and tried to load the sln and it hangs again.

So, I removed Droid again, and successfully opened the sln many times even after restarts and reboots.

So I'm pretty sure the Droid project is the culprit.
Comment 13 Bob Baldwin 2017-02-23 18:57:48 UTC

Good news...I think I see a pattern...

It seems as long as the Droid project is not the startup project the solution opens just fine, however, if the Droid project is the startup project VS hangs.

This seems to be the case in every situation I'm testing.

Please confirm.

Thx...Bob Baldwin
Trabon Solutions
Comment 14 Bob Baldwin 2017-02-23 19:04:33 UTC
Again, it is still intermittent, however, I can't get the sln to hang if I only have the PCL and IOS projects in the sln.
Comment 15 Jose Gallardo 2017-02-23 19:17:10 UTC
Hi Bob,

I think this is very helpful. I really appreciate all the provided info.
We're still investigating, but even using Phoneword.sln not repro yet.

Also, we got a different report of what looks like the same issue, and it seems to be fixed after the user updating Android SDK Tools and Platform-tools to latest version.

Please, before trying that workaround, can you tell us what exact Android SDK Tools and Platform-tools do you have installed? (in case that does the trick to get a repro).

Thanks again!
Comment 16 Hrvoje 2017-02-23 19:51:03 UTC
Latest SDK, build tools, and platform tools installed, but hang remains.
I takes 5-10 minutes after project loading for VS to unhang.
Than build project, and after that it freezes again for 5-10 minutes.
Logs are attached.

It looks to me, this started after I installed latest Xamarin Nuget packages.

You can find logs here:

Comment 17 Bob Baldwin 2017-02-23 20:26:28 UTC
Created attachment 19929 [details]
Android SDK Manager screen shot
Comment 18 Bob Baldwin 2017-02-23 20:28:22 UTC
Hi Jose,

I just uploaded a screen shot of my Android SDK Manager.  Do you know what SDK levels the other person updated to that reported the same issue?
Comment 19 Hrvoje 2017-02-23 21:03:29 UTC
Created attachment 19932 [details]
Android SDK

This is Android SDK Manager snapshot from my computer.
Comment 20 Hrvoje 2017-02-23 21:03:58 UTC
Created attachment 19933 [details]
Android SDK Manager snapshot

This is Android SDK Manager snapshot from my computer.
Comment 21 Jose Gallardo 2017-02-23 21:13:58 UTC
Hi Bob and Hrvoje,

The info I got was that upgrading to 25.2.5 for Android SDK Tools and 25.0.3 for Platform-tools fixed the issue for that user.

We're still working on this issue.
If you find out anything else that can help us, please let us know.

Thanks for all your help!
Comment 22 Hrvoje 2017-02-23 21:32:25 UTC
I do have 25.2.5 for Android SDK Tools and 25.0.3 for Platform-tools installed but VS is still freezing the IDE.
Comment 23 Hrvoje 2017-02-24 11:46:52 UTC
I believe you should also look into Xamarin.Android.Support.v7.AppCompat nuget package to possibly resolve this issue.

I downgraded to 4.2.2. and issue with freezing seamed to dissapear, but after I build the project it complains about 9 patch images inside Xamarin.Android.Support.v7.AppCompat.

I'm not sure, but the problem with freezing might be related to malformed 9 patch images (or some Xamarin mechanism related to 9 patch image validation).

Now I downgraded Nuget packages to 24.2.1 using package manager console by issuing the command:

Install-Package Xamarin.Android.Support.v4 -Version 24.2.1

and voila, problem with freezing dissapeared.

Next, I upgraded Xamarin to Cycle 9 (first stable release), and there is no freezing any more also.
Comment 24 Bob Baldwin 2017-02-24 15:38:03 UTC
Hi Jose,

We really like the changes in Cycle 9 especially the New Project Template intermediate dialog so wonder if you would recommend we do as Hrvoje did in order to truly work with Cycle 9?

Bob Baldwin
Trabon Solutions
Comment 25 Jose Gallardo 2017-02-24 19:27:35 UTC
Hi Bob, 

We think what Hrvoje is facing is mostly not your exact same case.
However, you can try if you're using the same NuGet packages (which I don't think it's the case).

We are now getting some progress investigating a potential root cause, but it's not yet confirmed as we don't have a repro. If we can get a build with that potential patch, we can share it with you (and other users hitting the same issue) for verification.

Also, if what we're trying to confirm is correct, there might be a workaround which is installing Java 8 on your machine. (Please read http://motzcod.es/post/157589380047/xamarin-cycle-9-preparing-machines). However, if you give a try to this workaround and it does work, you won't be able to help us verifying the patched build.

Finally, I would really like to get a dump of the hang in your machine, given that we couldn't get it on our side. That would give us the real stack trace and details about the hang. The easiest way is to open Task manager with VS hanged, and then  right click on the DEVENV (Visual Studio) process and select "Create dump file" and share it with us.

Comment 26 Bob Baldwin 2017-02-24 19:46:53 UTC

I'm not planning at this time to do anything to my laptop including install Java 8.  I understand your need to verify a patch so I'm leaving my laptop alone for now.

I'm uploading a DMP file right now.

Thanks for your help in resolving.

Bob Baldwin
Trabon Solutions
Comment 27 Bob Baldwin 2017-02-24 19:55:11 UTC
Dump is too large.  Do you guys have an FTP or DropBox or somewhere I can upload to...?
Comment 30 Jose Gallardo 2017-02-24 21:34:05 UTC

Good news, looking into your Dump we've found out that your VS2015 hang is exactly where we thought it was. So, our patch is mostly going to help in your case.

We're triggering a build right now, so I think in around 2 hours I can share a patched internal build with you for verification.

Comment 31 Jose Gallardo 2017-02-25 02:04:47 UTC

Sorry for the delay.
Here is the custom build:

Please keep in mind that this is an experimental build, which didn't pass the regular QA process, and the only goal of sharing it is to verify the specific patch for this issue.

Looking forward to hear if it helped.


Comment 32 Bob Baldwin 2017-02-25 16:57:56 UTC
Hi Jose,

I just downloaded and installed on my laptop and it now opens the Phoneword.sln perfectly (no hang).

Thx for you and your teams help.

Can you explain a bit about the cause and resolution of the problem and can I install build 785 on my other VM based dev workstations or should I wait for a more official build?

Thx...Bob Baldwin
Trabon Solutions
Comment 33 Brendan Zagaeski (Xamarin Team, assistant) 2017-02-25 22:28:38 UTC
*** Bug 52753 has been marked as a duplicate of this bug. ***
Comment 34 Steve Hayles 2017-02-26 10:06:42 UTC
I can confirm that the build solved my issues.  Thanks to everyone (else) for their debugging and support
Comment 35 Jose Gallardo 2017-02-27 12:47:51 UTC
Hi Bob, Steve,

Thanks for confirming the patch actually fixes the issue.

This fix is already on track to be included in our next public release. You can keep using the patched build in the meantime, as it's basically the exact stable build ( + only this patch.

We're also analyzing if a faster stable shipping vehicle is required for this patch. I'll update the report if we have news on it.

Thanks to everyone for your invaluable help resolving this issue.

Comment 36 Bob Baldwin 2017-02-27 19:03:21 UTC
Hi Jose,

Since we're currently evaluating Xamarin, my bosses have asked me to see if you can articulate more about the cause/resolution and how this seemingly significant bug was included in a stable release?

We're still very interested, but my bosses are now somewhat concerned, so anything you can give in this way would be helpful and appreciated.

Thx...Bob Baldwin
Trabon Solutions
Comment 37 Brendan Zagaeski (Xamarin Team, assistant) 2017-02-28 17:05:31 UTC
*** Bug 52904 has been marked as a duplicate of this bug. ***
Comment 38 Jose Gallardo 2017-03-01 20:45:01 UTC
Hi Bob,

The issue was caused by a deadlock triggered by two different analyzers adding warnings from different threads, without proper management of the UI thread (where the error/warning needs to be added at the end). It was quite hard to reproduce, because the only way to hit it was getting both warnings in the same environment. The fix was basically handling that case properly.

Hope that helps clarifying.

Comment 40 Jose Gallardo 2017-03-09 20:34:13 UTC
@smorsi, it seems like you're having a different issue at build time.
Can you please file a bug with the details?

I'm marking the comment as Team private for better readability.

For guidance on filing a Xamarin bug please refer to https://developer.xamarin.com/guides/cross-platform/troubleshooting/questions/howto-file-bug/

Comment 41 smorsi27 2017-03-09 20:37:35 UTC
Hi Jose, 

I already made this bug earlier but it was marked duplicate of this bug. Can you please reopen this bug: https://bugzilla.xamarin.com/show_bug.cgi?id=52753 and add my comments above to that case. 

Let me know if that would be alright? 

Comment 42 Ben Beckley 2017-03-09 20:41:47 UTC
Big thank you to all of the users who helped with this issue. Based on these user verifications, I am marking this bug as verified fixed.
Comment 43 Brendan Zagaeski (Xamarin Team, assistant) 2017-03-23 17:54:35 UTC
## Key call stack excerpts from the minidump

To help document the precise diagnostic symptoms of this (now resolved) report for future reference, I will surface the particular call stack excerpts from the minidump that characterize this issue.

### From the Main Thread

> Xamarin.VisualStudio.Android.dll!Xamarin.VisualStudio.Android.Services.AndroidErrorsManager.AddWarning(string text, System.Action<Clide.IErrorItem> handler)
> Xamarin.VisualStudio.Android.dll!Xamarin.VisualStudio.Android.Designer.MonoAndroidDesignerService.SetInitializationError(System.Exception exception)
> Xamarin.VisualStudio.Android.dll!Xamarin.VisualStudio.Android.Designer.MonoAndroidDesignerService.SetSdkPaths()
> Xamarin.VisualStudio.Android.dll!Xamarin.VisualStudio.Android.Designer.MonoAndroidDesignerService.Initialize()
> Xamarin.VisualStudio.Android.dll!Xamarin.VisualStudio.Android.XamarinAndroidPackage.Initialize()

### From one of the Worker Threads

> Clide.dll!Clide.ErrorsManager.Add(string text, System.Action<Clide.IErrorItem> handler, bool isWarning)
> Clide.dll!Clide.ErrorsManager.AddWarning(string text, System.Action<Clide.IErrorItem> handler)
> Xamarin.VisualStudio.Android.dll!Xamarin.VisualStudio.Android.Services.AndroidErrorsManager.AddWarning(string text, System.Action<Clide.IErrorItem> handler)
> Xamarin.VisualStudio.Android.dll!Xamarin.VisualStudio.Android.Setup.JavaVersionDesignerChecker.Verify()
> Xamarin.VisualStudio.Android.dll!Xamarin.VisualStudio.Android.Setup.JavaSdkSetup.VerifyDesignerDependencies()
> Xamarin.VisualStudio.Android.dll!Xamarin.VisualStudio.Android.Setup.JavaSdkSetup.VerifyJavaSdkInstalledAsync.AnonymousMethod__18_0()

## Internal bookkeeping note: commit location of the fix

The patched build in Comment 31 contains precisely a one commit difference compared (73f58d6):

XamarinVS/cycle9 12843fe812bfd42eaf40c28cb291c3bce2f0748e

This commit is included in the published Xamarin build for VS 2015 as of the (4d2ed3d) Cycle 9 SR 0 build.