Bug 51227 - XS hangs on "Updating resources..." when opening project with the android emulator already open
Summary: XS hangs on "Updating resources..." when opening project with the android emu...
Status: REOPENED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 6.1.2 (C7SR1)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2017-01-05 02:15 UTC by Tzach Shabtay
Modified: 2017-01-07 03:07 UTC (History)
2 users (show)

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


Attachments
IDE logs (703.91 KB, application/zip)
2017-01-05 02:15 UTC, Tzach Shabtay
Details
Terminal diag output (233.02 KB, text/plain)
2017-01-07 03:07 UTC, Tzach Shabtay
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 for Bug 51227 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
REOPENED

Description Tzach Shabtay 2017-01-05 02:15:43 UTC
Created attachment 19085 [details]
IDE logs

Description of Problem:

I installed Intel's Haxm yesterday for speeding up the android emulator. It worked fine and I used it with the emulator.
Today I had to restart Xamarin Studio but I did not restart the emulator.
On loading my project, Xamarin Studio shows "Updating Resources..." and never exits it. The IDE is responsive but it won't compile anything (stuck on "Building" or something like that when I try).
I tried restarting XS a few times, it didn't help.
I then closed the emulator and restarted XS, and voila, it opened fine.

I then tried to keep the emulator open and restart XS again, to see if it reproduces. It didn't (so maybe you need to keep the emulator open for a long time for this to reproduce?).

Additional Information:

1. Spotted this in the console logs (System logs queries -> All messages), which made me to believe it's the emulator's fault:
1/4/17 8:32:30.000 PM kernel[0]: haxm_error: vcpu is paniced, id:0
1/4/17 8:32:30.000 PM kernel[0]: haxm_error: log_host_cr4_vmxe: 1
1/4/17 8:32:30.000 PM kernel[0]: haxm_error: log_host_cr4 1626e0
1/4/17 8:32:30.000 PM kernel[0]: haxm_error: log_vmxon_err 0
1/4/17 8:32:30.000 PM kernel[0]: haxm_error: log_vmxon_addr 33d92000
1/4/17 8:32:30.000 PM kernel[0]: haxm_error: log_vmxon_err_type1 1
1/4/17 8:32:30.000 PM kernel[0]: haxm_error: log_vmxon_err_type2 0
1/4/17 8:32:30.000 PM kernel[0]: haxm_error: log_vmxon_err_type3 0
1/4/17 8:32:30.000 PM kernel[0]: haxm_error: log_vmclear_err 0
1/4/17 8:32:30.000 PM kernel[0]: haxm_error: log_vmptrld_err 0
1/4/17 8:32:30.000 PM kernel[0]: haxm_error: log_vmoff_no 0
1/4/17 8:32:30.000 PM kernel[0]: haxm_error: log_vmoff_err 0
This pattern repeats itself again and again and again in an endless loop, hundreds of time each second, so that every once in a while I also see this log:
1/4/17 8:32:29.000 PM kernel[0]: *** kernel exceeded 500 log message per second limit  -  remaining messages this second discarded ***

2. Looks like it might be a repro of https://bugzilla.xamarin.com/show_bug.cgi?id=41075, which was closed as not reproducible. Following the requests on that bug, when XS was in its hanging state, I tried doing kill -QUIT on it, it didn't kill it, I also tried with sudo, did not work, I eventually did sudo kill -9 which did work. I'll attach the IDE logs to the bug, this includes both today's logs and yesterday's logs, for comparison with a working IDE. The last 2 logs in the zip are when it definitely happened.
Comment 1 Greg Munn 2017-01-05 16:05:19 UTC
Tzach,

1. Updating the resources isn't related to having an emulator running. What happens is that we ask our build process (which is a process outside of XS to invoke a specific target, in this case `UpdateAndroidResources`. The output from the task should be in a `ResGen` output pad.

2. It does sound like a repro, can you move your userprefs file out of the solution folder and see if that fixes it.

3. `kill -QUIT` doesn't actually kill the process, it sends a QUIT signal which we use to dump the full call stack to try and identify what XS is doing at that moment in time.

