Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netcode 1.5.1 crash in Build using Relay #2600

Open
Schuebl opened this issue Jun 27, 2023 · 0 comments
Open

Netcode 1.5.1 crash in Build using Relay #2600

Schuebl opened this issue Jun 27, 2023 · 0 comments
Assignees
Labels
priority:high stat:imported Issue is tracked internally at Unity type:bug Bug Report

Comments

@Schuebl
Copy link

Schuebl commented Jun 27, 2023

Description

I'm actually try to initialize a Relay service with this simple code based on the Codemonkey Relay-Service tutorial. Authorization has been completed successfully:

private async void CreateRelayConnection()
{
      try
      {
             Allocation allocation = await RelayService.Instance.CreateAllocationAsync(4);
             var JoinCode = await RelayService.Instance.GetJoinCodeAsync(allocation.AllocationId);
             Debug.Log("JoinCode: " + JoinCode);
 
             var transport = NetworkManager.Singleton.GetComponent<UnityTransport>();
             if(null!= transport)
             {
                   transport.SetHostRelayData(
                        allocation.RelayServer.IpV4,
                        (ushort)allocation.RelayServer.Port,
                        allocation.AllocationIdBytes,
                        allocation.Key,
                        allocation.ConnectionData
                   );
                   Debug.Log("Relay Server initialized");
                   NetworkManager.Singleton.StartHost();
                   Debug.Log("Host successfull started");
             }
     }
     catch(RelayServiceException e)
     {
           Debug.Log(e.ToString());
     }
 }

Starting everything from Unity, this code works like a charm and the service is initialized successfully.
If I use a (Development) Build this code fails when calling StartHost() with this failure:

UnloadTime: 0.905900 ms
Data created: Main Menu
Signed in Anonymously: fuiSi2okDQL0SDCXWWF8QB8D86Q9
best region is europe-west2
JoinCode generated: K6DNCD
Relay Server initialized
ArgumentException: An item with the same key has already been added. Key: -1
at System.Collections.Generic.Dictionary2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x000dd] in <605bf8b31fcb444b85176da963870aa7>:0 at System.Collections.Generic.Dictionary2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <605bf8b31fcb444b85176da963870aa7>:0
at Unity.Netcode.NetworkSceneManager.GenerateScenesInBuild () [0x0004a] in :0
at Unity.Netcode.NetworkSceneManager..ctor (Unity.Netcode.NetworkManager networkManager) [0x00091] in :0
at Unity.Netcode.NetworkManager.Initialize (System.Boolean server) [0x0013f] in :0
at Unity.Netcode.NetworkManager.StartHost () [0x00030] in :0
at binrev.netcode.UIHostConnection.OpenConnection () [0x00066] in <9624421bb2774c9980efe3ed0782b5b9>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) [0x00000] in <605bf8b31fcb444b85176da963870aa7>:0
at UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () [0x00002] in <420f675e2d6b4f17877563ada0d329b3>:0
at UnityEngine.UnitySynchronizationContext.Exec () [0x0005d] in <420f675e2d6b4f17877563ada0d329b3>:0
at UnityEngine.UnitySynchronizationContext.ExecuteTasks () [0x00014] in <420f675e2d6b4f17877563ada0d329b3>:0

NullReferenceException: Object reference not set to an instance of an object
at Unity.Netcode.NetworkManager.NetworkUpdate (Unity.Netcode.NetworkUpdateStage updateStage) [0x0004c] in :0
at Unity.Netcode.NetworkUpdateLoop.RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage updateStage) [0x00021] in :0
at Unity.Netcode.NetworkUpdateLoop+NetworkPostLateUpdate+<>c.b__0_0 () [0x00000] in :0

The NullReferenceException then is thrown endless every second.
The Code is triggert by a simple UIScript UIHostConnection, listen to a Button which invokes the OpenConnection method.
This method only triggers this code. The UI script is inherited from MonoBehaviour.
I also tried to use NetworkBehaviour, but this has no different effect.

Reproduce Steps

  1. Run this snipped in Unity, anything works like expected.
  2. Create a Build (Development), this snipped crashes on StartHost call

Environment

  • OS: Windows 10
  • Unity Version: 2022.3.3f1
  • Netcode Version: 1.5.1
  • Relay Version: 1.0.5

Additional Context

Player.log
HostConnection.txt

@Schuebl Schuebl added stat:awaiting triage Status - Awaiting triage from the Netcode team. type:bug Bug Report labels Jun 27, 2023
@fluong6 fluong6 added priority:high stat:import stat:imported Issue is tracked internally at Unity and removed stat:awaiting triage Status - Awaiting triage from the Netcode team. stat:import labels Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:high stat:imported Issue is tracked internally at Unity type:bug Bug Report
Projects
None yet
Development

No branches or pull requests

3 participants