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

EditorFileDialog freezes the editor #65122

Closed
jtnicholl opened this issue Aug 31, 2022 · 7 comments · Fixed by #65142
Closed

EditorFileDialog freezes the editor #65122

jtnicholl opened this issue Aug 31, 2022 · 7 comments · Fixed by #65142

Comments

@jtnicholl
Copy link
Contributor

jtnicholl commented Aug 31, 2022

Godot version

v4.0.alpha.custom_build [8fa9d1a]

System information

Linux (Fedora 36)

Issue description

When opening a file dialog in certain projects the editor freezes while maxing out a CPU thread. It only happens if recent directories contains two of the same directory, one with a slash at the end and one without. Which is something that happens sometimes, I don't know if there's already an issue open for that or how to reproduce it.
From doing a git bisect this seems to be a regression caused by #63552. That PR involves some for loops so I think it's getting stuck in an infinite loop, but I couldn't figure out where.

Steps to reproduce

  1. Open the MRP (contains a .godot/editor/recent_dirs file that will cause the bug)
  2. Right click on FileSystem -> New Resource and select any resource type (or open an EditorFileDialog by some other means)
  3. Blank window pops up, editor freezes and maxes out a CPU core

Minimal reproduction project

EditorStuck.zip

@akien-mga
Copy link
Member

CC @RedMser

@RedMser
Copy link
Contributor

RedMser commented Aug 31, 2022

Can confirm. Was missing a change in EditorNode::disambiguate_filenames. Uploading a fix for it.

@compmstr
Copy link
Contributor

compmstr commented Nov 6, 2022

I'm seeing this behavior in Godot 4 Beta4 still.
I have ../godot and ../godot/ in my ~/.config/godot/recent_dirs.
When I go to create a new project and click on browse under Project path, I get the 100% CPU usage freeze.
Running with GDB and breaking when that happens shows the following backtrace (it's spinning on disambiguate_filenames):

(gdb) bt
#0  0x0000555555fbd2b5 in CowData<char32_t>::_ref(CowData<char32_t> const&) ()
#1  0x000055555713a11e in EditorNode::disambiguate_filenames(Vector<String>, Vector<String>&) ()
#2  0x000055555704fce2 in EditorFileDialog::_update_recent() ()
#3  0x0000555557053bf8 in EditorFileDialog::_notification(int) ()
#4  0x000055555a153fc8 in Object::notification(int, bool) ()
#5  0x00005555581b7ca1 in Window::set_visible(bool) [clone .part.0] ()
#6  0x00005555581b81dc in Window::popup(Rect2i const&) ()
#7  0x00005555581b8ae2 in Window::popup_centered_clamped(Vector2i const&, float) ()
#8  0x000055555703b6a5 in EditorFileDialog::popup_file_dialog() ()
#9  0x000055555a15ec4d in Object::emit_signalp(StringName const&, Variant const**, int) ()
#10 0x00005555581e0e45 in BaseButton::_pressed() ()
#11 0x00005555581e1bb9 in BaseButton::on_action_event(Ref<InputEvent>) ()
#12 0x00005555581e2046 in BaseButton::gui_input(Ref<InputEvent> const&) ()
#13 0x000055555818302c in Viewport::_gui_call_input(Control*, Ref<InputEvent> const&) ()
#14 0x000055555818415c in Viewport::_gui_input_event(Ref<InputEvent>) ()
#15 0x000055555819b856 in Viewport::push_input(Ref<InputEvent> const&, bool) ()
#16 0x00005555581ba52f in Window::_window_input(Ref<InputEvent> const&) ()
#17 0x00005555581cb816 in CallableCustomMethodPointer<Window, Ref<InputEvent> const&>::call(Variant const**, int, Variant&, Callable::CallError&) const ()
#18 0x0000555555fdbee6 in DisplayServerX11::_dispatch_input_event(Ref<InputEvent> const&) ()
#19 0x0000555559e412f7 in Input::_parse_input_event_impl(Ref<InputEvent> const&, bool) ()
#20 0x0000555559e43768 in Input::flush_buffered_events() ()
#21 0x0000555555fdee44 in DisplayServerX11::process_events() ()
#22 0x0000555555fbe380 in OS_LinuxBSD::run() ()
#23 0x0000555555faf95e in main ()

Should I set up a new issue for this?
Removing the 'duplicate' entry in recent_dirs clears up the problem.

@RedMser
Copy link
Contributor

RedMser commented Nov 6, 2022

@compmstr I can't reproduce on the latest master. Not sure how a relative path in the recent_dirs would happen, but it doesn't really make sense either.

Looking at the code, it trims file extensions via full_path.rfind("."), which would trim most of the path when you have a relative path pointing to a folder. I could try to change this logic to use get_basename, but would need you to test if that fixes it for you.

(I really think this code needs some unit tests 😅 )

@compmstr
Copy link
Contributor

compmstr commented Nov 6, 2022

@RedMser I made a mistake with my original comment: there aren't relative paths in the recent_dirs file, it's a full path with the same prefix.
I was trying to not put my name in a comment, but my Github profile has my name aways 🤦
So my recent_dirs file contains:

/home/corey/programming/godot/
/home/corey/programming/godot

I'll try checking out your branch to see if that fixes it though.

@RedMser
Copy link
Contributor

RedMser commented Nov 6, 2022

there aren't relative paths in the recent_dirs file, it's a full path with the same prefix.

Ah I see. Well it found us another bug then, which is good to get fixed :D

But in that case, I don't think this will fix it either. I'm on Windows, where absolute paths start with a drive letter, so this might only happen on Linux. I'll try to reproduce...

@compmstr
Copy link
Contributor

compmstr commented Nov 6, 2022

Ah, I also just found out that it's any duplicate paths, with or without a trailing slash.
So if I change to:

/home/corey/programming/godot/
/home/corey/programming/godot/

I see the same issue

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

Successfully merging a pull request may close this issue.

4 participants