Bug 54672

Summary: Windows iOS Simulator Crashes
Product: Windows iOS Simulator Reporter: Brandon Hartman <brandon.hartman>
Component: SimulatorAssignee: Bugzilla <bugzilla>
Status: VERIFIED FIXED    
Severity: normal CC: brendan.zagaeski, dan.rigby, Daniel.Regner, eric.maupin, harun, luis.aguilera, simulator
Priority: ---    
Version: 1.0   
Target Milestone: 15.2   
Hardware: PC   
OS: Windows   
Tags: 15.1R Is this bug a regression?: ---
Last known good build:
Attachments: Simulator Log

Description Brandon Hartman 2017-04-06 21:06:15 UTC
Created attachment 21281 [details]
Simulator Log

Version 1.0.1.94 (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.0.2.7  [1] on Windows 8.1, with .NET Framework 4.6.1
> BAD:  Remoted iOS Simulator 1.0.1.94 [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 1.0.2.2, 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 1.0.2.7).  But users who don't mind installing .NET 4.6.2 can use the Alpha Remoted iOS Simulator 1.0.2.2 to resolve this crash.



> GOOD: Remoted iOS Simulator 1.0.2.2  [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 4.4.0.34 (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 10.8.0.175 (d15-1: a04678c2)
Mono 5.0.0.48 (2017-02/851b6c7)

Xcode 8.3, Build version 8E162

Mac OS 10.12.4
US English locale, US Eastern time zone