Skip to content
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

Input System - Changing Value and pressing outside the field crashing Godot Engine #86612

Closed
mcdz opened this issue Dec 29, 2023 · 10 comments · Fixed by #89346
Closed

Input System - Changing Value and pressing outside the field crashing Godot Engine #86612

mcdz opened this issue Dec 29, 2023 · 10 comments · Fixed by #89346

Comments

@mcdz
Copy link

mcdz commented Dec 29, 2023

Tested versions

  • Reproducible in 4.2.1 stable.
  • minimum project requirement, empty project will do.

System information

Godot v4.2.1.stable - Windows 10.0.19045 - Vulkan (Mobile) - dedicated NVIDIA GeForce GT 1030 (NVIDIA; 31.0.15.3758) - AMD Ryzen 3 3100 4-Core Processor (8 Threads)

Issue description

Input Map - Changing Value and pressing outside the field crashing Godot Engine

Steps to reproduce

open input map, add a few fields,
try renaming, don't press enter, instead click outside the field.
then engine will crash.

Minimal reproduction project (MRP)

  • minimum project requirement, empty project will do.
@AThousandShips
Copy link
Member

What do you mean "input system"? Do you mean the Input Map in the project settings? What field are you talking about?

@mcdz
Copy link
Author

mcdz commented Jan 2, 2024

What do you mean "input system"? Do you mean the Input Map in the project settings? What field are you talking about?

yeah. sorry I am new, I accidently wrote system instead of map.

@kiprou
Copy link

kiprou commented Feb 25, 2024

Experiencing this as well.

To reproduce do Project > Project Settings > Input Map and double-click an existing action to rename it, then with the text field still active, double click on another action's name (as if you're trying to rename that one as well). Instant crash.

Until this is fixed the workaround is to press Enter to confirm a rename, instead of clicking elsewhere.

Godot 4.2.1 (Stable, Forward+), Windows 10 (19044.3086), NVIDIA GTX 970 (31.0.15.3623), Intel i7-3770K

@fkeyzuwu
Copy link
Contributor

fkeyzuwu commented Mar 1, 2024

yup, happened to me as well

@akien-mga
Copy link
Member

I can't reproduce the crash on Linux (KDE Plasma/XWayland) with either 4.2.1-stable or 4.3-dev4.

Might be Windows specific? CC @Sauermann @bruvzg

@akien-mga akien-mga added this to the 4.3 milestone Mar 1, 2024
@kiprou
Copy link

kiprou commented Mar 1, 2024

Here's a GIF recorded in a brand new project (see my previous comment for hardware/software specs):

GIF of Godot crash when clicking elsewhere in the UI after renaming an action.

@Sauermann
Copy link
Contributor

Tested on Windows 10 with both

Result was:

  • Unable to reproduce with Single Window mode on
  • Crashes for me with Single Window Mode on

@bruvzg
Copy link
Member

bruvzg commented Mar 9, 2024

I can reproduce it (sometimes) on macOS as well, so it's not Windows specific.

