Unity Netcode scene loading stops working fo clients when adding ~20 in-scene NetworkObjects

Hi!

I’m having a strange issue with Netcode for GameObjects scene loading.

I’m using:

  • Unity 6000.2.0b11
  • Netcode for GameObjects 2.13.1
  • Unity Transport
  • Unity Multiplayer Services / Relay
  • NetworkSceneManager for scene loading

I have a scene with multiple in-scene NetworkObjects. The objects are footprints that can later be cleaned by players.

The problem is reproducible based purely on the number of NetworkObjects in the scene:

  • With around 10 NetworkObjects, the scene loads correctly for both Host and Client.
  • With around 20 NetworkObjects, the Host loads the scene successfully, but the Client does not even receive SceneEventType.Load.
  • The Client therefore does not start loading the scene at all.

The scene is loaded by the Host with:

NetworkManager.Singleton.SceneManager.LoadScene(
    sceneName,
    LoadSceneMode.Single);

The returned status is:

SceneEventProgressStatus.Started

The Host successfully loads the Unity scene and the in-scene NetworkObjects are spawned. I can see Start() and OnNetworkSpawn() being called on the Host.

I also tried completely removing all logic from the Footprint component, including Start(), OnNetworkSpawn(), NetworkVariables, etc. The problem remains.

The Footprint component is essentially just:

public class Footprint : NetworkBehaviour
{
}

The only relevant component on the GameObject is NetworkObject.

Interestingly, if I disable the NetworkObject components on these objects, the same scene loads correctly on the Client.

There is also an important difference in OnLoadEventCompleted:

When the scene loads successfully for both Host and Client, this callback is invoked on the Host:

NetworkManager.Singleton.SceneManager.OnLoadEventCompleted

When there are enough in-scene NetworkObjects and the Client does not start loading, OnLoadEventCompleted is not invoked on the Host either.

So the sequence appears to be:

Working case:

Host calls NetworkSceneManager.LoadScene()
        ↓
Host loads the scene
        ↓
In-scene NetworkObjects are spawned
        ↓
Client receives SceneEventType.Load
        ↓
Client loads the scene
        ↓
OnLoadEventCompleted is invoked on Host

Failing case:

Host calls NetworkSceneManager.LoadScene()
        ↓
Host loads the scene
        ↓
In-scene NetworkObjects are spawned
        ↓
Client does NOT receive SceneEventType.Load
        ↓
OnLoadEventCompleted is NOT invoked on Host

I have verified that:

  • The scene is included in Build Settings.
  • The scene contains valid NetworkObjects.
  • The issue is reproducible by changing only the number of in-scene NetworkObjects.
  • Removing the NetworkObject components makes the scene load correctly.
  • Removing all logic from the NetworkBehaviour does not fix the issue.

Could there be some limit related to the number or size of in-scene NetworkObjects, scene object synchronization, message size, or Unity Transport?

Is there a recommended way to diagnose why the Host does not send the SceneEventType.Load event to the Client in this situation?

Any pointers on where in NetworkSceneManager / scene synchronization I should look would be greatly appreciated.

Thanks!

P.S. Additional observation:

I also tested the same objects using runtime spawning instead of placing them in the scene.

The Host loads the scene first, then spawns 20 Footprint NetworkObjects at runtime. Everything works correctly.

I then connect the Client after all 20 objects have already been spawned, and the Client successfully connects and synchronizes all of them.

So 20 NetworkObjects themselves do not seem to be the problem. The issue appears to be specifically related to having ~20 in-scene placed NetworkObjects during NetworkSceneManager.LoadScene() while the Client is already connected.

In other words:

  • 20 runtime-spawned NetworkObjects → works.
  • Client joins after 20 runtime-spawned NetworkObjects already exist → works.
  • ~20 in-scene NetworkObjects during network scene loading → Client does not receive SceneEventType.Load, and OnLoadEventCompleted is not invoked on the Host.

Hi @Volandpro,

I am attaching a project that uses NGO v2.13.1 and spawns:

  • 100 in-scene placed prefab instances
    • Based on a network prefab
  • 100 in-scene created NetworkObject instances
    • Created and placed “in-scene” (i.e. not based off of an in-scene placed network prefab instance)

ManyInScenePlaced.zip (713.2 KB)

When you open the project, load the ManyInScenePlaced scene which should look like this:

There are two root nodes (for organizational purposes really):

  • InScenePlacedPrefabInstances

  • InSceneCreatedInstances

Effectively, it contains and will synchronize 200 in-scene placed NetworkObjects.

The NetworkManager actually contains an “ExtendedNetworkManager” component that handles various connection and network topology types. Since you listed relay as being part of your configuration, I went ahead and configured it for a relay connection.

**Note: you will want to register the project with your Unity services account to connect via relay.

Once you have registered the project with your services account, create at least 1 MPPM (Multiplayer Playmode) virtual clients to connect the client with and use the main editor as your host.

