godotengine / godot

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

"Parent node is busy setting up children" on focus loss when `save_on_focus_loss` option is enabled #73765

Closed akien-mga closed 4 months ago

akien-mga commented 1 year ago

Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.


Godot version

4.0.rc (5f3dee5988391deffcc0de1039dd50e05e266913)

System information

Mageia 9, Linux

Issue description

When interface/editor/save_on_focus_loss is enabled in the Editor Settings, focus loss triggers a save as expected, but also these errors:

ERROR: Parent node is busy setting up children, `add_child()` failed. Consider using `add_child.call_deferred(child)` instead.
   at: add_child (scene/main/node.cpp:1136)
ERROR: Condition "!is_inside_tree()" is true.
   at: popup_centered (scene/main/window.cpp:1456)

Steps to reproduce

Minimal reproduction project

Happens on an empty project.

Production edit (keywords for easier searching): Task 'save' already exists.

Rindbee commented 1 year ago

https://github.com/godotengine/godot/blob/84a80721c5308df36c7295949c76a622c5e0edb9/scene/main/scene_tree.cpp#L643-L647 https://github.com/godotengine/godot/blob/84a80721c5308df36c7295949c76a622c5e0edb9/scene/main/node.cpp#L1924-L1932 https://github.com/godotengine/godot/blob/84a80721c5308df36c7295949c76a622c5e0edb9/editor/progress_dialog.cpp#L158-L168

propagate_notification(NOTIFICATION_APPLICATION_FOCUS_OUT) causes data.blocked to be greater than 0, and finally the root window fails to add the ProgressDialog as a child node.

It seems that new child nodes cannot be added to the parent node during propagate_notification.

rayzorite commented 1 year ago

This is still not fixed and is available in Godot 4.1

iseos commented 1 year ago

The error is also present in v4.2-dev5

jbromberg commented 12 months ago

Also encountering this issue - frustrating

ClassyCircuit commented 12 months ago

I have the same issue in v4.1.2. Do you think this will be prioritized any time soon?

thygrrr commented 11 months ago

Disabling Save on Focus Lost is a workaround, of course you lose the ability to save on focus lost.

ClassyCircuit commented 11 months ago

Disabling Save on Focus Lost is a workaround, of course you lose the ability to save on focus lost.

That's not a workaround, it's just a broken feature.

rayzorite commented 11 months ago

I have the same issue in v4.1.2. Do you think this will be prioritized any time soon?

i don't think so unless some big shot on twitter or youtube spread it and its not really a big deal for some people so i dont think this will be fixed anytime soon

thygrrr commented 11 months ago

Disabling Save on Focus Lost is a workaround, of course you lose the ability to save on focus lost.

That's not a workaround, it's just a broken feature.

It works around the error, which automated testing would flag as an error.

It surely doesn't fix the cause.

Calinou commented 11 months ago

propagate_notification(NOTIFICATION_APPLICATION_FOCUS_OUT) causes data.blocked to be greater than 0, and finally the root window fails to add the ProgressDialog as a child node.

The solution is likely to add a way to save all scenes/scripts in the editor without displaying a progress dialog, and use this when Save on Focus Loss is triggered.

Alternatively, we can get rid of the progress dialog when saving and move this to a non-blocking control displayed at the bottom of the editor (similar to a toast, though not the exact same). For instance, when saving a file, LibreOffice replaces its status bar at the bottom with a save progress bar:

image

I'd personally prefer this approach as I find the progress dialog on save distracting. We only need to keep it for operations that need to be blocking to avoid data inconsistency, such as resource importing.

MasterBroNetwork commented 11 months ago

This error is still occurring as of Godot v4.1.3-stable in the exact same manner, I agree with Calinou that a different way to show saving would be great, I also have found the dialog to be quite distracting but this error makes my output log ridiculously noisy over-time as I work on my project, I have had to disable Save on Focus Lost due to this issue as it has become frustrating to debug while this is occurring.

An option to temporarily hide internal editor errors during playtesting would be great so that my output is not cluttered by errors like this.

Wolve-3DTech commented 9 months ago

I've encountered the same issue in Godot 4.2.1 stable...

lemilonkh commented 7 months ago

Also encountering this on EndeavourOS with Godot 4.2.1. Thankfully this issue told me what's going on, as without a debug build of the editor you just get this error message without further detail:

ERROR: Task 'save' already exists.
   at: add_task (editor/progress_dialog.cpp:167)
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
     at: cleanup (core/object/object.cpp:2208)
ERROR: Resources still in use at exit (run with --verbose for details).
   at: clear (core/io/resource.cpp:493)
[1]    3340289 segmentation fault (core dumped)  ~/Tools/Godot_v4.2.1-stable_linux.x86_64 --editor

With the first two lines being repeated a lot. Would be helpful to either flag this as broken on linux with a warning on the settings or at least have more helpful error output. I was wondering for half an hour or so why my editor always crashed when I launched the game - turns out it's the save on focus loss instead of anything related to my code.

FathiMahdi commented 6 months ago

Any progress on this bug, it still available on version 4.2.1

calebhk98 commented 5 months ago

Still an issue on 4.2.2 stable. While a fix would be appreciated, it should probably add to the log that the issue is from save on Focus Lost, that way we have less wasted time debugging code that is not relevant.