Trace:

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	       0x18372ea60 __pthread_kill + 8
1   libsystem_pthread.dylib       	       0x183766c20 pthread_kill + 288
2   libsystem_c.dylib             	       0x183673a20 abort + 180
3   Godot                         	       0x10310b088 handle_crash(int) + 2304 (crash_handler_macos.mm:176)
4   libsystem_platform.dylib      	       0x183797584 _sigtramp + 56
5   Godot                         	       0x104576464 ActionMapEditor::update_action_list(Vector<ActionMapEditor::ActionInfo> const&) + 600 (action_map_editor.cpp:432)
6   Godot                         	       0x104a1e684 ProjectSettingsEditor::_update_action_map_editor() + 1672 (project_settings_editor.cpp:580)
7   Godot                         	       0x10352a7e0 void call_with_variant_args_helper<__UnexistingClass>(__UnexistingClass*, void (__UnexistingClass::*)(), Variant const**, Callable::CallError&, IndexSequence<>) + 24 (binder_common.h:304) [inlined]
8   Godot                         	       0x10352a7e0 void call_with_variant_args_dv<__UnexistingClass>(__UnexistingClass*, void (__UnexistingClass::*)(), Variant const**, int, Callable::CallError&, Vector<Variant> const&) + 40 (binder_common.h:451) [inlined]
9   Godot                         	       0x10352a7e0 MethodBindT<>::call(Object*, Variant const**, int, Callable::CallError&) const + 192 (method_bind.h:344)
10  Godot                         	       0x10732d338 Object::callp(StringName const&, Variant const**, int, Callable::CallError&) + 384 (object.cpp:784)
11  Godot                         	       0x107035f00 Callable::callp(Variant const**, int, Variant&, Callable::CallError&) const + 200 (callable.cpp:69)
12  Godot                         	       0x107039520 CallableCustomBind::call(Variant const**, int, Variant&, Callable::CallError&) const + 424 (callable_bind.cpp:144)
13  Godot                         	       0x10736c0f8 UndoRedo::_process_operation_list(List<UndoRedo::Operation, DefaultAllocator>::Element*, bool) + 300 (undo_redo.cpp:365)
14  Godot                         	       0x10736bef8 UndoRedo::_redo(bool) + 252 (undo_redo.cpp:81)
15  Godot                         	       0x10736ebe0 UndoRedo::commit_action(bool) + 240 (undo_redo.cpp:330)
16  Godot                         	       0x10490e9dc EditorUndoRedoManager::commit_action(bool) + 80 (editor_undo_redo_manager.cpp:243)
17  Godot                         	       0x104a1cbd4 ProjectSettingsEditor::_action_renamed(String const&, String const&) + 1920 (project_settings_editor.cpp:481)
18  Godot                         	       0x104a240c4 void call_with_variant_args_helper<ProjectSettingsEditor, String const&, String const&, 0ul, 1ul>(ProjectSettingsEditor*, void (ProjectSettingsEditor::*)(String const&, String const&), Variant const**, Callable::CallError&, IndexSequence<0ul, 1ul>) + 176 (binder_common.h:304)
19  Godot                         	       0x10732fff8 Object::emit_signalp(StringName const&, Variant const**, int) + 520 (object.cpp:1136)
20  Godot                         	       0x104574ec8 Error Object::emit_signal<String, String>(StringName const&, String, String) + 132 (object.h:931)
21  Godot                         	       0x104574a1c ActionMapEditor::_action_edited() + 1000 (action_map_editor.cpp:141)
22  Godot                         	       0x10732fff8 Object::emit_signalp(StringName const&, Variant const**, int) + 520 (object.cpp:1136)
23  Godot                         	       0x105792260 Error Object::emit_signal<>(StringName const&) + 32 (object.h:931) [inlined]
24  Godot                         	       0x105792260 Tree::item_edited(int, TreeItem*, MouseButton) + 164 (tree.cpp:4442)
25  Godot                         	       0x10579289c Tree::_line_editor_submit(String) + 368 (tree.cpp:3242)
26  Godot                         	       0x105792570 Tree::_text_editor_popup_modal_close() + 296 (tree.cpp:3171)
27  Godot                         	       0x10732fff8 Object::emit_signalp(StringName const&, Variant const**, int) + 520 (object.cpp:1136)
28  Godot                         	       0x1056226e8 Error Object::emit_signal<>(StringName const&) + 32 (object.h:931) [inlined]
29  Godot                         	       0x1056226e8 Popup::_notification(int) + 292 (popup.cpp:80)
30  Godot                         	       0x10732b020 Object::notification(int, bool) + 80
31  Godot                         	       0x10542422c Window::set_visible(bool) + 356 (window.cpp:845)
32  Godot                         	       0x10578ff88 Tree::select_single_item(TreeItem*, TreeItem*, int, TreeItem*, bool*, bool) + 68 (tree.cpp:2673)
33  Godot                         	       0x1057913f0 Tree::propagate_mouse_event(Vector2i const&, int, int, int, bool, TreeItem*, MouseButton, Ref<InputEventWithModifiers> const&) + 2212 (tree.cpp:2977)
34  Godot                         	       0x105790db4 Tree::propagate_mouse_event(Vector2i const&, int, int, int, bool, TreeItem*, MouseButton, Ref<InputEventWithModifiers> const&) + 616 (tree.cpp:3133)
35  Godot                         	       0x1057953ac Tree::gui_input(Ref<InputEvent> const&) + 5804 (tree.cpp:3885)
36  Godot                         	       0x1054f8178 Control::_call_gui_input(Ref<InputEvent> const&) + 704 (control.cpp:1804)
37  Godot                         	       0x1053d6214 Viewport::_gui_call_input(Control*, Ref<InputEvent> const&) + 244 (viewport.cpp:1609)
38  Godot                         	       0x1053d7154 Viewport::_gui_input_event(Ref<InputEvent>) + 1488 (viewport.cpp:1841)
39  Godot                         	       0x1053dda90 Viewport::push_input(Ref<InputEvent> const&, bool) + 780 (viewport.cpp:3374)
40  Godot                         	       0x1054253fc Window::_window_input(Ref<InputEvent> const&) + 756 (window.cpp:1627)
41  Godot                         	       0x105445a60 void call_with_variant_args_helper<Window, Ref<InputEvent> const&, 0ul>(Window*, void (Window::*)(Ref<InputEvent> const&), Variant const**, Callable::CallError&, IndexSequence<0ul>) + 168 (binder_common.h:304)
42  Godot                         	       0x10310dd78 Variant Callable::call<Ref<InputEvent>>(Ref<InputEvent>) const + 132 (variant.h:863)
43  Godot                         	       0x10310dac8 DisplayServerMacOS::_dispatch_input_event(Ref<InputEvent> const&) + 600 (display_server_macos.mm:383)
44  Godot                         	       0x106fc9a78 Input::_parse_input_event_impl(Ref<InputEvent> const&, bool) + 2816 (input.cpp:772)
45  Godot                         	       0x106fc7580 Input::flush_buffered_events() + 136 (input.cpp:1043)
46  Godot                         	       0x10311e2a0 DisplayServerMacOS::process_events() + 652 (display_server_macos.mm:3010)
47  Godot                         	       0x103106924 OS_MacOS::run() + 136 (os_macos.mm:774)
48  Godot                         	       0x103131320 main + 344 (godot_main_macos.mm:83)
49  dyld                          	       0x1833de0e0 start + 2360

