godot: Renaming Node Crashes Editor on Linux with i3wm

Godot version

4.0.beta17

System information

Linux.x86_64

Issue description

Renaming a node in the scene tree by double clicking randomly crashes the running editor instance with the following error message:

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.0.beta17.official (c40020513ac8201a449b5ae2eeb58fef0ce0a2a4)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /usr/lib/libc.so.6(+0x389e0) [0x7f729c7cf9e0] (??:0)
[2] /opt/godot/Godot_v4.0-beta17_linux.x86_64() [0x44ef5c1] (??:0)
[3] /opt/godot/Godot_v4.0-beta17_linux.x86_64() [0x4b802d7] (??:0)
[4] /opt/godot/Godot_v4.0-beta17_linux.x86_64() [0x2bc69f1] (??:0)
[5] /opt/godot/Godot_v4.0-beta17_linux.x86_64() [0x4957fc4] (??:0)
[6] /opt/godot/Godot_v4.0-beta17_linux.x86_64() [0xe76ab5] (??:0)
[7] /opt/godot/Godot_v4.0-beta17_linux.x86_64() [0xde8ec2] (??:0)
[8] /usr/lib/libc.so.6(+0x23290) [0x7f729c7ba290] (??:0)
[9] /usr/lib/libc.so.6(__libc_start_main+0x8a) [0x7f729c7ba34a] (??:0)
[10] /opt/godot/Godot_v4.0-beta17_linux.x86_64() [0xe0908e] (??:0)
-- END OF BACKTRACE --
================================================================

The error occurs about 8 out of 10 times.

Steps to reproduce

  1. Create a blank project
  2. Create a scene
  3. Add any root node
  4. Rename the root node by double clicking the name in the Scene Tree view

Minimal reproduction project

A blank project with no scene produces this error.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 2
  • Comments: 23 (21 by maintainers)

Most upvoted comments

The code you provided does fix the problem for me! Amazing

Great, I have opened PR - https://github.com/godotengine/godot/pull/73239.

But what does IME has to do with popups?

IME require an invisible sub-window to work (which determine candidate window drawing position, and dispatching input event to the IME engine). So each time a LineEdit or TextEdit is focused, the IME window is mapped and input focus is transferred to it. IME engines and WMs (especially on XWayland) are quite inconsistent in handling it and sensitive to window focus. Before IME support was implementation, all popups (including the node rename popup) were unfocusable, but this does not work on XWayland (it locks all input when focus is transferred to IME sub-window), so it was changed to be focusable. Dead keys without IME (input key handling changes) are not directly related to the issue or IME implementation, it was never supported before and was found only during IME issues debugging.

you are not able to reproduce the issue because you have IME enabled

No, it’s the same with or without IME, all modern distros should have IME enabled (even if you do not have keyboard layout configured) by default. Note: If IME is fully disabled, Godot will print XOpenIM failed warning on the start, so you can detect it this way.

Are you able to see the weird looking rename popup on i3?

Yes, rename popup are too big on i3. But no matter what I try, the third click always lands inside a popup and cause text selection, not popup closing.

The only thing I suspect can have some effect is event callback not being cleaned. Try adding the following code to the Window::_clear_window() in the scene/main/window.cpp:

void Window::_clear_window() {
	ERR_FAIL_COND(window_id == DisplayServer::INVALID_WINDOW_ID);

+	DisplayServer::get_singleton()->window_set_rect_changed_callback(Callable(), window_id);
+	DisplayServer::get_singleton()->window_set_window_event_callback(Callable(), window_id);
+	DisplayServer::get_singleton()->window_set_input_event_callback(Callable(), window_id);
+	DisplayServer::get_singleton()->window_set_input_text_callback(Callable(), window_id);
+	DisplayServer::get_singleton()->window_set_drop_files_callback(Callable(), window_id);
+
	if (transient_parent && transient_parent->window_id != DisplayServer::INVALID_WINDOW_ID) {
		DisplayServer::get_singleton()->window_set_transient(window_id, DisplayServer::INVALID_WINDOW_ID);
	}
9f426498231816ccb9d686b3944373f61312aa24 is the first bad commit
commit 9f426498231816ccb9d686b3944373f61312aa24
Author: bruvzg <7645683+bruvzg@users.noreply.github.com>
Date:   Wed Feb 1 10:51:03 2023 +0200

    [X11] Fix IME subwindow in the popup not getting input focus.

 platform/linuxbsd/x11/display_server_x11.cpp | 2 +-
 scene/gui/popup_menu.cpp                     | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

So caused by https://github.com/godotengine/godot/pull/72497. It’s been there for a while, but has become way easier to trigger recently

Can confirm, this happens if I triple click on a node. The two first clicks make the node enter rename mode and the third dispatches the WINDOW_EVENT_FOCUS_OUT.

If done too fast it leads to a segfault coming from here.

I’m on i3 as well. This is a recent crash I think. I can try to bisect it.

Well, I found a related issue #72763, which can be reproduced on i3wm and Cinnamon.

@geowarin If you search for “dead keys” you’ll see quite a lot of issues.

My understanding is that #18020 broke people’s ability to use dead keys (which are quite common, e.g. the Spanish and International US layouts use them). 72370 makes it possible to use those layouts again (because without it, only IME input works, which is to mean, Chinese/Japanese dead keys, but not Western dead keys because they don’t rely on IME)

While git bisecting, I was reproducing it 100% of the time by clicking a lot on a node. On latest git revision, 3 clicks are sufficient, in previous revisions I had to click a bunch but this is something I can pull of very consistently in less than 2 seconds.

It IS sensitive to timing.