Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity Transport/Netcode for Android

Discussion in 'NetCode for ECS' started by LiminalTeam, Feb 12, 2020.

  1. LiminalTeam

    LiminalTeam

    Joined:
    Sep 17, 2019
    Posts:
    6
    Hey guys, I've searching a little around, does anyone know if Unity Transport system support mobile at the moment?
     
    Last edited: Feb 12, 2020
  2. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    We do have socket implementations for android and ios so it works on both. There is a burst related bug on ios which causes it to only work there if you disable burst right now, android does not have that issue.
     
  3. khalid_mightybear

    khalid_mightybear

    Joined:
    Sep 10, 2017
    Posts:
    36
    May I know what the bug is so that I can track it? Planning to test it on ios devices soon.
     
  4. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    It's not in any public bug tracker, only internal ones. The bug is filed against burst, but we are also working on changing the socket backend for the transport which will also fix it - and I don't know which one of those will be available first.
     
  5. khalid_mightybear

    khalid_mightybear

    Joined:
    Sep 10, 2017
    Posts:
    36
    Any updates on a ios fix? I can't get it to work with burst disabled for ios either.
     
  6. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    We have released netcode 0.1 and transport 0.3 which switch to a new socket backend when using Unity 20.1. Unfortunately that suffers from another bug which needs to be fixed in Unity 20.1 before it works - I do not have a concrete date for when that fix will be available.
     
  7. khalid_mightybear

    khalid_mightybear

    Joined:
    Sep 10, 2017
    Posts:
    36
    would the new packages be backported to 2019.3?
     
  8. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    The package is using a new API in Unity which is not available in 19.3 to implement the new socket interface. I am not yet sure if that new API will be backported. If it is backported the package can use the new backend on 19.3 by setting a define.
     
  9. NovaEiz

    NovaEiz

    Joined:
    Sep 6, 2017
    Posts:
    53
    The following line does not work in "RpcCommandRequestSystem":

    Code (CSharp):
    1.  
    2.             m_ConnectionsQuery = EntityManager.CreateEntityQuery(ComponentType.ReadWrite<NetworkIdComponent>(),
    3.                 ComponentType.Exclude<NetworkStreamDisconnected>());
    , but this line works:

    Code (CSharp):
    1.  
    2.             m_ConnectionsQuery = EntityManager.CreateEntityQuery(ComponentType.ReadWrite<NetworkStreamConnection>(),
    3.                 ComponentType.Exclude<NetworkStreamDisconnected>());
    How so?
     
  10. NovaEiz

    NovaEiz

    Joined:
    Sep 6, 2017
    Posts:
    53
    This works:
    Code (CSharp):
    1.  
    2.  
    3.    if (battleSearchBuffer.Length == battleMode.Players) {
    4.       var playersArray = battleSearchBuffer.ToNativeArray(Allocator.Temp);
    5.       EntityManager.AddComponentData(entity, new WaitForPlayersToBeAccepted());
    6.  
    , but this no works:


    Code (CSharp):
    1.  
    2.  
    3.    if (battleSearchBuffer.Length == battleMode.Players) {
    4.       EntityManager.AddComponentData(entity, new WaitForPlayersToBeAccepted());
    5.       var playersArray = battleSearchBuffer.ToNativeArray(Allocator.Temp);
    6.  

    Error:

    InvalidOperationException: The UNKNOWN_OBJECT_TYPE has been deallocated, it is not allowed to access it
    Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckReadAndThrowNoEarlyOut (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <4c8f575a88be4f32bda3dc03553fa48a>:0)
    Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckReadAndThrow (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at /Users/builduser/buildslave/unity/build/Runtime/Export/Jobs/AtomicSafetyHandle.bindings.cs:151)
    Unity.Entities.DynamicBuffer`1[T].CheckReadAccess () (at Library/PackageCache/com.unity.entities@0.6.0-preview.24/Unity.Entities/Iterators/DynamicBuffer.cs:133)
    Unity.Entities.DynamicBuffer`1[T].AsNativeArray () (at Library/PackageCache/com.unity.entities@0.6.0-preview.24/Unity.Entities/Iterators/DynamicBuffer.cs:446)
    Unity.Entities.DynamicBuffer`1[T].ToNativeArray (Unity.Collections.Allocator allocator) (at Library/PackageCache/com.unity.entities@0.6.0-preview.24/Unity.Entities/Iterators/DynamicBuffer.cs:485)
     
  11. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Is there any documentation to understand what the new sockets are?

    Looking through the Transport package, there is BaselibNetworkInterface - looks like this is the new one.
    How are the sockets different this time?
    Are they not using mono's sockets anymore, but native C instead again?
    While working on Mirror we had endless issues with mono's sockets, so having a native alternative would be huge.

    What exactly is the bug that still needs to be fixed in 20.1?

    Also, I just noticed that you have a receive job. Didn't Unity say jobs were not meant for IO?
    If not, in which cases are jobs fine for IO?

    Thanks :)
     
  12. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    Not sure where you are changing that, but in general rpcs are used to go in game, so if they must be able to send requests before ghosting starts.
    Performing structural changes using the entity manager will invalidate the buffer, so accessing a buffer after a structural change is not allowed.
     
  13. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    They were never using mono sockets. The old sockets were c implementation of bsd sockets, the new lives inside unity and is more similar to regiostered io in windows, which reduces the number of copies to send a message.

    The job system is not meant for blocking io, the job we have is just polling the socket to see if there is data - which is fine since it is not blocking the cpu thread without doing any processing.
     
  14. NovaEiz

    NovaEiz

    Joined:
    Sep 6, 2017
    Posts:
    53
    Thank you for your answers.
    I have long understood in practice what is the reason for the problems.

    You must send the RPC to the connection after the connection entity has received the NetworkIdComponent.


    Please tell me, when will the new Transport package for working in Tiny be released?