godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.14k stars 21.19k forks source link

Godot v4.2.1, Window hosting server (ENetMultiplayer) closes without error message. #88610

Closed Ery0l closed 8 months ago

Ery0l commented 8 months ago

Tested versions

Used version: v4.2.1.stable.official [b09f793f5]

System information

Godot v4.2.1.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2060 (NVIDIA; 31.0.15.5152) - AMD Ryzen 5 5600X 6-Core Processor (12 Threads)

Issue description

Server window of the project is hosted and runs without problem. As soon as a client joins, all steps to add the client properly are run through. Once the player is spawned in the world on the client screen a short audio glitch occurs, similar to as if my pc was experiencing 100% cpu load, however viewing NZXT shows no spike in load. A few more instances of _process are run, between 1 and 4 in my experience. Then the window closes as if manually closed. This started occuring after I simplified the code, making the client movement run clientside instead of serverside. Video below

https://github.com/godotengine/godot/assets/160662669/54663245-d5b6-4a33-a7e4-3df7691636ed

Console output:

1981
1982
1983
1984
1985
1986
Player with ID: 751670674 connected to Server
add player started
Player ready finished
Add player ended
Player connection finished
1987
1988
--- Debugging process stopped ---

Steps to reproduce

Ive attached both projects as MRP. They are incredibly small, I have no idea what could possibly be causing this Launch server (automatic upon starting the project TEST SERVER) Launch Client Join, port and IP should be set up correctly already

Minimal reproduction project (MRP)

MRP.zip

Ery0l commented 8 months ago

Further testing has been done: The crash does NOT occur if the player node doesn't get its name changed to be equal to its multiplayer id. However, doing so is a necessary step for identification and player interaction

Ery0l commented 8 months ago

Further testing: MultiplayerSynchronizer is the cause of the crash. If it has a config to sync up ANY value, it will cause the server to shut down

brennennen commented 8 months ago

I couldn't re-create the crash, there were several issues when I tried to open the MRP projects (corrupt PlayerCharacter.tscn in the server project, an issue with the server PlayerCharacter.gd script extending node2d, and some missing textures). I tried to fix the issues mentioned above (see screen shot and zip), the client doesn't crash and can move around. In performing one of the fixes, the server started spawning the player/peer though, which I don't believe is your intended behavior. The crash issue may have been something associated with the ".godot" cache folder you didn't upload?

image MRP_bren.zip (I've also added the "LogMultiplayer.gd" script mentioned here: https://docs.godotengine.org/en/stable/classes/class_multiplayerapiextension.html to the project, it's a nice starting point to have some visibility into how the SceneMultiplayer stuff operates).

When the runtime windows close like that, they've crashed. I've only been able to generate crash reports from run instances by building godot from source with "dev_buld=yes" and running godot from command line. For an example of what I'm talking about, see the description here: https://github.com/godotengine/godot/issues/88263. If you can do this, and copy paste the console output. Otherwise, can you download and see if you can re-open your own MRP? If you can't, do you mind tinkering with it and uploading a new one?

All that being said though, I see you have 2 separate projects in your MRP. One for the server and one for the client. From what I've seen, I don't think this kind of paradigm is going to work very well with the godot high level multiplayer system. The high level multiplayer assumes you have the exact same scene trees between your client and server for any node it needs to interact with. You can't call RPCs or use the MultiplayerSynchronizer on nodes are not the ~exact~ same and have the same path on the client and server. Keeping your scene trees exactly the same across multiple projects is going to be difficult and I believe where you went wrong.

I see two things in particular that might be causing the issue:

hope this helps and good luck!

Ery0l commented 8 months ago

I appreciate your response. By now ive isolated it to multiplayerSynchronizer for some reason crashing the server if it sends any data from the client. Ive decided to just not use the node and send packets over script instead. I didnt upload the .godot folder because the instructions in the bug report said not to ^^'. Two files should be fine, its simply a dedicated server which is rare for godot but does work as long as im thorough. The player on the server being a node2D was intentional as well. I wanted a simple 2d-icon that would represent the players location from a topdown view. I had function that would kick a player if one clicked on it in the server window, but stripped that in my bug testing. Rpc functions being different on client server is normal for a dedicated build. They must have the same names and take the same data, but dont have to fulfill the same function. I think if its okay I'll just isolate it to "MultiplayerSynchronizer is buggy" and end it at that, I'm not knowledgable enough yet to properly dive into it, i've only gotten into godot and coding in general a few months ago ^^'

Ery0l commented 8 months ago

(Closed since I'm not smart enough to find the actual issue, but bug still exists)