Placeholder-Software / Dissonance

Unity Voice Chat Asset
70 stars 5 forks source link

[bug] Missing Opus.dll on Hololens #108

Closed ghost closed 6 years ago

ghost commented 6 years ago

Context

I cannot seem to test my app on the Hololens via Unity's holographic remoting tool as Dissonance requires the microphone, which does not seem to be supported via holographic remoting at this time. So instead I simply have to build the application for UWP in Unity, then open the solution in Visual Studio and deploy it to the Hololens in debug mode. However, the application crashes after only a few seconds and I get an error log about a missing Opus.dll. I did a bit of searching and based on the forum posts of other users experiencing the same issue, it seems that I have to include the Microsoft Visual C++ Redistributable for Visual Studio 2017 in the build on the hololens. However, I have no idea how to actually do this. Everything that I have found online suggests that I can include dependencies in my installer, however I am not using an installer as I am just deploying straight from Visual Studio to the device for debugging. Does anybody know how to fix this issue? Is there a way to manually install the redistributable package on the hololens somehow?

Expected Behavior

Dissonance should work correctly on the hololens without crashing.

Actual Behavior

Dissonance crashes after only a few seconds logging an error about a missing Opus.dll, which seems to be the result of a missing Microsoft Visual C++ Redistributable for Visual Studio 2017 on the hololens.

Workaround

N/A

Fix

Installing Microsoft Visual C++ Redistributable for Visual Studio 2017 on the hololens somehow?

Steps to Reproduce

  1. Import Dissonance into an empty project and set up a scene as per the HLAPI tutorial.
  2. In this scenario the host is the PC, and the client is the hololens.
  3. Create a script that auto connects as a client to your PC's host IP address. (This is a workaround for not being able to use the default network HUD on hololens. Alternatively, you could manually create a hololens friendly network HUD.)
  4. Change the build settings to UWP and build the solution.
  5. Open the solution in Visual Studio 2017 and deploy to the hololens in debug mode.
  6. Connect the PC as the host in the Unity editor and the hololens should automatically connect as the client. You can see it works as an extra player object is spawned in the Unity editor.
  7. A few seconds later the hololens will crash and an error log should appear in Visual Studio about the missing Opus.dll.

Your Environment

awonnink commented 6 years ago

Maybe the issue is just that you should build the project from Unity in a complete new folder, did you try that? I have seen similar issues being resolved this way.

ghost commented 6 years ago

Building the solution from Unity in a new folder outside of the Unity project directory seems to have worked. The missing packages now install automatically when I deploy to the device. However, I am now getting the following exception:

Exception thrown: 'System.BadImageFormatException' in Assembly-CSharp-firstpass.dll 'Voice Chat.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\Template3DVS.Debug_x86.fully\System.Diagnostics.StackTrace.dll'. Symbols loaded. BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) at Dissonance.Audio.Codecs.Opus.OpusNative.OpusNativeMethods.opus_encoder_create(Int32 samplingRate, Int32 channels, Int32 application, Int32& error) at Dissonance.Audio.Codecs.Opus.OpusNative.OpusEncoder..ctor(Int32 srcSamplingRate, Int32 srcChannelCount) at Dissonance.Audio.Codecs.Opus.OpusEncoder..ctor(AudioQuality quality, FrameSize frameSize, Boolean fec) at Dissonance.CodecSettingsLoader.CreateEncoder(AudioQuality quality, FrameSize frameSize, Boolean fec) at Dissonance.CodecSettingsLoader.Generate() at Dissonance.DissonanceComms.Start() at Dissonance.DissonanceComms.$Invoke65Start(Int64 instance, Int64 args) at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64 args, IntPtr method) (Filename: Line: 0)

Any advice?

================================ EDIT

Based on some more searching it looks like I need a 32 bit version of the dll files. Dissonance only seems to come with 64 bit versions...

martindevans commented 6 years ago

A BadImageFormatException means it's successfully found all of the dependencies of opus.dll but when loading something (either opus.dll or a depenency) it loaded something with the wrong format.

This could mean you're loading a file which is corrupted in some way. However I think that's fairly unlikely because a corrupted file would be more likely to fail at the previous stage (searching for dependencies, can't find the ones we're looking for in this file because it makes no sense). Of course it's always possible the headers are intact and the payload is corrupt. It's easy to check for that - navigate to the root Assets folder and run these commands in powershell, they should all return true:

//Verify that files exist
[System.IO.File]::Exists("Plugins/Dissonance/Plugins/UWP/x86/Opus.dll")
[System.IO.File]::Exists("Plugins/Dissonance/Plugins/UWP/x86_64/Opus.dll")

//Verify that they are intact
(get-filehash Plugins/Dissonance/Plugins/UWP/x86/Opus.dll).Hash -eq "B7D04E35E36A7E90196A386F8953BE1E6E356B723A2C0673B049E134C3A1E09E"
(get-filehash Plugins/Dissonance/Plugins/UWP/x86_64/Opus.dll).Hash -eq "B368FC64F3314C415BB26771F3BE1FCC7768ABB0AECB90FFE0061AC6E1C60425"

I would suggest finding the same files in your build output and checking the same hashes, to check that the right files have been exported.

Finally you should check that the settings are correct in Unity. They should look like this:

untitled
ghost commented 6 years ago

Yes thank you! It's working as expected now.

The issue was that the UWP folder under Plugins was completely missing from our project directory for some reason. I'm not sure why - we were using the latest version of Dissonance and importing it into a clean project and had not removed anything. In any case, manually re-importing Dissonance and making sure the UWP folder was selected solved the issue.

So to recap for anyone else experiencing the same issue:

1) Make sure the UWP folder under Plugins is present and configured as per the above image. 2) Build the solution in Unity into a new folder outside of the project directory.

Perhaps you could put a UWP section in the user manual if there isn't one already.

Cheers :-)

martindevans commented 6 years ago

Excellent, I'm glad to hear you've worked this out :D