Client Disconnect on VR freezes the other clients

Hi,

The players enter a VR experience either as a host or client. The players are being spawned using the Player Prefab defined in the Network Manager. So when I begin the script of StartHost() or StartClient(), the player is taken to the next scene where the player spawns. All VR interactions in the new scene work well.

But when any player leaves the experience, the controllers for the rest of the players freezes. I'm not sure why this is happening. Any help will be appreciated.

I'm handling the player disconnect using the script below

private void Singleton_OnClientDisconnectCallback(ulong id)
    {
        if (IsServer)
        {
            playersInGame.Value--;
            Debug.Log($"Id disconnected {id} and players count is {playersInGame.Value}");

        }
        else
        {
            NetworkManager.Singleton.DisconnectClient(id);
        }

    }

Debug IsServer to check for false positives and share the DisconnectClient code


So I've changed my code a bit. When any client disconnects, I'm calling a Client RPC.

private void Singleton_OnClientDisconnectCallback(ulong obj)
    {
        Debug.Log($"Client ID disconnected {obj}");
        if (IsServer)
        {
            RequestShutdownClientRpc(obj);
    }
}

[ClientRpc]
    public void RequestShutdownClientRpc(ulong id)
    {
        LobbyInGame.instance.OnDestroyLobby(id);
    }

LobbyInGame is a component on a game object in the scene, which creates Lobbies. I'm doing the shutdown for that particular client who has exited.

public async void OnDestroyLobby(ulong id)
    {
        try
        {
            string playerId = AuthenticationService.Instance.PlayerId;
            if(id.ToString() == playerId)
            {
                StopCoroutine(heartbeat);
                if (joinedLobby != null)
                {
                    if (joinedLobby.HostId == playerId)
                    {
                        await Lobbies.Instance.DeleteLobbyAsync(joinedLobby.Id);
                    }
                    else
                    {
                        await Lobbies.Instance.RemovePlayerAsync(joinedLobby.Id, playerId);
                        NetworkManager.Singleton.Shutdown();
                    }
                }
                Debug.Log("Joined Lobby now has " + joinedLobby.Players.Count);
            }
        }
        catch (Exception e)
        {
            Debug.Log($"Error shutting down lobby: {e}");
        }
    }

The controllers still freeze for all remaining clients. I don't want that to happen. When a client leaves, I want the others to continue playing.

When is Singleton_OnClientDisconnectCallback called?


The Client Disconnect code is attached to every client. So when a client leaves or closes the app, the callback is called.

Can anyone help me with this issue of the controllers freezing for everyone when a client disconnects?

I have reduced my code to contain the bare minimum logic with 1 host and one client connecting with Netcode.Singleton.StartHost() and Netcode.Singleton.StartClient().

I have one teleportation area for the player to move around. There is no lobby and relay anymore.
I've attached an image showing the components attached to my prefab, which is later spawned on the network.

Yet when the client exits, the controllers of the host freeze. All animations in the background continue to play.

9265794--1296804--Avatar.jpg

How do you read the input from the controllers, are you able to log it do see if it's still sending?