godotengine / godot

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

Game Locks up and steals mouse in Linux/X11 #89375

Open scotmcp opened 6 months ago

scotmcp commented 6 months ago

Tested versions

v4.2.1.stable.mono.flathub [b09f793f5]

System information

Godot v4.2.1.stable.mono (b09f793f5) - Freedesktop SDK 23.08 (Flatpak runtime) - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4060 Ti () - AMD Ryzen 7 5700X 8-Core Processor (16 Threads)

Issue description

When game starts, and I input a direction to move, the game locks up. Produces unref: BUG error messages

Steps to reproduce

When the game locks up, which in testing so far only happens when inputting a WASD movement. When the game locks up, it won't release the mouse, even if I ALT-TAB into other windows.

The only way to free the mouse and the game is to kill the session from a terminal window. Unfortunately this means I don't have any stack information to provide, I do however have the debugger output, which produces errors I have never seen. I am attaching a screen shot of those errors. Clicking on any of the unref: BUG errors does NOT bring the caret to erroneous code like other errors do. Looking into the Godot sources, this looks like an error capture specifically related strings in X11.

I could attach a copy of the game, however it rely on 3 servers and you wouldn't be able to get the game to run without the servers.

I can work with whoever picks the ticket up to demonstrate or otherwise poke around. image

image

Minimal reproduction project (MRP)

Not Available

scotmcp commented 6 months ago

Ok well, while fiddling with debugging messages all over my code, I narrowed it down to one block of code

while -player.velocity.z > 0.0: animation_player.play("locomotion/Jogging")

Which for the time being I have commented out and will find a better way to do it. However, I am not sure this should produce an bug that locks up the X11 session the way it does.

Sauermann commented 6 months ago

Can you please provide a minimal reproduction project, so that this issue can be debugged properly? It would help, if you could share only the part of your project, that causes the problem - perhaps not all 3 servers are required to reproduce the problem.

Without more details, is is nearly impossible to tell whether this is a bug in the engine or in the project.

scotmcp commented 5 months ago

Yeah unfortunately, the servers and the client are inextricable. This isn't a simple server authority game. The client simply can't run on it's own, and although you could probably rewrite pieces to make it run, I think that would be a significant effort...plus you wouldn't be getting any state stream from the servers, which as you stated might be part of the problem.

I can provide the model, the animation, and I already provided the block of code where the error occurs, however not sure that's going to produce anything useful. :-/

Sauermann commented 5 months ago

When searching for your error string "BUG: Unreferenced static string to 0" in the issues, one finds about a dozen other bugreports. Unfortunately they all seem to happen in different settings (vulkan, http-connection, ...) But perhaps you can find something there that helps you.

If you are able to compile the engine yourself, you could force a stacktrace with the following patch (under the assumption that this place in the code base causes your lock up):

diff --git a/core/string/string_name.cpp b/core/string/string_name.cpp
index 658297d805..4e9eae420d 100644
--- a/core/string/string_name.cpp
+++ b/core/string/string_name.cpp
@@ -128,6 +128,7 @@ void StringName::unref() {
                        } else {
                                ERR_PRINT("BUG: Unreferenced static string to 0: " + String(_data->name));
                        }
+                       CRASH_NOW();
                }
                if (_data->prev) {
                        _data->prev->next = _data->next;
RealMadvicius commented 1 month ago

Looks related to #93268