Skip to content

RPCs are being called endlessly after exception is thrown in a RPC #725

Closed
@JakobLindner

Description

@JakobLindner

Describe the bug
When calling multiple RPCs in the same frame and one of them throws an exception, the RPC and all other RPCs called before it are executed over and over again.
This also happens when the RPC that throws the exception is unreliable.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new GameObject
  2. Attach a NetworkObject component to it
  3. Attach the folowing C# script as component to it:
using System;
using System.Collections;
using System.Collections.Generic;
using MLAPI;
using MLAPI.Messaging;
using UnityEngine;

public class Bug : NetworkBehaviour
{
    public override void NetworkStart()
    {
        StartGame();
    }
    
    private void StartGame()
    {
        if (IsHost)
        {
            Debug.Log("start");
            FirstClientRpc();
            SecondClientRpc();
        }
    }

    [ClientRpc]
    private void FirstClientRpc()
    {
        Debug.Log("first");
    }
    
    [ClientRpc] // [ClientRpc(Delivery = RpcDelivery.Unreliable)] also causes the same error
    private void SecondClientRpc()
    {
        Debug.Log("second");
        throw new NotImplementedException(); // or any other exception
    }
}
  1. Run game in editor
  2. Start host on network manager
  3. See error (the RPCs are called multiple times like in the screenshot)

Expected behavior
All RPCs are only called once and then either unreliable or all RPCs that throw an exception are dropped.

Screenshots
MLAPI_bug

Environment:

  • OS: Windows 10
  • Unity Version: 2020.3.2f1
  • MLAPI Version: v0.1.0
  • MLAPI Commit: 3e3aef6

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions