-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Game crashes when calling peer.disconnect_peer #12
Comments
Hello bugbountyguy! You will check with my example code or bomberman (which is in the demo branch) and also with my personal project. a question: what is your platform? Could you provide a code to verify how you are using it? mainly after leave lobby? |
No worries on the delay, totally understand :) To answer "what system" - this is Godot (vanilla, with godotsteam/steam-multiplayer-peer gdextensions) on Linux 64-bit (so all testing/etc. is done through Linux) So just to provide a little more details so it's clear what the problem is and how I'm trying to solve it - and then the bug that seems to exist from trying to solve it: The scenario: When a client is connected to a host in a game, and the client crashes or kills their game (ungracefully), there's an obvious disconnect there in the game. In my logs, I can clearly see a disconnect, as the log shows "Player has left the lobby". This comes from the method The problem: If the player's game is terminated unexpectedly, and they re-join the lobby before their RPC session is dropped, there is a brief moment where there are "two" of the player in the game. When that 10 second timer hits, both instances are destroyed and the player's dropped from the lobby. The two issues here being: There's a duplicate of the player, and whether or not we find a way to clean that previous session up, the RPC from the previous connection is lost and causes the current connection to also drop. The solution: As I was able to get the immediate feedback from the player leaving the lobby, I thought I would use that to call The bug: Calling the For a code snippet, basically it's all centered around these parts in my game (trimmed down for the sake of this issue):
I hope this provides a clearer picture to this issue! I should have posted these details above, but I opened the issue at a time where my brain was already melting while trying to find hacky solutions around this lol. |
Very clear now, thank for details! Previously I admit two things:
Thank you for your attention! |
@bugbountyguy 1 - In the connection close method (It is made in my game) 2 - When giving Anyway, I'm going to release update 0.0.6 today by placing some more explanatory warnings within the |
@bugbountyguy trying add |
I'm not home to verify this, but I think the problem with calling close() is that it would close the connection to all peers when the host calls this, right? If it was just a 2 player game, this would be okay, but for games that have 3 or more players, this would kill the game/connection for all players. The goal with doing a clean close with disconnect_peer allows to disconnect just one peer from the game and let the rest of the players and host continue playing. This is especially ideal for a player who might have crashed from the game. That being said... I wonder if it's possible to have an array of all player peer connections? But I'm not sure, will have to investigate when I get home. |
@scriptsengineer okay to update on my last post: Yes,
The method
I think I read a post somewhere (can't remember if I saw it on reddit, discord, or what) that the regular Godot rpc MultiplayerPeer will disconnect connections like it's supposed to when using the Would it be possible to find out the flow made when a client 'crashes' (force kills the app) and then the rpc connection is lost after 10 seconds? Perhaps comparing that flow in this library against the flow of calling |
Yes, I'm still going to check this flow, one question, did you test disconnecting with p_force = true, the disconnect peer has a second parameter that forces the disconnection. |
@bugbountyguy
Confirming that you used godotsteam's precompiled SteamMultiplayerPeer and the problem is the same there? |
Yes, I've tried with the force param as true (assuming you're talking about the 2nd optional parameter in disconnect_peer() ) I didn't try GodotSteam's precompiled MultiplayerPeer... I wasn't sure how to set that one up as there weren't instructions on it, and "SteamMultiplayerPeer" is not the class name they chose there. So I'm not using that one yet - right now it's just the gdextension of GodotSteam and steam-multiplayer-peer. I've decided this morning to setup an example project for you: https://github.com/bugbountyguy/broken_multiplayer_peer_example/tree/main You'll of course need a second steam connection (a friend or if you have a second steam account). There are instructions when you create a broken or working lobby in the game. "Sorta" Working Lobby: Scenario 2: Host creates the lobby. Client joins the lobby. Client terminates their game (Ctrl+C, or F8 if you're in Godot). Host should see "Steam: Offline" show up. Player restarts the game and re-joins the lobby very quickly. Host and client will see a "duplicate" session of the same player. After < 10 seconds, the "new session" will be dropped and the player will be returned to the main menu. The old session that was terminated will remain in the game indefinitely. Broken Lobby: |
I also encountered the same problem; |
Im getting the same issue on both of my laptops disconnect_peer does work this error is only on file log
|
I originally posted this over in GodotSteam project, but the more I mess with this, the more I'm sure it's related to this instead of GodotSteam. If it does turn out to be that library instead, I'll close this - but all signs appear to be pointing to this one here.
When I get the lobby chat update, and the player is leaving the lobby (using GodotSteam library), I'm manually calling peer.disconnect_peer, as I want the player to be removed from the game altogether, immediately, rather than waiting for the RPC disconnect to happen after 5-10 seconds (just in case they crash / disconnect, and then join back immediately). Upon doing so, the game crashes completely, with the following inside the stacktrace (only found it when doing a build):
To reproduce, add peer.disconnect_peer somewhere in the game (e.g. kicking the player or something), the game will crash. Most likely something's not being handled properly when calling this method. I noticed some commented out code in this repo on that method, but I didn't quite understand the code, so that's what's leading me to post this bug report.
The text was updated successfully, but these errors were encountered: