Placeholder-Software / Dissonance

Unity Voice Chat Asset
71 stars 5 forks source link

[bug] NullReferenceException when clicking on a Dissonance Echo Cancellation filter attached to an Audio Mixer #177

Closed konradcl closed 4 years ago

konradcl commented 4 years ago

Context

I was following the guide in the Dissonance documentation for how to setup Acoustic Echo Cancellation. While trying to verify that the Acoustic Echo Cancellation works as intended, I attempted to select the "Dissonance Echo Cancellation" filter that I previously had attached to an audio mixer. This attempt failed and resulted in a NullReferenceException and an Assert failed error repeatedly being logged to the Unity console (view "Actual Behavior" for error details). If I at this point would exit and reenter play mode, the Unity editor would crash to desktop.

Furthermore, I have managed to reproduce the above behavior in a fresh Unity project with Dissonance's Mirror Networking Demo (view "Steps to Reproduce").

Expected Behavior

When clicking on a "Dissonance Echo Cancellation" filter attached to a mixer (after following the outlined in "Steps to Reproduce") I would expect to see something like the below image in the inspector:

AecStatus

Actual Behavior

After following the instructions outlined in "Steps to Reproduce", clicking on the "Dissonance Echo Cancellation" filter attached the mixer results in a NullReferenceException and an Assert failed error repeatedly being logged to the Unity console (errors details shown below). If I at this point would exit and reenter play mode, the Unity editor would crash to desktop.

NullReferenceException

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Audio.AudioMixerEffectController.GetFloatBuffer_Internal (UnityEditor.Audio.AudioMixerController controller, System.String name, System.Single* buffer, System.Int32 bufferLength) (at <a1a0cbfbb006481ba8f5b809536251bb>:0)
UnityEngine.Yoga.YogaNode.CalculateLayout (System.Single width, System.Single height) (at /Users/builduser/buildslave/unity/build/External/Yoga/csharp/Facebook.Yoga/YogaNode.cs:652)
UnityEngine.UIElements.UIRLayoutUpdater.Update () (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Renderer/UIRLayoutUpdater.cs:50)
UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/VisualTreeUpdater.cs:84)
UnityEngine.UIElements.Panel.UpdateForRepaint () (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Panel.cs:710)
UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event e) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/Panel.cs:738)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/UIElementsUtility.bindings.cs:387)
UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at /Users/builduser/buildslave/unity/build/Modules/UIElements/UIElementsUtility.bindings.cs:194)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:187)

Assertion Failed

Assertion failed
UnityEditor.RetainedMode:UpdateSchedulers() (at /Users/builduser/buildslave/unity/build/Editor/Mono/RetainedMode.cs:62)

Steps to Reproduce

To reproduce the described problem in the environment specified below, follow these steps:

  1. Create a new Unity project with Unity version 2019.3.0f6.
  2. Import Dissonance Voice Chat from the Unity Asset Store. If you encounter an error saying "Multiple plugins with the same name 'opus'" and/or "multiple plugins with the same name 'audioplugindissonance'", quit the Unity editor and navigate to the x86 and x86_64 directories located in Assets/Libraries/Plugins/Dissonance/Plugins relative to the location your Unity project. Delete all files ending with the extension .bundle or .bundle.meta from these directories. Then, relaunch the Unity editor and ensure that Unity is no longer complaining about the above error(s). If Unity still complains about these after you have deleted the specified files, clear the Unity console and relaunch Unity.
  3. Import "Mirror" (mirror networking) from the Unity Asset Store.
  4. Import “Dissonance For Mirror Networking” from the Unity Asset Store. Let "Dissonance For Mirror Networking" override any existing Dissonance files.
  5. Create a folder called "Libraries" and move all folders from the Unity Asset Store into it; then, wait for Unity to recompile.
  6. Clear the console and enter play mode. Make sure that no warnings or errors are logged to the console.
  7. Add both "MirrorIgnorance Demo" and "MirrorIgnorance Game World" scenes to your project's build settings, and drag "MirrorIgnorance Demo" to the top of the list. The scenes are located in Libraries/Dissonance/Integrations/MirrorIgnorance/Demo. Also remove the SampleScene from your "Scenes in Build" in your Build Settings.
  8. Open “Player Settings” and enter an arbitrary “Microphone Usage Description”, such as "hello".
  9. Open "MirrorIgnorance Demo" scene and open the NetworkManager. Ensure that Offline Scene is set up MirrorIgnorance Demo and Online Scene is set to MirrorIgnorance Game World. Also remove the SampleScene.
  10. Click: File > Build and Run. Name your build "MacOSClient" and verify that everything builds without errors at this point.
  11. Add an Audio Mixer: Window > Audio > Audio Mixer. Double click on the mixer in the Unity project pane and add a new mixer by clicking to the right of the "Mixers". Give it a name like "Master".
  12. Disable Auto Mixer Suspend on the Master mixer.
  13. Add "Dissonance Echo Cancellation" last in the Master mixer's effect stack.
  14. Open the PlaybackPrefab located at Libraries/Plugins/Dissonance/Resources and add the Master mixer as its "Output".
  15. Open the DissonanceSetup game object of the "MirrorIgnorance Game World" scene and drag the PlaybackPrefab into the "PlaybackPrefab" slot on the DissonanceComms component attached to DissonanceSetup. Save your changes to the game world scene.
  16. Create a new build as in step 10. Call it "MacOSClient"
  17. Once the client is running, run the Demo scene in the editor.
  18. In the editor, click "LAN Host".
  19. In the client window, click "LAN Client".
  20. Click (one or several times) on the "Dissonance Echo Cancellation" label displayed under the "Attentuation" label in the mixer that you created. This should either result in the aforementioned errors being logged to the Unity console.
  21. Exit and reenter play mode in the Editor. This should result in a crash to desktop.

Environment

The described issue was initially encountered and subsequently reproduced in the following environment:

martindevans commented 4 years ago

Workaround (confirmed to work by @konradcl) - remove the call to GetFloatBuffer in Assets/Plugins/Dissonance/Editor/DissonanceAecFilterInspector.cs.

It's possible this is a bug in the Unity UI (Mac only?) or something in DissonanceNative/webrtc/src/DissonanceAEC.cpp#L225 set up incorrectly.

martindevans commented 4 years ago

Dissonance 6.4.5 is now on the asset store, it should fix this issue.

In this case since it seems to be a Unity bug we've added the workaround that I mentioned above, effectively disabling almost all of the AEC statistics in the inspector for MacOS.

juzpermsky commented 4 years ago

Still failed with this expection on Win10 and Dissonance 6.4.6 and Unity 2019.3.4f1

juzpermsky commented 4 years ago

@martindevans BUT! On Unity 2019.3.9f1 works as expected! image Just tested.

martindevans commented 4 years ago

Thanks for checking that it works in the latest version.

Since it looks like this was broken by Unity only for a small number of versions I'm going to change this issue to "Won't Fix": Anyone else encountering this issue should upgrade to the latest version of 2019.3 or .4.

martindevans commented 4 years ago

Coincidentally Unity support just got in touch with me about this issue and linked me to this duplicate issue that they have fixed: https://issuetracker.unity3d.com/issues/editor-freezes-or-crashes-when-interacting-with-native-audio-plugin-sdks-audio-mixers