Finally, enter play mode and you should be confronted with creating (host) or joining (client) the session.

When you create/host a relay session you should see all of the in-scene placed NetworkObjects generate a spawned message:

You will also see the relay join key in the top left corner of the host’s Game view. Use this to connect your client. Upon the client connecting, you should see that all of the in-scene placed NetworkObjects are spawned.

Using the Hierarchy view on the MPPM virtual client, you can expand each group and verify every instance was spawned.

Take a look at the project (link included above at top) and see what the primary differences are between the two as you should be able to spawn way more than 20…like at least 100x more.

If you can replicate it using that project by making adjustments to better fit how you have setup your project then feel free to zip up the same folders included in the original zip file and post that here so we can see what might be causing this issue.

Hello!

Thank you for your answer!

I’ve installed Unity 6000.4.0f1, downloaded your project and tried to run as you said.

I tested it without making any changes, and I’m seeing the same behavior on the client side. The client successfully starts connecting to the session:

Client connecting to session.

but shortly afterwards it gets disconnected:

Disconnected event invoked for Client-0.
Connection event ClientDisconnected for Client-0.
NetworkManager has stopped.

I would like to understand the exact reason for this disconnect rather than just seeing the OnClientDisconnect event.

Could you please advise how I can get more detailed information about why the client is being disconnected? Is there a specific NGO/Unity Transport/Relay callback, log, disconnect reason, error code, or debug setting that I should enable?

In particular, I would like to determine whether the disconnect is caused by Relay, Unity Transport, NGO, or some project/configuration issue.

What would be the best way to diagnose the root cause of this disconnect?

P.S. I also tested the same project with Relay disabled (UseRelay = false). In that case, the connection works correctly.

So the behavior is:

  • Relay ON → client disconnects
  • Relay OFF → connection works correctly

This makes me think the issue is specifically related to the Relay connection. Is there a way to get more detailed information about what causes the client to disconnect when using Relay?

On the NetworkManager, you can set the “log level” to “developer” which should provide more information. Atleast it’s something you can try.

FWIW b11 indicates a BETA version. These are not for production use but for beta-testing only. You are supposed to keep updating these once the beta period is over.

When you download a newer Unity version for the first time, always (!) download the latest release version not the first (0f1 - which is the almost-still-beta version).

Both BETA and early releases will have more issues than usual, the higher the “f” release number the more stable it generally is.

Hey @Volandpro,

I was seeing a similar issue yesterday where I could get around 400(ish) in-scene placed objects synchronized but going beyond that caused a “silent disconnect”.

Now, I am able to get (so far) up to 2,000 without the client being silently disconnected.

Could you re-try today (in case there was some kind of update to fix this issue) to verify you are still having issues with Relay.

If you are, post back here and I will get someone from the services group to investigate this issue further.

Hello!

I tried your project with Unity 6000.5.7f1, but unfortunately it didn’t help. I’m experiencing the same issue: when Relay is enabled, the client cannot connect to the host. When Relay is disabled, the connection works successfully.

@Volandpro
Are you connected to a VPN?

Hello!

Yes, I tried changing the settings you suggested. I increased both Heartbeat Timeout MS and Spawn Timeout, but unfortunately neither of them helped.

I also see the following messages in the logs:

  • Client connecting to session.
  • [Netcode] [Approval Pending][Client] Transport connection with server established! Awaiting connection approval…
  • [Netcode] Timed out waiting for the server to approve the connection request.

I also tried increasing Connect Timeout MS to 50000, but that didn’t make any difference either.

Oh… you are using connection approval?
That is an important piece of information.

The project I posted here is not using connection approval.
Did you make that change to the project I sent you or are you using your project?

Either case, if you are using connection approval and getting disconnected early you will want to increase the Client Connection Buffer Timeout:

Really, I would:

  • Disable connection approval 1st
    • Verify the client can connect without the connection approval.
    • If not, then post here the message you are getting.
    • If so, then enable connection approval with an increased timeout.
      • See if that resolves your issue.

What kind of information are you sending during the client approval process and are you having to contact an external service (or the like)?

@Volandpro

I have updated the project to use WSS (Websockets which basically uses TCP/IP):
ManyInSceneWSS.zip (847.8 KB)

I increased the total in-scene placed to 2000 objects.
I can connect and synchronize a virtual MPPM client whether connected to VPN or not.

Can you check to see if by using the above modified project you can successfully get the client to synchronize all 2k in-scene placed from your side?

Hello! Sorry for the delayed response.

I tried these settings, and everything connects successfully (although the connection process is quite slow). Please note that I am not using Connection Approval — it was disabled before, and I have not enabled it.

What is strange is that yesterday I tested the exact same settings and could not get a successful connection at all.

I also think that using WebSockets over TCP may not be the best option in this case because of potential issues with latency and network delays.

Tomorrow I will try different configurations in my own project and will share the results here.