Placeholder-Software / Dissonance

Unity Voice Chat Asset
71 stars 5 forks source link

InvalidOperationException: Error: Attempted to call Initialize on a HlapiCommsNetwork #36

Closed RamTheRam closed 7 years ago

RamTheRam commented 7 years ago

Context

I have purchased dissonance from unity asset store and I wanted to try it. however for some reason while following the guidlines and other tutorials, it seems I can not even get the voice chat working and I do get an error which does not make any sense

Expected Behavior

just wanted the voice chat to work

Actual Behavior

voicechat not working

Workaround

N/A

Fix

N/A

Steps to Reproduce

Provide a detailed set of steps to reproduce the problem I get this error: InvalidOperationException: Error: Attempted to call Initialize on a HlapiCommsNetwork, but it is not in the correct state (expected Ready|Initializing, got Disconnected)! 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: 3E7F2D4C-0F13-4324-83A1-97874221B99B Dissonance.Networking.BaseCommsNetwork3[Dissonance.Integrations.UNet_HLAPI.HlapiServer,Dissonance.Integrations.UNet_HLAPI.HlapiClient,Dissonance.Integrations.UNet_HLAPI.HlapiConn].Initialize (System.String playerName, Dissonance.Rooms rooms, Dissonance.PlayerChannels playerChannels, Dissonance.RoomChannels roomChannels, System.Action1 connectionCallback) (at Assets/Plugins/Dissonance/Core/Networking/BaseCommsNetwork.cs:319) Dissonance.DissonanceComms.Start () (at Assets/Plugins/Dissonance/DissonanceComms.cs:352)

Your Environment

martindevans commented 7 years ago

Hi ronkhmps,

Are you getting this error in your own scene, or in the demo scene included with Dissonance (there's one demo scene for each network integration)? The error you're getting here looks like you're trying to re-use the Dissonance components in multiple voice sessions (which isn't currently supported) - however in that case you should have perfectly working voice the first time.

If you're using the HLAPI the best way to configure Dissonance is to put all of the components in the online scene, this will correctly tear down and setup Dissonance at the right time.

RamTheRam commented 7 years ago

hello martin thank you very much for the reply yes I am using it in my own scene which is a fairly empty scene with one character. I am not trying to use the component in multiple sessions but I am not sure if the way I set it up work. I did also tried to run the demo scenes you had in the hlapi integration but: 1- in the HLAPI gameworld scene I am not getting anything when pressing the global chat and getting this error on load: NullReferenceException: Object reference not set to an instance of an object Dissonance.Integrations.UNet_HLAPI.HlapiCommsNetwork.Initialize () (at C:/Users/ramin/Desktop/testDiso/Assets/Dissonance/Integrations/UNet_HLAPI/HlapiCommsNetwork.cs:57) Dissonance.Networking.BaseCommsNetwork3[Dissonance.Integrations.UNet_HLAPI.HlapiServer,Dissonance.Integrations.UNet_HLAPI.HlapiClient,Dissonance.Integrations.UNet_HLAPI.HlapiConn].Initialize (System.String playerName, Dissonance.Rooms rooms, Dissonance.PlayerChannels playerChannels, Dissonance.RoomChannels roomChannels, System.Action1 connectionCallback) (at C:/Users/ramin/Desktop/testDiso/Assets/Plugins/Dissonance/Core/Networking/BaseCommsNetwork.cs:344) Dissonance.DissonanceComms.Start () (at C:/Users/ramin/Desktop/testDiso/Assets/Plugins/Dissonance/DissonanceComms.cs:352)

2- in the HLAPI demo scene I made sure the scene is part of the build setting but I still get this error Scene 'HLAPI Game World' couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded. To add a scene to the build settings use the menu File->Build Settings... UnityEngine.Networking.NetworkManagerHUD:OnGUI()

I built the standalone win version from the HLAPI demo scene and: no luck no voice chat when pressing globalchat

On Wed, Jun 28, 2017 at 11:20 AM, Martin Evans notifications@github.com wrote:

Hi ronkhmps,

Are you getting this error in your own scene, or in the demo scene included with Dissonance (there's one demo scene for each network integration)? The error you're getting here looks like you're trying to re-use the Dissonance components in multiple voice sessions (which isn't currently supported) - however in that case you should have perfectly working voice the first time.

If you're using the HLAPI the best way to configure Dissonance is to put all of the components in the online scene, this will correctly tear down and setup Dissonance at the right time.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Placeholder-Software/Dissonance/issues/36#issuecomment-311744640, or mute the thread https://github.com/notifications/unsubscribe-auth/AJBHSIAA_apXosIzPAXv2e3w6gZD5drUks5sIplVgaJpZM4OIHnl .

-- Ramin Shadmehr

ACE-3DFX www.ace3dfx.com 604-320-0010

martindevans commented 7 years ago

