Bug 54672 - Windows iOS Simulator Crashes
Summary: Windows iOS Simulator Crashes
Alias: None
Product: Windows iOS Simulator
Classification: Xamarin
Component: Simulator ()
Version: 1.0
Hardware: PC Windows
: --- normal
Target Milestone: 15.2
Assignee: Bugzilla
: 54805 ()
Depends on:
Reported: 2017-04-06 21:06 UTC by Brandon Hartman
Modified: 2017-04-13 19:43 UTC (History)
7 users (show)

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

Simulator Log (4.65 KB, text/plain)
2017-04-06 21:06 UTC, Brandon Hartman

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 Brandon Hartman 2017-04-06 21:06:15 UTC
Created attachment 21281 [details]
Simulator Log

Version (Windows 7 64-bit; VS2015 Enterprise)

After the latest version the simulator crashes at startup. 
I tried resizing the simulator window as it was loading but it still crashes.
Comment 1 Daniel R. Regner 2017-04-06 22:00:50 UTC
I hit what I believe to be the same issue (with a similar log file showing a zero scaling factor) and worked-around it by monkey-patching the DpiAwareWindow class in Xamarin.Simulator.Windows.exe (using Reflexil and ILSpy) to hard-code the scaling factor to 1.0 (knowing that this loses high-DPI-awareness).

Original Xamarin.Simulator.Windows.DpiAwareWindow.get_ScaleX():
> ldarg.0
> ldfld float64 Xamarin.Simulator.Windows.DpiAwareWindow::scaleX
> ret

Original Xamarin.Simulator.Windows.DpiAwareWindow.get_ScaleY()
> ldarg.0
> ldfld float64 Xamarin.Simulator.Windows.DpiAwareWindow::scaleY
> ret

Temporary replacement IL for both property accessors (a hard-coded 1.0 scale factor):
> ldc.r8 1
> ret
Comment 2 Eric Maupin 2017-04-07 16:16:46 UTC
This has been switched to a more reliable setup in 1.0.2, it should be fixed.
Comment 3 Eric Maupin 2017-04-07 21:27:10 UTC
*** Bug 54805 has been marked as a duplicate of this bug. ***
Comment 4 Brendan Zagaeski (Xamarin Team, assistant) 2017-04-12 03:30:02 UTC
## Verification status: VERIFIED in candidate build (2e6d296)

> GOOD: Remoted iOS Simulator  [1] on Windows 8.1, with .NET Framework 4.6.1
> BAD:  Remoted iOS Simulator [2] on Windows 8.1, with .NET Framework 4.6.1

[1] Not yet published candidate build (2e6d296)
[2] The current version in the Xamarin Stable Channel and in the VS 2017 15.1 installer

Crash rate in the BAD version:  100% (4/4 trials)
Crash rate in the GOOD version:   0% (0/4 trials)

## Also VERIFIED in Alpha Remoted iOS Simulator, for users who already have (or don't mind installing) .NET 4.6.2

The current Alpha version requires .NET 4.6.2.  This version requirement will be adjusted back to .NET 4.6.1 in future published builds (as noted above for the candidate build  But users who don't mind installing .NET 4.6.2 can use the Alpha Remoted iOS Simulator to resolve this crash.

> GOOD: Remoted iOS Simulator  [3] on Windows 8.1, with .NET Framework 4.6.2 (4.0.16590)

Crash rate:                       0% (0/4 trials)

[3] The current version in the Xamarin Alpha Channel, not yet included in the VS 2017 installer

### Installing .NET 4.6.2

During the first run, the simulator presented the following dialog:

> This application requires one of the following versions of the .NET Framework:
>  .NETFramework,Version=v4.6.2
> Do you want to install this .NET Framework version now?
> [Yes] [No]
I clicked "Yes".  I then proceeded to quit Visual Studio, download the installer from the browser window, and run the installer.

## Excerpt of the Xamarin.Simulator.Windows.exe crash from "Windows Logs > Application" section of the Windows "Event Viewer"

> Application: Xamarin.Simulator.Windows.exe
> Framework Version: v4.0.30319
> Description: The process was terminated due to an unhandled exception.
> Exception Info: System.ArgumentException
>    at System.Windows.Size..ctor(Double, Double)
>    at Xamarin.Simulator.Windows.DeviceWindow.SizeForScreen()
>    at Xamarin.Simulator.Windows.DeviceWindow.OnSourceInitialized(System.EventArgs)
>    at System.Windows.Window.CreateSourceWindow(Boolean)
>    at System.Windows.Window.CreateSourceWindowDuringShow()
>    at System.Windows.Window.SafeCreateWindowDuringShow()
>    at System.Windows.Window.ShowHelper(System.Object)
>    at System.Windows.Window.Show()
>    at Xamarin.Simulator.Windows.App+<StartDevice>d__15.MoveNext()

## Additional testing environment info

### Windows

Microsoft Visual Studio Enterprise 2017

XamarinVS (3f99c5a)

Microsoft .NET Framework 4.6.1
Version 4.6.01055

Windows 8.1 (64-bit) version 6.3 (Build 9600)
US English locale, US Pacific time zone

Running in Hyper-V, in a Windows 10 (64-bit) version 1607 (OS Build 14393.321) host

### Mac

Xamarin.iOS (d15-1: a04678c2)
Mono (2017-02/851b6c7)

Xcode 8.3, Build version 8E162

Mac OS 10.12.4
US English locale, US Eastern time zone