godotengine / godotengine/godot

Passing zero-length array when Rpc-Calling a method that accepts one byte array results in `Rpc Method not found.`

Open
#95,247 10 comments 3 reactions 0 assignees View on GitHub
discussion topic:multiplayer
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

Reproducible in:
- 4.2.1 stable
- 4.3.0 dev6
- 4.3.0 rc2

### System information

Godot v4.3.rc2.mono - Windows 10.0.17763 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4060 Ti (NVIDIA; 31.0.15.5222) - AMD Ryzen 9 5900X 12-Core Processor (24 Threads)

### Issue description

As the title mentioned, assume we have a method that matches the following signature:
```csharp
[Rpc] private void TestRpc(byte[] byteArray)
```

```gdscript
@rpc
func test_rpc(byte_array: PackedByteArray)
```

If we attempt to call this method with a zero-length byte array
```csharp
Rpc("TestRpc", new byte[0])
```

```gdscript
rpc("test_rpc", PackedByteArray())
```

Godot will report
- For `C#`
```
E 0:00:03:0553 _process_rpc: RPC - 'Control(MainCS.cs)::TestRpc': Method not found
modules/multiplayer/scene_rpc_interface.cpp:290 @ _process_rpc()
```

- For `GDScript`
```
E 0:00:03:0934 _process_rpc: RPC - 'Control(main.gd)::test_rpc': Method expected 1 arguments, but called with 0
modules/multiplayer/scene_rpc_interface.cpp:290 @ _process_rpc()
```

~~This issue is only in the `C#` scripts, not in the corresponding `GDScript` implementation.~~
Thanks @AThousandShips for pointing out my mistake in the `GDScript` implementation

### Steps to reproduce

1. Download and open the MRP with `Godot 4.3.0 rc2 with .Net module`.
2. From the `Debug/Customize Run Instances`, enable `Multiple Instances` and set the instance number to 2, then close the `Run Instances` window.
3. Build and Run the project.
4. In one of the opening windows, press `As Host`.
5. In the other window, press `As Client`.
6. Inspect the error in the `Debugger` panel.

### Minimal reproduction project (MRP)

~~A `GDScript` replica has been included in this MRP to demonstrate this issue only affects C#.~~

~~[MrpPbArrayError.zip](https://github.com/user-attachments/files/16522787/MrpPbArrayError.zip)~~

This updated version includes both `GDScript` and `C#` implementations.

[MrpPbArrayErrorNew.zip](https://github.com/user-attachments/files/16529239/MrpPbArrayErrorNew.zip)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the updated MrpPbArrayErrorNew.zip using the listed Godot versions and inspect modules/multiplayer/scene_rpc_interface.cpp at line 290. Compare the C# and GDScript zero-length byte-array calls; done means both RPC methods are found and invoked without the reported argument errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, csharp
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.