Is it possible for you to send me a copy of your test project?

NullReferenceException: Object reference not set to an instance of an object

The line in question reads: if (UnreliableChannel >= NetworkManager.singleton.channels.Count)

The only thing which could reasonably be null here is NetworkManager.singleton which sounds a lot like you're not in a network session yet! If you directly launched the game world this would be the case - the menu scene sets up the network session and then only loads the game world once everything is ready to go.

Scene 'HLAPI Game World' couldn't be loaded because it has not been added to the build settings

I've seen this before, it seems like Unity sometimes gets confused about the build settings and scene references. Try locating the HLAPI Network Manager and clearing and setting the online and offline scenes (after properly configuring the build settings). Offline = HLAPI Demo, Online = HLAPI Game World

RamTheRam commented 7 years ago

hello martin here is the link to the project my scene is called test

On Wed, Jun 28, 2017 at 11:56 AM, Martin Evans notifications@github.com wrote:

Is it possible for you to send me a copy of your test project?

NullReferenceException: Object reference not set to an instance of an object

The line in question reads: if (UnreliableChannel >= NetworkManager.singleton.channels.Count)

The only thing which could reasonably be null here is NetworkManager.singleton which sounds a lot like you're not in a network session yet! If you directly launched the game world this would be the case

  • the menu scene sets up the network session and then only loads the game world once everything is ready to go.

Scene 'HLAPI Game World' couldn't be loaded because it has not been added to the build settings

I've seen this before, it seems like Unity sometimes gets confused about the build settings and scene references. Try locating the HLAPI Network Manager and clearing and setting the online and offline scenes (after properly configuring the build settings). Offline = HLAPI Demo, Online = HLAPI Game World

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Placeholder-Software/Dissonance/issues/36#issuecomment-311754413, or mute the thread https://github.com/notifications/unsubscribe-auth/AJBHSAuyC0g4eAtuJTt-uzamgHN0jbcjks5sIqHDgaJpZM4OIHnl .

-- Ramin Shadmehr

ACE-3DFX www.ace3dfx.com 604-320-0010

RamTheRam commented 7 years ago

link removed

On Wed, Jun 28, 2017 at 1:28 PM, Ram sh ramin@ace3dfx.com wrote:

hello martin here is the link to the project my scene is called test

On Wed, Jun 28, 2017 at 11:56 AM, Martin Evans notifications@github.com wrote:

Is it possible for you to send me a copy of your test project?

NullReferenceException: Object reference not set to an instance of an object

The line in question reads: if (UnreliableChannel >= NetworkManager.singleton.channels.Count)

The only thing which could reasonably be null here is NetworkManager.singleton which sounds a lot like you're not in a network session yet! If you directly launched the game world this would be the case

  • the menu scene sets up the network session and then only loads the game world once everything is ready to go.

Scene 'HLAPI Game World' couldn't be loaded because it has not been added to the build settings

I've seen this before, it seems like Unity sometimes gets confused about the build settings and scene references. Try locating the HLAPI Network Manager and clearing and setting the online and offline scenes (after properly configuring the build settings). Offline = HLAPI Demo, Online = HLAPI Game World

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Placeholder-Software/Dissonance/issues/36#issuecomment-311754413, or mute the thread https://github.com/notifications/unsubscribe-auth/AJBHSAuyC0g4eAtuJTt-uzamgHN0jbcjks5sIqHDgaJpZM4OIHnl .

-- Ramin Shadmehr

ACE-3DFX www.ace3dfx.com 604-320-0010 <(604)%20320-0010>

-- Ramin Shadmehr

ACE-3DFX www.ace3dfx.com 604-320-0010

martindevans commented 7 years ago

Thanks for the project, I'm just downloading it now. I removed the link from the public comments, since it contains a complete copy of Dissonance.

martindevans commented 7 years ago

Ok, so here's what I see:

Edit: Of course as soon as I finished typing this I realised what the problem is. The Dissonance components are not designed to be re-used. we have work in progress to rectify this - but until that's done they're all very paranoid about their state (re-using components is a very common mistake). The Dissonance network component is deactivated by the network identity, which it interprets as a disconnection and so instantly sets itself into the Disconnected state - of course when it's subsequently activated by the identity it breaks because it's in a bad state!

RamTheRam commented 7 years ago

hello Martin I managed to run the demo scenes as you instructed. in regards to my test scene, could you elaborate more on what needs to be done. it is my first time dealing with dissonance and voice chat in general. ultimately I would like to incorporate this plug in into my game that is already made and works between two players regards

On Wed, Jun 28, 2017 at 2:53 PM, Martin Evans notifications@github.com wrote:

Ok, so here's what I see:

-

I set added the HLAPI demo scenes to the build, put them into the demo scene network manager as online and offline scenes (as I mentioned a few comments above), then ran HLAPI Demo. That all seems to work fine - do you get the same?

