This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 43566 - iOS Designer initialization causes any already running iOS 10 simulator to hang
Summary: iOS Designer initialization causes any already running iOS 10 simulator to hang
Status: CONFIRMED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: iOS Designer (show other bugs)
Version: 6.1.0 (C8)
Hardware: PC All
: High normal
Target Milestone: master
Assignee: Alex Corrado
URL:
Depends on:
Blocks:
 
Reported: 2016-08-21 01:33 UTC by Brendan Zagaeski (Xamarin Support)
Modified: 2016-11-09 11:52 UTC (History)
10 users (show)

See Also:
Tags: potentialC8SR2
Is this bug a regression?: No
Last known good build:


Attachments
Hung Simulator process sample from Activity Monitor (46.84 KB, text/plain)
2016-08-21 01:33 UTC, Brendan Zagaeski (Xamarin Support)
Details
Xamarin Studio log files (2.63 KB, application/zip)
2016-08-21 01:35 UTC, Brendan Zagaeski (Xamarin Support)
Details

Description Brendan Zagaeski (Xamarin Support) 2016-08-21 01:33:54 UTC
Created attachment 17143 [details]
Hung Simulator process sample from Activity Monitor

[Cycle 8 Beta] iOS Designer initialization causes any already running iOS 10 simulator to hang, (get stuck, freeze, become non-responsive)




## Regression status: new incompatibility with Xcode 8 that was not a problem with Xcode 7.3

BAD:  Cycle 8 Beta + Xcode 8,   iOS 10  simulator
GOOD: Cycle 8 Beta + Xcode 7.3, iOS 9.3 simulator




## Steps to replicate


1. Install Xcode 8 Beta 5, and run it once to allow it to set itself up.


2. Open the Cycle 8 Beta version of Xamarin Studio and set "Xamarin Studio > Preferences > Projects > SDK Locations > Apple > Apple SDK > Location" to point to the beta version of Xcode.  For example, in my case:

/Applications/Xcode-beta.app


3. Open Xcode and select "Xcode > Open Developer Tool > Simulator" to start up the iOS 10 simulator (I tested with the "iPhone 6s Plus" configuration).  Wait until the simulator has launched and you are able to navigate around the home screen.


4. Go back to Xamarin Studio, open an existing project that was created via "iOS > App > Single View App", or create a new project using that template.


5. After the project loads in Xamarin Studio, return to the iOS simulator and attempt to navigate on the home screen by swiping left and right.




## Alternate way to replicate that more clearly highlights the involvement of the iOS Designer

At step 4, instead of opening a project in Xamarin Studio, instead run the `Designer.exe` agent that is used by Xamarin for Visual Studio:

mono64 "$HOME/Library/Caches/Xamarin/XMA/Agents/Designer/4.2.0.508/Designer.exe"


(The agent will quit when it fails to establish a connection, but it will still "successfully" causes the iOS simulator to freeze before then.)




## Results

The iOS 10 simulator is frozen and does not respond to any user input.

(See also the attached process sample of the simulator taken via Activity Monitor while in this frozen state.)




## Additional version info (brief)

Xamarin Studio 6.1 (build 5345)

Mono 4.6.0 (mono-4.6.0-branch/d0fc1a6)

Xcode 8.0 (11239.2), Build 8S201h

OS X 10.11.6
Comment 1 Brendan Zagaeski (Xamarin Support) 2016-08-21 01:35:23 UTC
Created attachment 17144 [details]
Xamarin Studio log files
Comment 2 Alan McGovern 2016-08-25 15:42:38 UTC
This is unlikely to be something we can affect
Comment 3 Alan McGovern 2016-08-25 15:49:37 UTC
Marking as low/minor as there is a trivial workaround - restart the sim.

Apple broke a lot of stuff with the sim this time round and it is much less stable than it used to be. This is towards the bottom of the list of things we need to look at
Comment 4 Brendan Zagaeski (Xamarin Support) 2016-09-01 06:34:35 UTC
One potential complication is whether Xamarin might need to switch around the failure mode to be a good citizen: rather than causing the simulator to become unresponsive, perhaps the designer could semi-gracefully refuse to initialize if the iOS 10 simulator is currently running.

There are some pros and cons either way from a perspective of "least surprise" for a user, but perhaps the "good citizen" consideration is enough to tip the balance slightly in favor of changing the failure mode.




## Possible adjustments for Cycle 8

For expediency for now, maybe it would be possible to do something similar to the following:



- Check if the iOS 10 simulator is running at each of the following times:

