Placeholder-Software / Dissonance

Unity Voice Chat Asset
71 stars 5 forks source link

BasePreprocessingPipeline: Error: Unhandled exception killed audio preprocessor #207

Closed davidbardos closed 3 years ago

davidbardos commented 4 years ago

I have just updated Dissonance to the latest 7.1.1. It randomly stops working from the editor after some time without really changing anything. If a remove the Dissonance asset and add it again it starts working again.

Windows 10 Unity 2019.4.10 Platform: Android Integration: Mirror LibNet

Error: [Dissonance:Recording] (14:52:54.759) BasePreprocessingPipeline: Error: Unhandled exception killed audio preprocessor thread: Dissonance.DissonanceException: Error: Cannot associate preprocessor with Playback filter - one already exists! 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: D5862DD2-B44E-4605-8D1C-29DD2C72A70C at Dissonance.Audio.Capture.WebRtcPreprocessingPipeline+WebRtcPreprocessor.SetFilterPreprocessor (System.IntPtr preprocessor) [0x0005e] in F:\Projects\Univrse\Univrse-Core\Assets\Plugins\Dissonance\Core\Audio\Capture\WebRtcPreprocessingPipeline.cs:377 at Dissonance.Audio.Capture.WebRtcPreprocessingPipeline+WebRtcPreprocessor.Reset () [0x00061] in F:\Projects\Univrse\Univrse-Core\Assets\Plugins\Dissonance\Core\Audio\Capture\WebRtcPreprocessingPipeline.cs:329 at Dissonance.Audio.Capture.WebRtcPreprocessingPipeline.ApplyReset () [0x0000e] in F:\Projects\Univrse\Univrse-Core\Assets\Plugins\Dissonance\Core\Audio\Capture\WebRtcPreprocessingPipeline.cs:64 at Dissonance.Audio.Capture.BasePreprocessingPipeline.ThreadEntry () [0x00009] in F:\Projects\Univrse\Univrse-Core\Assets\Plugins\Dissonance\Core\Audio\Capture\BasePreprocessingPipeline.cs:227 ! 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

martindevans commented 4 years ago

A few people have reported this issue to me, but unfortunately I haven't been able to track down an exact cause yet.

The following process has worked for some people:

  1. Close Unity editor
  2. Delete Assets/Plugins/Dissonance/Plugins
  3. Open Unity editor
  4. Reinstall Dissonance from the asset store

In the past we have had problems with the asset store delivering out of date/corrupted binary plugins. So that could be the root problem here. However, if you have any other indicators of what might cause the problem (or a reliable reproduction) please do give me the details, thanks.

davidbardos commented 4 years ago

Thanks @martindevans for the quick response! This workaround indeed works. It is a bit annoying as it happens too often, multiple times a day. Do you think upgrading to Unity 2020 might fix it?

As it happens randomly without changing anything related in Unity, it is hard to give you hints unfortunately.

martindevans commented 4 years ago

To be clear you only need to reinstall the binaries once - that has completely fixed it for some people! If that's not fixing it there's no need to do it again. You do need to restart the editor to clear the error though (the root problem here is some global state being left in the Unity audio system and not properly cleaned up, restarting the editor is the only way to clear it).

To help me narrow down the issue some more, could you add the following logging code in to DissonanceComms (line 713):

[UsedImplicitly] private void OnDestroy()
{
    Log.Warn("Calling Destroy for `_capture` system");
    _capture.Destroy();
    Log.Warn("Called Destroy called for `_capture` system");
}

I suspect one or both of these messages will not be logged when you get the error. If you can confirm that I might be able to fix this even without a reliable reproduction.

martindevans commented 3 years ago

Dissonance 7.2.0 was just approved by Unity and is now live on the asset store. That includes a partial fix for this issue. See the full details over on issue #214.

iliachry commented 3 years ago

Caused to me after attempting to run a coroutine from OnAudioFilterRead(). After removing this call to the coroutine I was getting that error when I was playing the game. After restarting Unity Editor it was ok.

martindevans commented 3 years ago

Caused to me after attempting to run a coroutine from OnAudioFilterRead()

You've got to be extremely careful with implementing OnAudioFilterRead. Not only can you not interact with most Unity APIs (e.g. coroutines) you also have to be sure that any code in this path is extremely fast (e.g. don't allocate) because it's running on the audio thread - any delay will cause bad sounding audio glitches.

iliachry commented 3 years ago

Yes. I realized that and now I am trying to make it work. Thanks a lot!