I ran your test scene. This is set up in the old way (using a network identity to activate the Dissonance components) - this isn't really supported any more (although I'm surprised it breaks, I will investigate further). For HLAPI I suggest using the online and offline scenes to manage the game state (the way the demo does).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Placeholder-Software/Dissonance/issues/36#issuecomment-311803125, or mute the thread https://github.com/notifications/unsubscribe-auth/AJBHSJmOeMfmC29F8VI99vD8ztj5Vjojks5sIstogaJpZM4OIHnl .

-- Ramin Shadmehr

ACE-3DFX www.ace3dfx.com 604-320-0010

martindevans commented 7 years ago

There's really only one thing you need to ensure: Never re-use Dissonance components between network session. Dissonane considers disabling and enabling a component to be re-use, so that's the problem in your test scene. We have stuff on the way to make this better.

In your game I assume you perform some work when a network session is created (for example, loading up a new scene containing the gameplay) - you should create a new set of Dissonance components at this time. If you're using the HLAPI Online/Offline scenes this is easy - you can just add the Dissonance components into the online scene.

Conversely when the network session ends you need to destroy the Dissonance components and then make a new set when you start a new session. Again, if you're using HLAPI online/offline scenes, this is done for you.

here's some docs on the online scene concept

RamTheRam commented 7 years ago

thanks I will try it cheers

On Thu, Jun 29, 2017 at 11:30 AM, Martin Evans notifications@github.com wrote:

There's really only one thing you need to ensure: Never re-use Dissonance components between network session. Dissonane considers disabling and enabling a component to be re-use, so that's the problem in your test scene. We have stuff on the way to make this better.

In your game I assume you perform some work when a network session is created (for example, loading up a new scene containing the gameplay) - you should create a new set of Dissonance components at this time. If you're using the HLAPI Online/Offline scenes this is easy - you can just add the Dissonance components into the online scene.

Conversely when the network session ends you need to destroy the Dissonance components and then make a new set when you start a new session. Again, if you're using HLAPI online/offline scenes, this is done for you.

here's some docs https://docs.unity3d.com/ScriptReference/Networking.NetworkManager-onlineScene.html on the online scene concept

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Placeholder-Software/Dissonance/issues/36#issuecomment-312055328, or mute the thread https://github.com/notifications/unsubscribe-auth/AJBHSCW5NxQHA3ct_UTYHjBKmtMI-9eCks5sI-04gaJpZM4OIHnl .

-- Ramin Shadmehr

ACE-3DFX www.ace3dfx.com 604-320-0010

RamTheRam commented 7 years ago

hello martin it seems working now thanks for advice

On Thu, Jun 29, 2017 at 1:34 PM, Ram sh ramin@ace3dfx.com wrote:

thanks I will try it cheers

On Thu, Jun 29, 2017 at 11:30 AM, Martin Evans notifications@github.com wrote:

There's really only one thing you need to ensure: Never re-use Dissonance components between network session. Dissonane considers disabling and enabling a component to be re-use, so that's the problem in your test scene. We have stuff on the way to make this better.

In your game I assume you perform some work when a network session is created (for example, loading up a new scene containing the gameplay) - you should create a new set of Dissonance components at this time. If you're using the HLAPI Online/Offline scenes this is easy - you can just add the Dissonance components into the online scene.

Conversely when the network session ends you need to destroy the Dissonance components and then make a new set when you start a new session. Again, if you're using HLAPI online/offline scenes, this is done for you.

here's some docs https://docs.unity3d.com/ScriptReference/Networking.NetworkManager-onlineScene.html on the online scene concept

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Placeholder-Software/Dissonance/issues/36#issuecomment-312055328, or mute the thread https://github.com/notifications/unsubscribe-auth/AJBHSCW5NxQHA3ct_UTYHjBKmtMI-9eCks5sI-04gaJpZM4OIHnl .

-- Ramin Shadmehr

ACE-3DFX www.ace3dfx.com 604-320-0010 <(604)%20320-0010>

-- Ramin Shadmehr

ACE-3DFX www.ace3dfx.com 604-320-0010

martindevans commented 7 years ago

Excellent! I'll close this issue but don't hesitate to open another if you encounter any more problems :)

RamTheRam commented 7 years ago

Hello martin one last question I am trying to toggle the chat on and off with a gui toggle. What would the best way to do it? I mean which variable in dissonance i could disable/enable? Thanks

On Jul 5, 2017 5:51 AM, "Martin Evans" notifications@github.com wrote:

Excellent! I'll close this issue but don't hesitate to open another if you encounter any more problems :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Placeholder-Software/Dissonance/issues/36#issuecomment-313093412, or mute the thread https://github.com/notifications/unsubscribe-auth/AJBHSONOzYcL-O8G-qENmNHJT5xfroxVks5sK4aUgaJpZM4OIHnl .

martindevans commented 7 years ago

If you want to disable sending voice there's an IsMuted property on the DissonanceComms component.

If you want to disable receiving voice there's not currently a good way to do this built in to Dissonance (next release will allow you to mute individual players). For now the best thing to do would be to create a custom playback prefab which sends all audio to a particular mixer and then mute the mixer.

RamTheRam commented 7 years ago

hello martin thanks for the help I tried that and somewhat it does the job. but what I really want is to just disable the outgoing and incoming voice if the user wants. I tried disabling the comm object but that doesnot work your thoughts?

On Fri, Jul 7, 2017 at 11:06 AM, Martin Evans notifications@github.com wrote:

If you want to disable sending voice there's an IsMuted property on the DissonanceComms component.

If you want to disable receiving voice there's not currently a good way to do this built in to Dissonance (next release will allow you to mute individual players). For now the best thing to do would be to create a custom playback prefab https://dissonance.readthedocs.io/en/latest/Tutorials/Playback-Prefab/ which sends all audio to a particular mixer https://docs.unity3d.com/ScriptReference/AudioSource-outputAudioMixerGroup.html and then mute the mixer https://forum.unity3d.com/threads/how-do-you-mute-a-audiomixergroup-from-code.308909/ .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Placeholder-Software/Dissonance/issues/36#issuecomment-313753454, or mute the thread https://github.com/notifications/unsubscribe-auth/AJBHSE5iNhf9zo-9kdCVOnGf6r3tl9j4ks5sLnOfgaJpZM4OIHnl .

-- Ramin Shadmehr

ACE-3DFX www.ace3dfx.com 604-320-0010

martindevans commented 7 years ago

Which part of using IsMuted and muting the mixer didn't work for you?

RamTheRam commented 7 years ago

Hello martin For sone reason it just did not work. I tried accessing it and enable/disable with toggle and just did nit work. I am still hearing the chat

On Jul 12, 2017 3:19 AM, "Martin Evans" notifications@github.com wrote:

Which part of using IsMuted and muting the mixer didn't work for you?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Placeholder-Software/Dissonance/issues/36#issuecomment-314719617, or mute the thread https://github.com/notifications/unsubscribe-auth/AJBHSLvOBGXZprp1RuFXpkhHGu9p0lGfks5sNJ3IgaJpZM4OIHnl .

martindevans commented 7 years ago

Alright that sounds like a bug in Dissonance; could you open a new issue and provide details of exactly what you tried etc. Thanks :)

RamTheRam commented 7 years ago

hello martin actually I made a mistake I had the function I created messed up it is working now cheers

On Wed, Jul 12, 2017 at 10:56 AM, Martin Evans notifications@github.com wrote:

Alright that sounds like a bug in Dissonance; could you open a new issue and provide details of exactly what you tried etc. Thanks :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Placeholder-Software/Dissonance/issues/36#issuecomment-314847612, or mute the thread https://github.com/notifications/unsubscribe-auth/AJBHSHx6_gxlMqzEhLXiiY0dsxWYFBoMks5sNQi-gaJpZM4OIHnl .

-- Ramin Shadmehr

ACE-3DFX www.ace3dfx.com 604-320-0010

martindevans commented 7 years ago

Alright good to hear :)

RamTheRam commented 7 years ago

Hrllo again martin I was hoping not to bother you but here is another question. I am getting this weird echo during the chat. Even when the testing devices are on different locations. Like 2 km apart. Any solution for that? I have the dissonance setup on voice activation by the way

On Jul 12, 2017 12:43 PM, "Martin Evans" notifications@github.com wrote:

Alright good to hear :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Placeholder-Software/Dissonance/issues/36#issuecomment-314875692, or mute the thread https://github.com/notifications/unsubscribe-auth/AJBHSGgSTfvFZdJmMvOrG23TzJpTQXD8ks5sNSHcgaJpZM4OIHnl .

martindevans commented 7 years ago

Hi again, no worries about asking questions :)

I imagine you're suffering from remote echo. Your voice goes:

Local Mic -> Network -> Remote Speaker ---v
Local Speaker <-- Network <- Remote Mic <--

This is made worse by voice activation because your voice coming out of the remote speaker is a voice, so voice activation does it's job properly and sends back the voices it hears. Noise suppression won't have any effect here because once again the remote voice is a voice and noise suppression is specifically designed not to reduce voices! Using headphones should fix the problem (since your mic can't hear your headphones of course).

The real solution is acoustic echo cancellation - it monitors what's playing from the local speaker and removes that signal from the local mic when it picks it up a few milliseconds later. This is something that's been in the works for a couple of months and hopefully will be done soon - once the next version comes out (in a week) I'll be testing some prototype code and if that works I'll aim put AEC in the next next version (no timetable on that though).