Placeholder-Software / Dissonance

Unity Voice Chat Asset
69 stars 5 forks source link

[Bug] BasePreprocessingPipeline: Error: Unhandled exception killed audio preprocessor thread: System.EntryPointNotFoundException: Dissonance_CreateRnnoiseState #239

Closed vollstock closed 2 years ago

vollstock commented 2 years ago

Context

Following this guide, I have included Dissonance in our Project.

Behavior

After starting a Host, no Audio is being captured (or at least I can’t hear anything on other instances of the game). An error message is printed and then subsequently many, many warnings.

Bildschirmfoto 2021-09-22 um 12 07 51

Tries and thoughts

Microsofts docs on an EntryPointNotFoundException suggest I can't load a DLL.

I have tried to delete and re-install the Plugins folder as suggested in #207, though. Will try on Windows later today…

Error message

[Dissonance:Recording] (09:59:16.417) BasePreprocessingPipeline: Error: Unhandled exception killed audio preprocessor thread: System.EntryPointNotFoundException: Dissonance_CreateRnnoiseState

[Dissonance:Recording] (09:59:16.417) BasePreprocessingPipeline: Error: Unhandled exception killed audio preprocessor thread: System.EntryPointNotFoundException: Dissonance_CreateRnnoiseState
  at (wrapper managed-to-native) Dissonance.Audio.Capture.AudioPluginDissonanceNative.Dissonance_CreateRnnoiseState()
  at Dissonance.Audio.Capture.WebRtcPreprocessingPipeline+RnnoisePreprocessor.Reset () [0x0004c] in /Users/vollstock/Arbeit/Projekte/VR-Theater/Software/VR Theater/Assets/Plugins/Dissonance/Core/Audio/Capture/WebRtcPreprocessingPipeline.cs:481 
  at Dissonance.Audio.Capture.WebRtcPreprocessingPipeline.ApplyReset () [0x00027] in /Users/vollstock/Arbeit/Projekte/VR-Theater/Software/VR Theater/Assets/Plugins/Dissonance/Core/Audio/Capture/WebRtcPreprocessingPipeline.cs:71 
  at Dissonance.Audio.Capture.BasePreprocessingPipeline.ThreadEntry () [0x00009] in /Users/vollstock/Arbeit/Projekte/VR-Theater/Software/VR Theater/Assets/Plugins/Dissonance/Core/Audio/Capture/BasePreprocessingPipeline.cs:224 ! This is probably a bug in Dissonance, we're sorry! Please report the bug on the issue tracker "https://github.com/Placeholder-Software/Dissonance/issues". You could also seek help on the community at "http://placeholder-software.co.uk/dissonance/community" to get help for a temporary workaround. Error ID: 02EB75C0-1E12-4109-BFD2-64645C14BD5F
UnityEngine.Debug:LogError (object)
Dissonance.Logs/LogMessage:Log () (at Assets/Plugins/Dissonance/Core/Log.cs:69)
Dissonance.Logs:WriteMultithreadedLogs () (at Assets/Plugins/Dissonance/Core/Log.cs:87)
Dissonance.Editor.Windows.Startup:Update () (at Assets/Plugins/Dissonance/Editor/Windows/Startup.cs:33)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions () (at /Users/bokken/buildslave/unity/build/Editor/Mono/EditorApplication.cs:327)

Subsequent warnings

[Dissonance:Recording] (09:59:16.693) BasePreprocessingPipeline: Lost 960 samples in the preprocessor (buffer full), injecting silence to compensate

[Dissonance:Recording] (09:59:16.693) BasePreprocessingPipeline: Lost 960 samples in the preprocessor (buffer full), injecting silence to compensate
UnityEngine.Debug:LogWarning (object)
Dissonance.Logs/LogMessage:Log () (at Assets/Plugins/Dissonance/Core/Log.cs:66)
Dissonance.Logs:SendLogMessage (string,Dissonance.LogLevel) (at Assets/Plugins/Dissonance/Core/Log.cs:98)
Dissonance.Log:WriteLog (Dissonance.LogLevel,string) (at Assets/Plugins/Dissonance/Core/Log.cs:181)
Dissonance.Log:WriteLogFormat<int> (Dissonance.LogLevel,string,int) (at Assets/Plugins/Dissonance/Core/Log.cs:190)
Dissonance.Log:Warn<int> (string,int) (at Assets/Plugins/Dissonance/Core/Log.cs:393)
Dissonance.Audio.Capture.BasePreprocessingPipeline:Dissonance.Audio.Capture.IMicrophoneSubscriber.ReceiveMicrophoneData (System.ArraySegment`1<single>,NAudio.Wave.WaveFormat) (at Assets/Plugins/Dissonance/Core/Audio/Capture/BasePreprocessingPipeline.cs:189)
Dissonance.Audio.Capture.BasicMicrophoneCapture:SendFrame () (at Assets/Plugins/Dissonance/Core/Audio/Capture/BasicMicrophoneCapture.cs:409)
Dissonance.Audio.Capture.BasicMicrophoneCapture:ConsumeSamples (System.ArraySegment`1<single>) (at Assets/Plugins/Dissonance/Core/Audio/Capture/BasicMicrophoneCapture.cs:367)
Dissonance.Audio.Capture.BasicMicrophoneCapture:DrainMicSamples () (at Assets/Plugins/Dissonance/Core/Audio/Capture/BasicMicrophoneCapture.cs:339)
Dissonance.Audio.Capture.BasicMicrophoneCapture:UpdateSubscribers () (at Assets/Plugins/Dissonance/Core/Audio/Capture/BasicMicrophoneCapture.cs:273)
Dissonance.Audio.Capture.CapturePipelineManager:Update (bool,single) (at Assets/Plugins/Dissonance/Core/Audio/Capture/CapturePipelineManager.cs:199)
Dissonance.DissonanceComms:Update () (at Assets/Plugins/Dissonance/Core/DissonanceCommsImpl.cs:683)

