Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

(Case 1103998) XboxOneEndPoint + Unet = Majorly Broken

Discussion in '2018.3 Beta' started by Barkers-Crest, Nov 26, 2018.

  1. Barkers-Crest

    Barkers-Crest

    Joined:
    Jun 19, 2013
    Posts:
    164
    Basically, multiplayer with Unet using XboxOneEndPoint is totally broken. Works fine in 2018.2.

    The error takes place in NetworkTransport.cs

    2018.2 version:

    https://github.com/Unity-Technologi...untime/Networking/Managed/NetworkTransport.cs

    Code (CSharp):
    1.  
    2. 76:  // Convert the byte[] pointer to an IntPtr
    3. 77:  IntPtr st = new IntPtr(BitConverter.ToInt64(dst, 0));
    4. 78:  if (st == IntPtr.Zero)
    5. 79:      throw new ArgumentException("XboxOneEndPoint has an invalid SOCKET_STORAGE pointer");
    6. 80:
    7. 81:  byte[] SocketAddressFamily = new byte[2]; // short
    8. 82:  System.Runtime.InteropServices.Marshal.Copy(st, SocketAddressFamily, 0, SocketAddressFamily.Length);
    9. 83:
    10. 84:  System.Net.Sockets.AddressFamily a = (System.Net.Sockets.AddressFamily)((((int)SocketAddressFamily[1]) << 8) + (int)SocketAddressFamily[0]);
    11. 85:  if (a != System.Net.Sockets.AddressFamily.InterNetworkV6)
    12. 86:      throw new ArgumentException("XboxOneEndPoint has corrupt or invalid SOCKET_STORAGE pointer");
    13.  
    2018.3 version:

    https://github.com/Unity-Technologi...untime/Networking/Managed/NetworkTransport.cs

    Code (CSharp):
    1. 76:  byte[] SocketAddressFamily = new byte[2]; // short
    2. 77:  Buffer.BlockCopy(dst, 0, SocketAddressFamily, 0, SocketAddressFamily.Length);
    3. 78:
    4. 79:  System.Net.Sockets.AddressFamily a = (System.Net.Sockets.AddressFamily)((((int)SocketAddressFamily[1]) << 8) + (int)SocketAddressFamily[0]);
    5. 80:  if (a != System.Net.Sockets.AddressFamily.InterNetworkV6)
    6. 81:      throw new ArgumentException("XboxOneEndPoint has corrupt or invalid SOCKET_STORAGE pointer");
    Basic issue is line 79 of 2018.3 version is performing an operation on the memory address.

    2018.2 is performing the operation on the value at the memory address (See line 82 of 2018.2 version to where it reads the value of the memory)

    This is happening on UWP build. I haven't tested on Xbox One but I suppose it will break there as well.

    Any idea on a time frame for this getting fixed? I'd love to be able to ship on 2018.3 because 2018.2 has a different show stopping bug that isn't getting any attention but is fixed in 2018.3.
     
  2. alexandrum

    alexandrum

    Unity Technologies

    Joined:
    May 5, 2017
    Posts:
    199
    Having a look at this now.
     
  3. alexandrum

    alexandrum

    Unity Technologies

    Joined:
    May 5, 2017
    Posts:
    199
    So I've fixed this by reverting some of the code that was removed in 2018.3:

    Code (CSharp):
    1. 74:                // Convert the byte[] pointer to an IntPtr so we can marshal copy info from the underlying native socket object below
    2. 75:                IntPtr socketPointer = new IntPtr(BitConverter.ToInt64(dst, 0));
    3. 76:                if (socketPointer == IntPtr.Zero)
    4. 77:                    throw new ArgumentException("XboxOneEndPoint has an invalid SOCKET_STORAGE pointer");
    5. 78:
    6. 79:                // check that the socket pointed to by socketPointer has an address family of type IPv6
    7. 80:                byte[] SocketAddressFamily = new byte[2]; // short
    8. 81:                System.Runtime.InteropServices.Marshal.Copy(socketPointer, SocketAddressFamily, 0, SocketAddressFamily.Length); // copy over the first 2 bytes from the object pointed to by socketPointer
    9. 82:                System.Net.Sockets.AddressFamily a = (System.Net.Sockets.AddressFamily)((((int)SocketAddressFamily[1]) << 8) + (int)SocketAddressFamily[0]);
    10. 83:                if (a != System.Net.Sockets.AddressFamily.InterNetworkV6)
    11. 84:                    throw new ArgumentException("XboxOneEndPoint has corrupt or invalid SOCKET_STORAGE pointer");
    12. 85:
    13. 86:                // everything should be OK so call the internal function to begin the connect handshake to this socket
    14. 87:                return Internal_ConnectEndPoint(hostId, dst, kSockAddrStorageLength, exceptionConnectionId, out error);
    This is now being PRed internally into the networking extension repo code and into 2018.3. I'm trying to hurry my PR along so it can get into the next 2018.3 release (which is currently being planned to be the first release candidate) so fingers crossed.
     
    Barkers-Crest and LeonhardP like this.