(a) During iOS project load in Xamarin Studio (when the designer normally initializes)

(b) During the build host connection from Visual Studio (when the `Designer.exe` process is starting up)

(c) When attempting to open a storyboard in Xamarin Studio



- If the iOS 10 simulator is running, cancel the designer initialization and output an error message in the IDE log file similar to the following:

> Initialization of the designer service has been aborted to avoid
> interfering with a running iOS 10 simulator.  If use of the designer
> service is desired, please quit the iOS 10 simulator and retry.  As
> soon as the designer service is initialized, the iOS 10 simulator can
> safely be relaunched.


- Additionally, if the error happens during (c) (when attempting to explicitly open a storyboard in Xamarin Studio), perhaps the error message can also be shown in the "standard" error dialog box within the designer surface.



### Potential complications


- If the new logic to detect the run state of iOS 10 simulator is sometimes incorrect (e.g., it thinks the iOS 10 simulator is running when it's not), then aborting the designer initialization based on that logic could block users from being able to use the designer at all.  And the error message would be frustratingly inaccurate in that case.


- The error message would potentially be a bit confusing to users because starting up the designer service is not something the user usually does directly.  It's also tricky to convey in only a few words that the conflict is only a problem during _initialization_, and that it's fine to start the iOS 10 simulator after that.  One of the problems is that the error message inevitably has to briefly teach the user that the designer has a distinct initialization phase that is separate from the normal usage phase.




## Possible further enhancements for Cycle 8 – Service Release 1 or later

One possible idea to combat the potential complications of a raw error message could be to display a dialog message instead.  The dialog could say something like:


> The designer service detected a running iOS 10 simulator during
> initialization.  Continuing with the initialization would likely cause the
> simulator to become non-responsive, so you would need to quit and restart the
> simulator after the designer service starts.
>  
> Please choose how to proceed:
> 
> ( ) Quit the iOS 10 simulator for me and then restart it after the designer
>     service is initialized.
> 
> ( ) Leave the iOS 10 simulator running _and_ start the designer service.
> 
> ( ) Cancel starting the designer service.
> 
> 
> ( ) Remember this option for next time.
> 
> (OK) (Cancel)
Comment 7 Alan McGovern 2016-09-01 10:38:30 UTC
Adding detection for a running simulator is tricky for the visual studio case. We have to round trip from windows to mac before initialising the designer just to check its running. I suspect that any change would have to happen for the next service release. It's too big a change to rush this week.

We can review it when the GM is released. If it ends up being a common problem we could add a temporary notice when starting the designer or forms previewer.
Comment 10 Luis Aguilera 2016-09-12 20:20:24 UTC
since C8 is now closed, and is shipping this week, I will move this but to the C8SR1 milestone. We'll continue working on the issue seeking it's resolution as soon as possible.
Comment 13 xamarin-release-manager 2016-09-15 10:12:42 UTC
Fixed in version 6.2.0.492 (master)

Author: Alan McGovern
Commit: 626ce66504b019adeca29fc4b6374a0b2cc14812 (xamarin/ios-sim-sharp)
Included in Commit: b81325eef8adf74178c7465ce4ea9979a558ba09 (mono/monodevelop)
Comment 14 xamarin-release-manager 2016-09-15 10:13:07 UTC
Fixed in version 6.1.0.5442 (cycle8)

Author: Alan McGovern
Commit: 626ce66504b019adeca29fc4b6374a0b2cc14812 (xamarin/ios-sim-sharp)
Included in Commit: d3e6b3050a54e805ad4d8f0f2ba53d1afd1e7e3a (mono/monodevelop)
Comment 15 Alan McGovern 2016-09-15 10:15:58 UTC
This has been mitigated to make it less frequent, but not completely resolved.
Comment 16 Luis Aguilera 2016-09-15 15:52:32 UTC
I'm marking this as resolved/fixed so we can test the mitigation that @Alan describes in the trello card:

"A mitigation to make the reset less frequent has been added to master and C8.

The full fix (never having to reset the services) falls outside the scope of SR0. We'll leave the bug open until we can properly resolve it."

We will track the full fix in bug 44373
Comment 17 Alan McGovern 2016-09-15 17:03:15 UTC
lets do it the other way around. This has all the info i need. Let's use 44373 to verify the mitigation :)
Comment 18 Ben Beckley 2016-10-20 20:06:04 UTC
44373 has been verified as fixed. Would this then also be considered fixed as per my understanding of comment 17?

Note You need to log in before you can comment on or make changes to this bug.