My Environment

martindevans commented 2 years ago

The System.EntryPointNotFoundException doesn't mean that the DLL can't be loaded (you'd get something like a DllNotFoundException if that were the case). Instead it means that a particular method call in the DLL does not exist, in this case Dissonance_CreateRnnoiseState. All of the following warnings about "lost samples" are just a consequence of the first error, so once we fix that they should disappear.

On MacOS the Dissonance_CreateRnnoiseState method does not exist in the native plugin because that feature is not yet supported on MacOS. You should be protected from the EntryPointNotFoundException happening by some #if checks which swap in some other code on non-supported platforms.

Could you check in Assets\Plugins\Dissonance\Core\Audio\Capture\AudioPluginDissonanceNative.cs on line 26, you should find this:

#region rnnoise
    #if UNITY_EDITOR_WIN || (UNITY_STANDALONE_WIN && !UNITY_WSA) || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX || UNITY_ANDROID || UNITY_LUMIN
        [DllImport(ImportString, CallingConvention = Convention)]
        public static extern IntPtr Dissonance_CreateRnnoiseState();

        // ... <trimmed some more code here> ...
    #else
        private static bool _rnnoiseWarning = false;

        public static IntPtr Dissonance_CreateRnnoiseState()
        {
            if (!_rnnoiseWarning)
            {
                Log.Warn("Rnnoise is not supported on this platform");
                _rnnoiseWarning = true;
            }

            return new IntPtr(1);
        }

As you can see we've got a list of supported platforms at the top which does not include MacOS, so it should be calling into the C# code which simply prints a warning. Does yours look different?

vollstock commented 2 years ago

no, mine looks the same. Indeed if I temporarily replace this line with

#if false //|| UNITY_EDITOR_WIN || (UNITY_STANDALONE_WIN && !UNITY_WSA) || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX || UNITY_ANDROID || UNITY_LUMIN

it works. I don't quite know, why i run into this on my machine…

martindevans commented 2 years ago

Could you try adding in the terms one-by-one to see which one is enabling that block?

vollstock commented 2 years ago

Unfortunately those compile-time directives are truedepending on my build settings. See comment here I am developing on a Mac but I am targeting Linux (the server) and Android (a VR headset).

UNITY_ANDROID is true if I set Android as target platform in the build settings UNITY_EDITOR_LINUX is truewhen I set Linux as target platform

A working line for me is e.g.

#if !UNITY_EDITOR_OSX && (UNITY_EDITOR_WIN || (UNITY_STANDALONE_WIN && !UNITY_WSA) || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX || UNITY_ANDROID || UNITY_LUMIN)

as the UNITY_EDITOR* directives are not evaluated at compile time

martindevans commented 2 years ago

Aha! Yes you're absolutely right, I didn't consider that case properly.

I'll either change it to this for the next version:

#if (!UNITY_EDITOR_OSX) && (UNITY_EDITOR_WIN || (UNITY_STANDALONE_WIN && !UNITY_WSA) || UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX || UNITY_ANDROID)

Or I'll compile RNNoise support into the MacOS plugins.

(Nb.UNITY_LUMIN is intentinally missing from that line).

vollstock commented 2 years ago

This line works fine for me :-) Don't need noise suppression on my dev-machine

Thanks!

martindevans commented 2 years ago

Don't need noise suppression on my dev-machine

Fortunately disabling this on your dev machine doesn't totally remove noise suppression!

The basic noise suppression which removes "pure" noise (e.g. fans) works on all platforms. That's actually the most important one since almost all audio setups will have some static in them (unless you're developing in a recording studio!).

RNNoise is a new system which uses a machine learning system to detect background sounds (e.g. someone talking in the background, dogs barking) and removes them. Since the process of background sound removal can distort voice this is only something you'd want to use in very noisy environments (e.g. mobile game where players are in busy environments, VR exercise game where the player will be breathing heavily).

You can read more about these systems and the tradeoffs involved here: https://placeholder-software.co.uk/dissonance/docs/Reference/Other/VoiceSettings.html#noise-suppression

martindevans commented 2 years ago

This was released a while ago!