I still need to look through the logs some more, but right now I can't tell you why the target didn't complete. One thing you could try is to see what happens when you try to invoke that target from Terminal

> xbuild /p:DesignTimeBuild=true /t:UpdateAndroidResources 

it's possible that it might be doing something long running?
Comment 2 Tzach Shabtay 2017-01-06 03:37:17 UTC
(TLDR Version, reliable repro steps:
1. start google emulator with HaxM
2. start XAP emulator
3. In XS, Debug with existing google emulator -> XS hangs on "detecting installed packages"
4. Restart XS and reopen projects -> XS hangs on "updating resources..."
5. Kill google emulator -> XS gets back to life on the spot -> life is good again
)

So it happened again today, and I figured out how to reproduce it, so now I can reproduce it on demand.
What I didn't write about yesterday is why I had to restart XS in the first place, since I didn't remember.
So last night, I again kept the emulator open (and this bug is definitely 100% related to the emulator), and today when I got back to the computer I started debugging. Now, there's another bug in Xamarin Studio, where it forgot the emulator I chose yesterday, and instead opted to start an old XAP emulator which I haven't used in weeks (please solve this bug as well, it's really annoying! I saw that that emulator appears in my userprefs file, so I'll try to modify it manually as a workaround).
At that point I stopped debugging, I set the currently running emulator to run instead and pressed debug again. I haven't actually killed the XAP emulator though, which apparently is what started the HAXM to go crazy, it starts the endless loop of errors which I showed previously, with an additional line:

1/5/17 9:56:59.000 PM kernel[0]: haxm_error: HAX: vmxon failed (33d93000). Is that another VMM running?

Once I kill the XAP emulator that line stops appearing but the endless loop of errors keeps on going. And at that point XS was stuck on "detecting installed packages". When I then restart XS it hangs on "updating resources".
Regarding "UpdateAndroidResources": I didn't have any ResGen output pad visible, and when I ran from terminal it looks like it gets stuck after "found devices" running shell "getprop ro.build.version.sdk" (I'll add the logs from the terminal run at the end of this post). 
I tried moving my userprefs file and restart, it doesn't solve the issue. The only solution is killing the emulator.
Note that I don't actually need to restart XS, once I kill the emulator it becomes responsive again almost immediately.
As for the last question, I kept XS running for 30 minutes and it was still hanging on "updating resources" (not even a timeout after 30 minutes?).

The output from "UpdateAndroidResources" in the terminal:
Tzachs-MacBook-Pro:Droid zachi$ xbuild /p:DesignTimeBuild=true /t:UpdateAndroidResources
XBuild Engine Version 14.0
Mono, Version 4.6.2.0
Copyright (C) 2005-2013 Various Mono authors

