Search Unity

  1. We have added sub-forums for the experimental MLAPI and Unity Transport Package. Please use the new forums to discuss related topics.
    Dismiss Notice
  2. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  3. Dismiss Notice

Mirror or MLAPI?

Discussion in 'MLAPI' started by WeiWuDe, Mar 26, 2021.

  1. WeiWuDe

    WeiWuDe

    Joined:
    Nov 3, 2020
    Posts:
    1
    Hi there,
    i am currentlly using Mirror, since MLAPI comes out, which one should i pick to use? and One more question, i am finding a voice-chat-tool that can be used in multiplayer-game, i have tried vivox with mirror, but it has many conflicts in code with mirror, is there some solution?
     
    craiggephart and Karrix like this.
  2. Student4Life

    Student4Life

    Joined:
    Sep 28, 2016
    Posts:
    27
    I'm curious too - did you learn more since your post?
     
  3. Todiloo

    Todiloo

    Joined:
    Jan 22, 2016
    Posts:
    23
    From looking at the documentation MLAPI are waaay behind Mirror in terms of features and stability. I will keep up-to-date with the changes but I don't expect it to be ready for production in 2021.
     
  4. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,886
    You could ask the Vivox guys to update their Mirror demo.
    I talked to them at Unite once and they seemed really friendly and pretty happy about using Mirror :)
     
    hippocoder and mmoprogramming like this.
  5. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    117
    MLAPI-a crooked stub of unity developers that was thrown to unity users to shut their mouths about the net code for DOTS that they have been making for many years
     
    Cranom likes this.
  6. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    27,148
    Except the MLAPI of today is a complete re-write.

    Misinformation harms everyone, including the reputation of the person spreading it.
     
  7. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,041
    Mirror is not a good solution.
    It tries to achieve simplicity in the way of less lines of code at the cost of everything. As of today it removed some of the Linq parts but still in the main path of the hottest part of the code which is sending messages, uses reflection to get type name of each message and hash it to a number and ... for every message.

    It has been forked from uNet and they made it worse and only fixed a few none-important none-show stopper things like sync list and ... uNet is not supported by unity but neither mirror. If you are not switching to MLAPI for now, I would stick with uNet and its working features which is almost everything. Mirror doesn't solve any of its problems meaningfully. they don't scale it to bigger numbers in real environments and don't seem to know a lot about real network programming based on their technical choices in the codebase and their recommendations.

    MLAPI seem to be ok based on a few weeks of tests but I cannot say anything definitive yet.
     
  8. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    127
    Photon, pun/bolt.
    Fusion (another multiplayer solution from photon that does what pun and bolt do, except better)
    will release soon, open beta, and if it delivers on what's promised, It'll be the best ready unity integrated multiplayer solution by far.
     
  9. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    27,148
    That's like saying water is wet and if it does what it promises, it'll fix your thirst. Networking libraries require time so we'll never know if it delivers until months after it comes out.
     
    Ricky-Brno and JoNax97 like this.
  10. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,041
    Here Mirror/MessagePacking.cs at 9fe19bf8e825a6e3029a3312b3d67fba9bdd7650 · vis2k/Mirror (github.com) and it doesn't matter if you later on at least cache this/change it. The fact that you once thought that this is a good idea to call this for every send and many others like 2 threads per client in telepathy and ... means Mirror is not a good solution unless you want to focus on ease of integration with other thigns at the cost of everything else or you want to read a codebase with the smallest possible implementation.

    I have nothing personal against you and this is not a personal thing. Just these decisions lead to so much waste which is not acceptable in almost all real situations which you network library matters.
     
  11. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,041
    upload_2021-5-10_14-22-15.png

    To be clear, this calls GetType which si not fast and then FullName which is not fast and gives you a huge string and then hashes it and uses it every time. At minimum it should be cached and I would argue that users for sure should be allowed to use a method with a pre-determined code like the way uNet does it at least for hot paths and you should use it for RPC/State sync and any other high frequency message that you have too.

    You made it like this so it is easy to send messages which has other drawbacks like forcing one type per message as well to just remove short numbers and integrate with libs easier. The later is good but there are other ways to achieve it like an editor which allocates codes for libs with names so they could register names and number of codes they need and they ask for them dynamically.
     
  12. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,886
    Did this actually show up in your profiler?
    That's not Linq btw :)

    Mirror uses kcp over UDP now.

    When we used TCP, 2 threads per connection was the approach that performed best in Unity.

    We have SocketAsyncEventArgs and async/await versions of Telepathy too.
    Outside of Unity, they perform significantly better.
    Inside Unity, they don't because anything async does not scale in Unity.

    So many people got upset about 2 threads per connections. We don't like it either, but we tried every other approach and this one scaled the best in Unity when using managed sockets.

    If you have a managed TCP transport that performs better than Telepathy, please do share :)
     
    Last edited: May 10, 2021
    hippocoder and MadMojo like this.
  13. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,041
    I said you had linq and now still have things like this. I'm not going to argue with you if this is good or not. of course this is allocating lots of memory and puts presure on GC. And I'm not going to debate on KCP's relevance to a low latency, low overhead game. and of course there is nothing stopping one from creating a x thread work stealing pattern in unity instead of 2 threads per client. It is impossible that an OS changing between say 64 threads performs better than x (where x is number of hyper threads in the core - threads for your IO and other things) theread work stealing from each other.

    The fact that async event args was buggy in the mono impl of unity has nothing to do with the number of threads you chose in your implementation and choice of KCP now is irrelevant (KCP is not the best choice either anyways). The fact that your team's leadership thought that Linq and TCP with 2 threads per client were good back then and now think that doing reflection and string manipulation in the hottest path every time is fine and combined with the fact that you never wrote this and just forked mirror and made it worth is enough that nobody should use this unless somebody is using uNet and it suddenly stops working and they want to bring something up quick which mirror is good enough for.
     
  14. orangetech

    orangetech

    Joined:
    Sep 30, 2017
    Posts:
    27
    Mirror is awsome, keep going mirror!
     
    ScriptsEngineer and vis2k like this.
unityunity