Added rpc_node_notfound signal to SceneTree and MultiplayerAPI - #23893
Added rpc_node_notfound signal to SceneTree and MultiplayerAPI#23893alimalkhalifa wants to merge 1 commit into
Conversation
eda3880 to
4d78381
Compare
|
CC @Faless |
|
Somewhat relevant: #24681 |
| if (!node) | ||
| if (!node) { | ||
| emit_signal("rpc_node_notfound", String(np)); | ||
| ERR_PRINTS("Failed to get path from RPC: " + String(np)); |
| if (!node) | ||
| if (!node) { | ||
| emit_signal("rpc_node_notfound", String(ni->path)); | ||
| ERR_PRINTS("Failed to get cached path from RPC: " + String(ni->path)); |
| ADD_SIGNAL(MethodInfo("connected_to_server")); | ||
| ADD_SIGNAL(MethodInfo("connection_failed")); | ||
| ADD_SIGNAL(MethodInfo("server_disconnected")); | ||
| ADD_SIGNAL(MethodInfo("rpc_node_notfound", PropertyInfo(Variant::STRING, "node_name"))); |
There was a problem hiding this comment.
Is there anything left that's required to be able to use it purely on the MultiplayerAPI itself instead of the SceneTree? As it's the case when using CustomMultiplayer. SceneTree got a "ClassDB::bind_method" added - might that be missing?
|
Hi @alimalkhalifa , sorry about the very late reply. There are at least 2 things to consider:
Additionally, there's no need to modify |
|
Moving to the next milestone as this won't be ready to merge for the imminent 3.2. @alimalkhalifa see the review comments by @Faless above, there would be changes necessary. |
|
I had missed the reply. I could use a bit of direction on where to implement this. I'll take a look and maybe make a new PR for 4.0 with a more well thought out solution |
|
@Faless The "node not found" errors can sometimes make the client hang if the server miscalculates and starts sending data before the client has finished populating all the game objects. It can be worked around with some foresight, but preferably ~50 server-side objects should not cause the client to irretrievably hang, for a reasonably non-critical error. Emitting signals from my experience also gets expensive on the main process thread (relative to direct method calls), with a large number of objects spamming |
|
My work around has been to limit movement updates to a movement update node. It also consolidates the updates so that's a plus. That gets rid of most issues. |
|
@alimalkhalifa Is this still desired? If so, it needs to be rebased on the latest master branch. If not, abandoned pull requests will be closed in the future as announced here. |
|
@aaronfranke I will pose this question on Discord/IRC to see the general consensus. This is definitely something that can be handled in GDScript, but it is a lot of boiler plate for something that is a common issue. However, the counter argument is that different scenarios might require different solutions, and this is a non-issue in lobby->game type scenarios. That said, I still believe everyone will benefit from error signals on the NetworkPeer for node issues. Willing to give it another go from my end to sort out the above concerns and resubmit. For the record, I forced a situation where a desync happens and causes a node to only exist on server. This is the output on client debug: |
|
This PR has not received any new commits for over a year, closing. |
rpc_node_notfound signal
Affected classes
Objective
I have added an rpc_node_notfound signal in SceneTree to make the multiplayer system more usable in real-life use cases. The main issue I keep facing is a Node Tree Desync between server and client, where the client will keep throwing Node Not Found exceptions when a node on the server uses an RPC. This is a typical problem for me with movement synchronization. I had found myself implementing multiplayer on a NetworkController node instead of on the game nodes themselves to avoid this issue.
The solution
I have added an rpc_node_notfound signal on the SceneTree which is emitted whenever the client receives an RPC for a node that it does not have. This allows you to connect the signal to a function that does an RPC to request missing nodes from the server.
Note
Please be gentle, this is my first PR to this project :) Let me know if I have overstepped somehow or if this PR is undesirable or if I can improve my PR somehow to be more in line with the project.