@bruvzg
Copy link
Member

bruvzg commented Mar 9, 2024

The issue is caused by ActionMapEditor::update_action_list called from within Tree::propagate_mouse_event, which block tree updating, and cause Tree::create_item (called by update_action_list) to return nullptr (which is unreferenced on the next line).

TreeItem *action_item = action_tree->create_item(root);
action_item->set_meta("__action", action_info.action);
action_item->set_meta("__name", action_info.name);

@bruvzg
Copy link
Member

bruvzg commented Mar 9, 2024

Something like this seems to fix it, but I'm not sure if the rest of the logic is correct:

diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 7842fc5fc0..b696115e1f 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -3166,9 +3166,17 @@ void Tree::_text_editor_popup_modal_close() {
 	}
 
 	if (popup_edited_item->is_edit_multiline(popup_edited_item_col) && popup_edited_item->get_cell_mode(popup_edited_item_col) == TreeItem::CELL_MODE_STRING) {
-		_apply_multiline_edit();
+		if (blocked > 0) {
+			callable_mp(this, &Tree::_apply_multiline_edit).call_deferred();
+		} else {
+			_apply_multiline_edit();
+		}
 	} else {
-		_line_editor_submit(line_editor->get_text());
+		if (blocked > 0) {
+			callable_mp(this, &Tree::_line_editor_submit).call_deferred(line_editor->get_text());
+		} else {
+			_line_editor_submit(line_editor->get_text());
+		}
 	}
 }
 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants