Search Unity

[Released] Dissonance: Unity Voice Chat

Discussion in 'Assets and Asset Store' started by Nyarlathothep, Oct 27, 2016.

  1. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    > frame rate drop 60fps to 40 fps when I run AEC

    You definitely shouldn't see anything like this! Could you open up a report on our issue tracker with details of your project and I'll see what I can do.

    > Attempted to Locally UnMute the local player!

    Dissonance doesn't support playing your local mic out through you local speaker, which is what you're attempting to do here. Is that really what you want?
     
    tricagames likes this.
  2. tricagames

    tricagames

    Joined:
    Dec 9, 2016
    Posts:
    11
    I just want my local player cannot be mute by default like in previous version but when I upgrade to latest version local player is mute

    Screenshot 2020-07-29 at 22.27.37.png
     
    Last edited: Jul 29, 2020
    Nyarlathothep likes this.
  3. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    Dissonance has never supported unmuting the local player. I think you're misunderstanding that setting though - this isn't preventing you from sending audio to other players it is preventing you from hearing yourself.

    The only thing that's changed with this setting recently is that you can no longer even try to toggle it from the inspector because the control is disabled for the local player. In the past the control was active but it didn't do anything except print a warning.
     
  4. tricagames

    tricagames

    Joined:
    Dec 9, 2016
    Posts:
    11
    ok but I cannot hear audio from other device , i test with android mobile and unity editor , but I can't hear anything in editor when speak from mobile.
    Also I notice when i run game on mobile i cannot see mic permission dialog ,maybe that's why I cannot hear anything.
    I'm using Mac
    unity 2019.4.0
    Screenshot 2020-07-30 at 06.14.09.png
     
    Last edited: Jul 30, 2020
    Nyarlathothep likes this.
  5. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    Can you hear something on the phone when you speak in the editor? If so, I think this is most likely an issue with permission to access the microphone on the mobile.

    Here are the Unity docs on how to request permission on Android and iOS :)
     
    tricagames likes this.
  6. tricagames

    tricagames

    Joined:
    Dec 9, 2016
    Posts:
    11
    yeah when I speak in editor I hear in phone but when I spoke from phone I can't hear anything in editor
     
    Nyarlathothep likes this.
  7. tricagames

    tricagames

    Joined:
    Dec 9, 2016
    Posts:
    11
    Finally it works
    thanks
     
    Nyarlathothep likes this.
  8. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    Excellent. Glad I could help :D
     
    tricagames likes this.
  9. tricagames

    tricagames

    Joined:
    Dec 9, 2016
    Posts:
    11
    kindly see attach image when I run AEC my game frame rate down 60fps to 40fps , but without AEC game run fine but echo and voice repeat issue when I speak
     

    Attached Files:

  10. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    Could you open up an issue on the tracker with all the necessary details about your project and a copy of the editor log? I'll have a dig through all the details on Monday and see if I can work out what's wrong :)
     
    tricagames likes this.
  11. davidborbis

    davidborbis

    Joined:
    May 2, 2019
    Posts:
    27
    Hello everyone,

    I just downloaded the latest version of dissonance and I started getting this error

    Exception: All copies of plugin AudioPluginDissonance must have the same "Don't process" setting.

    I am using UWP for hololens 2 and unity version 2019.4 with HLAPI
     
    Nyarlathothep likes this.
  12. davidborbis

    davidborbis

    Joined:
    May 2, 2019
    Posts:
    27

    Looks like someone has already brought this to your attention

    https://github.com/Placeholder-Software/Dissonance/issues/205

    I will keep checking back in
     
    Nyarlathothep likes this.
  13. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    I've updated that issue you linked with the results of some investigating into the issue. Unfortunately I don't have a Hololens, so I don't think I can test any further. If you could check my comments on that thread and tell me if they help with running it on the actual hardware that would be really helpful. Thanks.
     
    davidborbis likes this.
  14. davidborbis

    davidborbis

    Joined:
    May 2, 2019
    Posts:
    27
    Thanks, I will get to this today hopefully within the next couple hours
     
    Nyarlathothep likes this.
  15. davidborbis

    davidborbis

    Joined:
    May 2, 2019
    Posts:
    27
    So far it builds for me, but I keep getting this error constantly and it doesn't seem to send any audio

    basepreprocessingpipeline lost 960 samples in the preprocessor (buffer full) injecting silence to compensate

    I will double check my scene and make sure I am setting it up correctly
     
  16. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    This usually indicates that the preprocessor is falling behind due to a performance issue (the preprocessor fell far enough behind that it discarded some audio and put silence in it's place, allowing it to catch up a little). Do you have something else in the scene that may be slowing things down?
     
  17. davidborbis

    davidborbis

    Joined:
    May 2, 2019
    Posts:
    27
    I apologize, I missed the initial error

    DissonanceComms Dependency Error: Unable to load DLL 'AudioPluginDissonance': The specified module could not be found
     
    Nyarlathothep likes this.
  18. davidborbis

    davidborbis

    Joined:
    May 2, 2019
    Posts:
    27
    I may have not applied my settings to the plugin before I built it, I will do another quick test, sorry about this.
     
    Nyarlathothep likes this.
  19. davidborbis

    davidborbis

    Joined:
    May 2, 2019
    Posts:
    27
    It's working normally with your plugin settings! Thanks, sorry I goofed earlier. I will comment on the github issue
     
    Nyarlathothep likes this.
  20. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    Excellent, I'm glad that resolved it. Thanks for checking that out on the actual Hololens hardware for me :D
     
    davidborbis likes this.
  21. ConjureScape

    ConjureScape

    Joined:
    Feb 14, 2013
    Posts:
    445
    Our client has done a penetration test on our application which contains the dissonance plugin.
    Your code has been flagged with "Insecure Randomness" as seen in the screenshot.


    upload_2020-10-12_10-9-17.png
     
    Nyarlathothep likes this.
  22. ConjureScape

    ConjureScape

    Joined:
    Feb 14, 2013
    Posts:
    445
    Explanation

    Insecure randomness errors occur when a function that can produce predictable values is used as a source
    of randomness in a security-sensitive context. Computers are deterministic machines, and as such are
    unable to produce true randomness. Pseudorandom Number Generators (PRNGs) approximate
    randomness algorithmically, starting with a seed from which subsequent values are calculated. There are
    two types of PRNGs: statistical and cryptographic. Statistical PRNGs provide useful statistical properties,
    but their output is highly predictable and form an easy to reproduce numeric stream that is unsuitable for
    use in cases where security depends on generated values being unpredictable. Cryptographic PRNGs
    address this problem by generating output that is more difficult to predict. For a value to be
    cryptographically secure, it must be impossible or highly improbable for an attacker to distinguish between
    the generated random value and a truly random value. In general, if a PRNG algorithm is not advertised as
    being cryptographically secure, then it is probably a statistical PRNG and should not be used in securitysensitive
    contexts, where its use can lead to serious vulnerabilities such as easy-to-guess temporary
    passwords, predictable cryptographic keys, session hijacking, and DNS spoofing. Example: The following
    code uses a statistical PRNG to create a URL for a receipt that remains active for some period of time after
    a purchase.

    string GenerateReceiptURL(string baseUrl) {
    Random Gen = new Random();
    return (baseUrl + Gen.Next().toString() + ".html");
    }

    This code uses the Random.Next() function to generate "unique" identifiers for the receipt pages it
    generates. Since Random.Next() is a statistical PRNG, it is easy for an attacker to guess the strings it
    generates. Although the underlying design of the receipt system is also faulty, it would be more secure if it
    used a random number generator that did not produce predictable receipt identifiers, such as a
    cryptographic PRNG.
     
    Nyarlathothep likes this.
  23. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    Dissonance itself does not handle any kind of encryption of voice packets - that's the responsibility of the network layer which is transferring the Dissonance packets over the network. In general that means that most parts of Dissonance (even networking) are not relevant to a pentest, since security should be handled by another system.

    This specific random number is the "session ID" - the server generates a random session ID when it starts up and then all packets from clients are prefixed with this ID. It simply acts as a check that packets from one session are not somehow leaking into another session. It's not a security flaw of any kind because it's not intended to ensure security :)
     
  24. ConjureScape

    ConjureScape

    Joined:
    Feb 14, 2013
    Posts:
    445
    Thank you Nyarlathothep!
    Your explanation of the random ID and how it is used solves it. I will pass this on to the client.
     
    Nyarlathothep likes this.
  25. Mese96

    Mese96

    Joined:
    Jul 23, 2013
    Posts:
    40
    @Nyarlathothep Will there be an Integration for MirrorNG at some time ?
     
    Nyarlathothep likes this.
  26. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    We don't have any immediate plans to support MirrorNG, but if enough people request it we'll build an integration for it. But don't forget: Dissonance is designed such that anyone can build an integration, so you don't need to wait on us to build in MirrorNG support to use it for your project!
     
    Mese96 likes this.
  27. Mese96

    Mese96

    Joined:
    Jul 23, 2013
    Posts:
    40
    Yeah sure, I am currently trying to adapt the Mirror one.
    But it would have been nicer to have official support.
     
  28. Celestipoo

    Celestipoo

    Joined:
    Jul 1, 2013
    Posts:
    379
    I have an issue on the Magic Leap device. When the device goes to standby mode the audio capture is still active so when I put the device back on and the app becomes active again, I hear all the audio that was captured while the device was in standby. Is there any way to reset the audio so that I flush all that recorded audio and essentially throw it out?
     
  29. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    Dissonance is meant to handle app suspension automatically by pausing audio recording when OnApplicationPause is called by Unity. Could you check if that message is called correctly on the Magic Leap device?
     
  30. Celestipoo

    Celestipoo

    Joined:
    Jul 1, 2013
    Posts:
    379
    It doesn't seem to be getting called. Is there anything I can do to work around this?
     
  31. jjobby

    jjobby

    Joined:
    Nov 28, 2009
    Posts:
    161
    Hello, I want to setup a Team Chat. My game has a room session which players can create or join on demand. My question is that can I add new chat room at runtime or should I estimate max chat rooms and add them in chat room setting beforehand?
     
    Last edited: Apr 26, 2021
  32. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    That's tricky, if the built in way of detecting suspension isn't working you'll need some other (platform specific?) way of detecting when it happens. Perhaps you could have something watching frame times and call the suspension methods yourself when the frame time is very long?

    There may also be a Magic Leap specific alternative method if there's some kind of platform SDK that you can use, but I don't know a lot about that unfortunately.
     
  33. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    The chat room config which you can change in the editor is only for convenience - it adds those rooms to the drop down rooms list in the inspector. It's not used for anything else at all! So you're safe to just generate and use new rooms names without adding them.
     
    jjobby likes this.
  34. auhfel

    auhfel

    Joined:
    Jul 5, 2015
    Posts:
    92
    Hello! I'm working on a game that's strictly peer to peer, using LiteNetLib. I do have a master server running that introduces peers to eachother so that they can connect to eachother, but that's all it does -- It can't be used with Dissonance in any way itself, it's just a simple console program, doesn't run unity.

    So my question is how does Dissonance work in pure Peer to Peer mode, no master server at all? Is every peer that is connected to eachother considered a Host? Are there any special considerations for working with Dissonance in this mode?

    Edit: I've implemented most everything so far and am getting closer to testing, but just realized that my BaseClient.SendReliable/Unreliable are trying to send comms to my master server that can't be used as a relay. Since we're strictly peer to peer, does this actually need to be implemented? I'm not sure where I'd even make this method send people to, as the relay server doesn't exist.
     
    Last edited: Jun 12, 2021
    Nyarlathothep likes this.
  35. auhfel

    auhfel

    Joined:
    Jul 5, 2015
    Posts:
    92
    I've finished setting up the custom network integration using LiteNetLib in my p2p scenario, I keep getting "Attempted to send a voice before assigned a client ID by the host". I'll keep looking at the code, but I dunno if this is an error because I did something wrong, or an error in how I think dissonance is set up to run in peer to peer without a server. I'm definitely calling client.Connected(), so it's not that.

    EDIT: I think this is probably because I have not handled loop back at all, and perhaps the local client isn't getting assigned an ID because of this. I'll report back soon!

    EDIT: I also neglected to capture the return id from the NetworkRecievedPacket and process it.. working on that now too
     
    Last edited: Jun 12, 2021
    Nyarlathothep likes this.
  36. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    We do actually have another network integration (Dark Rift 2) which has a non-Unity server instance. For that we've already done the work to pull the necessary bits of Dissonance out to be usable in a non-Unity environment. So you could take that project (source available on request with an invoice number) and adapt it to your central server if you want a central voice session host.

    A Dissonance session always has a host which does two things:
    • manages the session (assigning unique IDs, handshaking new clients into the session etc).
    • relaying voice between peers (if those peers cannot communicate directly).
    In most network systems peers cannot communicate directly, and so all voice is relayed via the the host. In a p2p session where everyone can talk to everyone else no voice traffic will go via the host.

    In a purely p2p session you'll still need to pick a peer as your "master peer". When a new client joins the session they need to find out who the master peer is so that they can introduce themselves to the master peer and get assigned an ID/receive all the voice session metadata etc. If the master peer leaves the session you can simply migrate the host to a new peer (session setup is fast, so even if you simply tear down and setup the entire voip session in this event it'll only be a very brief interruption).

    Since all the voice will be sent via p2p no voice will be relayed to via the host. SendUnreliable should not be used by anything (it's probably safest to simply implement it as calling SendReliable and logging a warning, so at least things will work if something ends up using it).

    SendReliable is used for all the session management messages (e.g. "I've just joined the session, what's my ID?", "What rooms are everyone listening to?", "I am listening to room X", "I am no longer listening to room X").

    This means the the master peer hasn't replied to your handshake with a unique ID. Until this is done you can't talk.
     
    auhfel likes this.
  37. auhfel

    auhfel

    Joined:
    Jul 5, 2015
    Posts:
    92
    Thanks so much for the detailed response! This answers all the problems I was having trying to make it work, and explains why It wouldn't work when my current implementation of Dissonance was assuming that every peer could be a master peer. It looks like with how my current network is written, that Dissonance won't work in this pure P2P method mode. I'll need to implement something on my master server so that at a minimum it can do handshakes for clients so they can get their ID, kind of like how my master server does nat introductions for my own net logic. So the current path forward is probably to implement the dissonance logic in my master server using the Dark Rift code as an example. I'll email you a response, thanks so much!

    EDIT: Just a quick question before I get started on changing anything, this is the picture in my head of how it should work now:

    I make my master server use Dissonance via the Darkift Server example. This master server is ran as a Server in Dissonance, now everyone else who connects will be a client. I assume that there are no hosts in this example because the server isn't even running Unity.

    Then, each client we have needs to at the minimum contact the master server to get their dissonance ID. I'm assuming this is where the need of master server communications ends, as I'm not currently wanting to use it as a Relay. (Probably will in the future, just not right now). In my P2P send examples, I'm clearing the destinations before calling the base method so nothing gets sent to the master server.

    I manage who is already connected to the current peer in my LiteNetLib integration, so I then use this information to send handshakes to all the peers that my integration is tracking as connected. These peers should have an ID from the master server, and I'm already managing when peers connect/disconnect to eachother, so that should be mostly it to get voice working right?

    I think I may have additional work to do to manage p2p disconnections amongst eachother, so that peers gracefully disconnect eachother, but mostly the way forward is looking pretty clear!

    Looking forward to getting my hands on that Dark Rift server code!
     
    Last edited: Jun 12, 2021
    Nyarlathothep likes this.
  38. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    That's not quite where it ends. All peers (including the server) keep a list of who is listening to which rooms, when a new client joins it gets this list from the master. So you'll have some traffic going to your central server as people join and leave rooms - we're only talking tens of bytes each time though, really tiny amounts of traffic.

    Everything else you've said sounds correct, looks like you understand the architecture pretty well :)
     
    auhfel likes this.
  39. auhfel

    auhfel

    Joined:
    Jul 5, 2015
    Posts:
    92
    Perfect, I don't mind some data going through the server, I just want to avoid anything high volume like voice traffic.

    This all should keep me preoccupied for awhile, I'll post again here if I need help but I think with the code provided and my now, fixed view of how the architecture works I should be able to solve anything else that comes up. Thanks again!
     
    Nyarlathothep likes this.
  40. auhfel

    auhfel

    Joined:
    Jul 5, 2015
    Posts:
    92
    Just an update for everyone, I did get Dissonance working on my custom LiteNetLib P2P implementation. I took me longer than it should have, mostly because I almost exclusively code inside Unity so my Visual Studio DLL/Linux Mono/other stuff lack of knowledge held me back. But it's working!

    The one issue I ran into that held me back for so long was that for LiteNetLib implementation. My Dissonance Send methods were using NetDataWriter.PutBytesWithLength, and dissonance was not expecting that causing malformed packets. I assume it didn't want the length. Changing to a foreach byte in ArraySegment, NetDataWriter.Put(byte) fixed it. Leaving here for anyone else trying to implement Dissonance with LiteNetLib.. don't use PutBytesWithLength!

    I remember seeing this in one of the other dissonance plugins and disregarded it, shouldn't of took me so long to figure out. Super stoked that it's working now though!
     
    Nyarlathothep likes this.
  41. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    Dissonance wants to be given exactly the bytes that were sent, and nothing else. So if you were directly reading out those bytes (with the length prefix) that would definitely cause an issue.

    That said - you can probably use PutBytesWithLength if there's some kind of equivalent call on the other side like ReadLengthPrefixedBytes.
     
    auhfel likes this.
  42. auhfel

    auhfel

    Joined:
    Jul 5, 2015
    Posts:
    92
    Yup! I'm glad it worked.
    The NetDataReader does have GetBytesWithLength which returns a byte array, so I assume it does read a length prefix and return the remaining bytes. In my code I appended a header to it that I then read out, and then passed the remaining data with reader.GetRemainingBytesSegment() as it was handy have as a segment since that's what the dissonance methods were expecting. Had I also read it with GetBytesWithLength, it would have worked just as you say!

    Hard to see such obvious problems when you're in the thick of it. Time for a heavy refactor now that I got everything to at least work!
     
    Nyarlathothep likes this.
  43. caglarenes

    caglarenes

    Joined:
    Jul 9, 2015
    Posts:
    45
    Hello, I just bought this asset. It's very very good and useful asset. Thanks for your all effort.
    I'm planning to use it with WebRTC.

    WebRTC asset have a 'conference' option natively. Dissonance WebRTC doesn't use this option. So we need to authorize any one client as a server creator and we need to check him for disconnections to recreating room again for other clients with another sender.

    Do you planning any implementation to use 'conference' feature in WebRTC?
     
    Nyarlathothep likes this.
  44. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    I'm not familiar with the "conference" option of the WebRTC asset, do you have a link to any documentation about it?

    My guess is that we won't be able to support it though - Dissonance has it's own server logic (e.g. assigning IDs, maintaining a list of who is listening to which channels) which has to run somewhere, since WebRTC is purely p2p that means it has to run on a client. If that client disconnects, the information is lost and a new session needs to be setup.
     
    caglarenes likes this.
  45. caglarenes

    caglarenes

    Joined:
    Jul 9, 2015
    Posts:
    45
    Yeah here:
    http://www.because-why-not.com/webrtc/examples/minimal-conference/

    Also there is "VideoConferenceApp/conferencescene" scene in 'extra' folder. Documentation says it's beta but whole WebRTC asset is beta by the way.

    It uses new ICall system which is no implementation in Dissonance I think. I try to some workarounds but no one work as I excepted. I try to use very experimental "CreateCall(NetworkConfig config, IBasicNetwork signalingNetwork)" function which creates a mixture of new ICall and old IBasicNetwork class I think, but it freezes the application totally.

    The whole story is WebRTC adresssharing option in signaling server(node.js one), respect every one equally and it doesn't close room when sender/first client leave the room. There is no StartServer() or Join() functions on conference. Only Listen() function is enough to join or create the room.

    I totally understand and love Dissonance's logic. I just want to try some experiments about clients connection stability. Thanks a lot for your interest :)
     
    Nyarlathothep likes this.
  46. Nyarlathothep

    Nyarlathothep

    Joined:
    Jun 13, 2013
    Posts:
    398
    Ah I see, this does look like a slightly better way to do the networking - Dissonance opens up p2p connections from every client to every other client to achieve the same as the conferencing, so it would be simpler to use this.

    However, it wouldn't change the issue with having a more important peer because that's purely a Dissonance thing - no matter how the underlying network system works Dissonance will always want a single peer coordinating the session.
     
  47. olavrv

    olavrv

    Joined:
    May 26, 2015
    Posts:
    515
    Dissonance asset crashes when compiling il2cpp in Unity 2021.2.0b16, has worked fine with previous beta versions of Unity.

    Also works fine in MONO.

    Does anyone have any tips to fix this?
     
  48. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Is there an error message or call stack when this problem happens?
     
  49. olavrv

    olavrv

    Joined:
    May 26, 2015
    Posts:
    515
    No error, but it works in mono not il2cpp
     
  50. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    Is it possible to get a dump or core file from the process when the crash happens?
     
    Nyarlathothep likes this.