Build started 1/5/2017 10:24:22 PM.
__________________________________________________
Project "/Users/zachi/Projects/MonoAGS/Source/Demo/Droid/DemoQuest.Droid.csproj" (UpdateAndroidResources target(s)):
	Target ResolveProjectReferences:
		Project "/Users/zachi/Projects/MonoAGS/Source/Engine/AGS.Engine/AGS.Engine.csproj" (default target(s)):
			Target PrepareForBuild:
				Configuration: Debug Platform: AnyCPU
			Target ResolveProjectReferences:
				Project "/Users/zachi/Projects/MonoAGS/Source/AGS.API/AGS.API.csproj" (default target(s)):
					Target PrepareForBuild:
						Configuration: Debug Platform: AnyCPU
					Target GenerateSatelliteAssemblies:
					No input files were specified for target GenerateSatelliteAssemblies, skipping.
					Target _GenerateTargetFrameworkMonikerAttribute:
					Skipping target "_GenerateTargetFrameworkMonikerAttribute" because its outputs are up-to-date.
					Target CoreCompile:
					Skipping target "CoreCompile" because its outputs are up-to-date.
				Done building project "/Users/zachi/Projects/MonoAGS/Source/AGS.API/AGS.API.csproj".
			Target GenerateSatelliteAssemblies:
			No input files were specified for target GenerateSatelliteAssemblies, skipping.
			Target _GenerateTargetFrameworkMonikerAttribute:
			Skipping target "_GenerateTargetFrameworkMonikerAttribute" because its outputs are up-to-date.
			Target CoreCompile:
			Skipping target "CoreCompile" because its outputs are up-to-date.
			Target _CopyDeployFilesToOutputDirectoryAlways:
				Copying file from '/Users/zachi/Projects/MonoAGS/DLLs/OpenTK.dll.config' to '/Users/zachi/Projects/MonoAGS/Source/Engine/AGS.Engine/bin/Debug/OpenTK.dll.config'
		Done building project "/Users/zachi/Projects/MonoAGS/Source/Engine/AGS.Engine/AGS.Engine.csproj".
		Project "/Users/zachi/Projects/MonoAGS/Source/Engine/AGS.Engine.Android/AGS.Engine.Android.csproj" (default target(s)):
			Target _BuildSdkCache:
			Skipping target "_BuildSdkCache" because its outputs are up-to-date.
			Target _SetLatestTargetFrameworkVersion:
				 Found Android SDK. API levels: 10, 15, 19, 23
			Target _ResolveMonoAndroidSdks:
				MonoAndroid Tools: /Library/Frameworks/Xamarin.Android.framework/Versions/Current/lib/mandroid/
				MonoAndroid Binaries: /Library/Frameworks/Xamarin.Android.framework/Versions/Current/bin/
				Android Platform API level: 25
				TargetFrameworkVersion: v7.0
				Android NDK: /Users/zachi/Library/Developer/Xamarin/android-ndk/android-ndk-r10e/
				Android SDK: /Users/zachi/Library/Developer/Xamarin/android-sdk-macosx/
				Android SDK Build Tools: /Users/zachi/Library/Developer/Xamarin/android-sdk-macosx/build-tools/23.0.1/
				Java SDK: /usr/
			Target _GetPrimaryCpuAbi:
				Tool /Users/zachi/Library/Developer/Xamarin/android-sdk-macosx/platform-tools/adb execution started with arguments: devices 
				  FoundDevices: True
				Tool /Users/zachi/Library/Developer/Xamarin/android-sdk-macosx/platform-tools/adb execution started with arguments: shell getprop ro.build.version.sdk
Comment 3 Tzach Shabtay 2017-01-06 03:49:44 UTC
(Also opened a related bug for HaxM, see here: https://code.google.com/p/android/issues/detail?id=231584&thanks=231584&ts=1483674268)
Comment 4 Greg Munn 2017-01-06 15:20:20 UTC
couple of notes whilst they're in my head

1. XAP is, unfortunately, discontinued. There are various reasons, notably cost at the time and that google's emulators are much faster now. I don't know how much traction you will get with the bug you reported given that it's for a third party emulator, that emulator is discontinued and that HaxM is made by Intel.

2. The bug with XS sometimes thinking that the emulator is no longer running is because the communication link between ADB and XS gets interrupted and ADB doesn't always reconnect correctly. We've spent a lot of time messing about with ADB, and unfortunately again, it's just a little flakey from time to time.

3. this is interesting.

> when I ran from terminal it looks like it gets stuck after "found devices" running shell "getprop ro.build.version.sdk"

I didn't realise that the UpdateAndroidResources target interacted with ADB at all. I'm going to hand this to the XA team to see what they make of it. In the meantime, I know that they will ask for a diagnostic output, so, from Terminal again can you do the same command but this time with

> xbuild /p:DesignTimeBuild=true /t:UpdateAndroidResources /v:diag

I probably should have asked for that earlier.


Cheers
Comment 5 Tzach Shabtay 2017-01-07 03:07:13 UTC
Created attachment 19122 [details]
Terminal diag output
Comment 6 Tzach Shabtay 2017-01-07 03:07:38 UTC
1. Yes, I'm very much aware of XAP being discontinued (which is why I downloaded HAXM in the first place), I'm guessing that the HAXM bug is not just about conflicting with XAP, but with other emulators as well. I just gave it as an example of a reliable repro.

2. Well, the bug you are talking about is annoying without a doubt, though that's not the same bug I was talking about. My bug has nothing to do with ADB, it's about XS defaulting to an old emulator and not remembering the last emulator I've been using.

3. Terminal output with diag was attached.