UWP Crash when using Dissonance
Does this affect the legacy HoloToolkit (master) or the Mixed Reality Toolkit (mrtk_release)? HoloToolkit
Describe the bug When Dissonance is in the project (not always apparently, can't seem to reproduce in an empty project), the UWP app will crash STRAIGHT away when joining an online scene. The actual error is as follows:
"TypeLoadException: Unresolved P/Invoke method 'opus_encoder_create!opus' in assembly 'Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' because it is not available in UWP applications. Please either use an another API , or use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP application APIs.
at Dissonance.Audio.Codecs.Opus.OpusNative.OpusEncoder..ctor(Int32 srcSamplingRate, Int32 srcChannelCount)
at Dissonance.CodecSettingsLoader.CreateEncoder(AudioQuality quality, FrameSize frameSize, Boolean fec)
at Dissonance.CodecSettingsLoader.Generate()
at Dissonance.DissonanceComms.Start()
at Dissonance.DissonanceComms.$Invoke65(Int64 instance, Int64 args)
at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64 args, IntPtr method)"
Now I tried to add ExactSpelling=true to the DllImport, but when I built that time, it would crash the game straight away saying it couldn't find the Dll.
To Reproduce I cannot seem to reproduce it in an empty project and unfortunately, I can't supply the actual project due to confidentiality reasons.
Expected behavior Not crash when joining a game.
Actual behavior Crashes straight away when joining an online scene.
Unity Editor Version 2017.2.0p2-MRTP5
Mixed Reality Toolkit Release Version I'm not actually sure how to find this out... It's been over a year since we imported it and it was the first version to work with MRTP5... Have not updated since
Additional context Dissonance Issue
Are you building to IL2CPP or .NET?
.NET
4.6 Experimental
Does this crash without HTK in a project?
I don't know. Unfortunetly, I need to have HTK in there due to the entire game (which is virtually complete) being a VR project. And as I said... I can't seem to reproduce in an empty project with or without MRTK
I was asked by the developer of Dissonance to open this issue
The callstack doesn't seem to indicate an issue from the MRTK, but I'll look through your issue over on their repo to see if I can pinpoint a problem.
Thank you. The thing I find most bizarre is that I can't reproduce it in any way in any project other than the basically complete one.
Question: Is there a way to check what version of MRTK I am using?
It should be in the root folder of the assets. try searching for version or MRTKVersion
Dissonance dev here. The problem is happening on this line:
var encoder = OpusNativeMethods.opus_encoder_create(srcSamplingRate, srcChannelCount, (int)Application.Voip, out error);
Which is calling out to this external method:
[DllImport("opus", CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr opus_encoder_create(int samplingRate, int channels, int application, out int error);
JamesMillsDev tried adding ExactSpelling=true as suggested by the initial error message and that changed the error to DLL not found (still occurring in the same place). We have a few other devs using Dissonance on hololens and other mixed reality headsets without this issue so it's something in some way specific to this project.
Actually Martin, it isn't happening in the same place... it now just happens the moment the game runs... in fact... it doesn't run
Ah, sorry. So just to check I've got it straight: it happens on that line without ExactSpelling, and happens immediately on application launch after the change?
Yes
@JamesMillsDev did some more testing on this issue (full details over on https://github.com/Placeholder-Software/Dissonance/issues/103#issuecomment-424541549). Dissonance contains two DLLs so I suggested that he try calling a method in the other DLL to see if it produces the same error - it does not! My best guess is there is some kind of difference between how these DLLs are compiled which causes opus.dll to crash when called but makes AudioPluginDissonance.dll ok when called.
Do you have any suggestions for build settings which may affect this? Once I have some suggestions I can compare the two build configurations and see if there are any relevant differences.
If you're trying to call a native plugin from another native plugin, they need to be in the same plugin folder.
Nothing that complicated. This is just 2 DLLs: calling one from C# causes the error mentioned above (unresolved method, advises using ExactSpelling=true), calling the other from C# seems to cause no problems at all.
Closing issues older than 180 days. If this is still an issue, please reactivate with recent information.