microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6k stars 2.12k forks source link

Can not debug Hololens UWP-Applications #1398

Closed brean closed 6 years ago

brean commented 6 years ago

Overview

My Hololens/MRTK-Applications are crashing and the output is not showing why, I am also not seeing any debug log. This might be a bug in Unity and/or Visual Studio.

Expected Behavior

Visual Studio should show the exact position the Code and the full log of the stacktrace.

Actual Behavior

The Program is compiled and run as Unity-UWP-Project from Visual Studio. When an error occurs I see the error message "A debugger is attached to .exe but not configured to debug this unhandled exception".

Steps to reproduce

create a new Unity-Project copy the Mixed Reality Project into it, use the build Menu to add all MR and UWP settings and add a script that has an runtime error to your scene. Build the app from File > Build settings as unity project, activate the "Unity C# Projects" and "Development build". After building open the Project with Visual Studio and run it as "Debug", "x86" on your Local Machine

Unity Editor Version

2017.2.0f3

UWP-SDK Version

10.0.16299.0

Visual Studio Version

15.4.0 (Community 2017)

Mixed Reality Toolkit Release Version

current master https://github.com/Microsoft/MixedRealityToolkit-Unity/commit/2c59d07b574cbde904b7ad6bd2e249438597440d

samharper94 commented 6 years ago

For HoloLens apps, you need to run "Release", "x86", on Remote Machine and Run without Debugging (Ctrl+F5)

brean commented 6 years ago

@samharper94 I want to debug my code to see why my app crashed, so "Release" build is not an option for me and I can not run it as remote without a remote device. Without the debugger it can be very frustrating/impossible finding some bugs.

Running the app locally on my notebook worked with older Unity Versions and UWP 15xxx, but since the update to the current Unity Version with the latest UWP and the Windows-Fall Creators update it does not work anymore. Because I updated everything in one session I don't know what exactly broke this functionality.

brean commented 6 years ago

I think I got it now! There is not only my bug but also the known bug #1369 . The last message I see in the output log before the app crashes is "Main camera not found". When I delete all the new HolographicSettings.IsDisplayOpaque-calls and comment out large parts of the BoundaryManager and MixedRealityCameraManager it works, Visual Studio shows the Debugger as expected. I think when #1369 is fixed we can also close this issue.

Is there already a (beta?) Unity Version I can test/install where this bug is fixed?

ivan2007 commented 6 years ago

I have a similar problem with Immersive HMD. I can start the debug from visual studio only the first time and I can't set the breakpoints. After the first time the application always crashes. At the moment the only way to debug my app is to start from unity and then 'Attach Unity Debugger' from Visual Studio.

keveleigh commented 6 years ago

@brean the MRTP builds don't have this issue. The latest is MRTP4, found here: http://beta.unity3d.com/download/b1565bfe4a0c/download.html

ivan2007 commented 6 years ago

In my case I am using the latest MRTP4. I have this exception: image With this correction I can start the app: image In any case I am not able to set breakpoints. The symbols for the main process and the dll (Assembly-CSharp) are loaded but the breakpoints are disabled: image

brean commented 6 years ago

@keveleigh thank you for the links but that Unity version made things even worse for me. I still have the "No main Camera"-Error in the debugger and when I try to start the game in the Unity Editor by pressing the play button the whole Editor crashes.

keveleigh commented 6 years ago

@brean: Do you have an HMD attached to your machine? If not, Unity will crash. #1008 I'm unable to repro the No main camera error anywhere.

@ivan2007: Which version of the Toolkit are you using? That should have been fixed in #1196.

ivan2007 commented 6 years ago

@keveleigh I am using the latest release v1.2017.2.0

brean commented 6 years ago

Ah, I wasn't aware I need to plug in a Headset. I don't have one of the newer HMDs, connecting a Hololens does not work I assume... So I will wait for Unity to fix the "No Main Camera"-Bug and in the meantime switch between the MRTK-camera and controls and default Unity FPS-camera as workaround for debugging when I do not have access to the Hololens.

keveleigh commented 6 years ago

@ivan2007 Looks like the fix I linked above came after that release. Unfortunately, that has since been discovered to be a pretty buggy release...

@brean Ahh yes, unfortunately. I'm not sure the status of the crashing bug fix, but I'll try to get an update on it.

ivan2007 commented 6 years ago

Thank you keveleigh I tried with the latest master branch and now I can run the app from visual studio without errors (so the fix is ok). I noticed that now all is more fluid, memory usage is about 300 MB while before was at least about 1 GB. I still have the problems about breakpoints. I can set them only on some lines. It seems like there is a misaligment between the pdb symbols and the source code. Any idea about this? Thank you Ivan

brean commented 6 years ago

I got an answer from Unity support: "We have been able to reproduce this bug and have sent it for resolution with our developers. You can easily workaround this bug. Your machine's Windows settings are not set to Developer Mode. Windows ==> Settings ==> Updates & Security ==> for developers After you can need to setup a mixed reality portal for simulation." So I think we can close this issue?

brean commented 6 years ago

Looks like its fixed in 2017.3. The Unity-UWP-App stops nicely when I set a breakpoint. So I close this now.

StephenHodgson commented 6 years ago

Let's close this when we merge the editor update