godotengine / godot-vscode-plugin

Godot development tools for VSCode
MIT License
1.52k stars 149 forks source link

Lots of errors appear in the output window after editing a script in an empty project #497

Closed paul-mcnamee closed 11 months ago

paul-mcnamee commented 11 months ago

Godot version

v4.1.1.stable.official [bd6af8e0e]

VS Code version

1.82.2

Godot Tools VS Code extension version

v1.3.1

System information

Windows 11

Issue description

Godot Engine v4.1.1.stable.official (c) 2007-present Juan Linietsky, Ariel Manzur & Godot Contributors. modules/gltf/register_types.cpp:73 - Blend file import is enabled in the project settings, but no Blender path is configured in the editor settings. Blend files will not be imported. --- Debug adapter server started --- --- GDScript language server started --- Parent node is busy setting up children, add_child() failed. Consider using add_child.call_deferred(child) instead. scene/main/window.cpp:1565 - Condition "!is_inside_tree()" is true. [LSP] Connection Taken Caller thread can't call this function in this node (/root/@EditorNode@17637/@Control@697/@Panel@698/@VBoxContainer@706/@HSplitContainer@709/@HSplitContainer@717/@HSplitContainer@725/@VBoxContainer@726/@VSplitContainer@728/@PanelContainer@7498/@VBoxContainer@7499/@EditorLog@7529/@VBoxContainer@7513/@RichTextLabel@7515). Use call_deferred() or call_thread_group() instead. Caller thread can't call this function in this node (/root/@EditorNode@17637/@Control@697/@Panel@698/@VBoxContainer@706/@HSplitContainer@709/@HSplitContainer@717/@HSplitContainer@725/@VBoxContainer@726/@VSplitContainer@728/@PanelContainer@7498/@VBoxContainer@7499/@EditorLog@7529/@VBoxContainer@7513/@RichTextLabel@7515). Use call_deferred() or call_thread_group() instead. Caller thread can't call this function in this node (/root/@EditorNode@17637/@Control@697/@Panel@698/@VBoxContainer@706/@HSplitContainer@709/@HSplitContainer@717/@HSplitContainer@725/@VBoxContainer@726/@VSplitContainer@728/@PanelContainer@7498/@VBoxContainer@7499/@EditorLog@7529/@VBoxContainer@7513/@RichTextLabel@7515). Use call_deferred() or call_thread_group() instead. Caller thread can't call this function in this node (/root/@EditorNode@17637/@Control@697/@Panel@698/@VBoxContainer@706/@HSplitContainer@709/@HSplitContainer@717/@HSplitContainer@725/@VBoxContainer@726/@VSplitContainer@728/@PanelContainer@7498/@VBoxContainer@7499/@EditorLog@7529/@VBoxContainer@7513/@RichTextLabel@7515). Use call_deferred() or call_thread_group() instead. Caller thread can't call this function in this node (/root/@EditorNode@17637/@Control@697/@Panel@698/@VBoxContainer@706/@HSplitContainer@709/@HSplitContainer@717/@HSplitContainer@725/@VBoxContainer@726/@VSplitContainer@728/@PanelContainer@7498/@VBoxContainer@7499/@EditorLog@7529/@VBoxContainer@7513/@RichTextLabel@7515). Use call_deferred() or call_thread_group() instead. This function in this node (/root/@EditorNode@17637/@Control@697/@Panel@698/@VBoxContainer@706/@HSplitContainer@709/@HSplitContainer@717/@HSplitContainer@725/@VBoxContainer@726/@VSplitContainer@728/@PanelContainer@7498/@VBoxContainer@7499/@EditorLog@7529/@VBoxContainer@7517/@Button@7528) can only be accessed from either the main thread or a thread group. Use call_deferred() instead. Caller thread can't call this function in this node (/root/@EditorNode@17637/@Control@697/@Panel@698/@VBoxContainer@706/@HSplitContainer@709/@HSplitContainer@717/@HSplitContainer@725/@VBoxContainer@726/@VSplitContainer@728/@PanelContainer@7498/@VBoxContainer@7499/@EditorLog@7529/@VBoxContainer@7517/@Button@7528). Use call_deferred() or call_thread_group() instead. This function in this node (/root/@EditorNode@17637/@Control@697/@Panel@698/@VBoxContainer@706/@HSplitContainer@709/@HSplitContainer@717/@HSplitContainer@725/@VBoxContainer@726/@VSplitContainer@728/@PanelContainer@7498/@VBoxContainer@7499/@EditorLog@7529/@VBoxContainer@7517/@Button@7528) can only be accessed from the main thread. Use call_deferred() instead. Caller thread can't call this function in this node (/root/@EditorNode@17637). Use call_deferred() or call_thread_group() instead. Caller thread can't call this function in this node (/root/@EditorNode@17637/@EditorFileSystem@694). Use call_deferred() or call_thread_group() instead.

Steps to reproduce

Create a new empty project change the editor to external Add a Node2D Add a script to the empty Node2D Edit the script (which opens vscode)

DaelonSuzuka commented 11 months ago

This is a Godot engine issue, it doesn't have anything to do with this extension. Those particular errors are coming from the editor itself during initialization and are annoying but seem to be harmless.

paul-mcnamee commented 11 months ago

@DaelonSuzuka It is worth noting that the errors did not appear until I opened the script via vscode, and I did not observe them when using the built in script editor. The last one in the list is reoccurring each time I alt tab between vscode and godot.

DaelonSuzuka commented 11 months ago

Did you actually read the warnings?

Caller thread can't call this function in this node (/root/@EditorNode@17637/https://github.com/control@697/@panel@698/@VBoxContainer@706/@HSplitContainer@709/@HSplitContainer@717/@HSplitContainer@725/@VBoxContainer@726/@VSplitContainer@728/@PanelContainer@7498/@VBoxContainer@7499/@EditorLog@7529/@VBoxContainer@7513/@RichTextLabel@7515). Use call_deferred() or call_thread_group() instead.

This is very obviously a node in the editor attempting to do a cross-thread function call in a way that the runtime doesn't like.

All of them are variations of this problem, which is a mistake in the engine/editor code and not related to VSCode or this extension.

paul-mcnamee commented 11 months ago

Parent node is busy setting up children, add_child() failed. Consider using add_child.call_deferred(child) instead. scene/main/window.cpp

It was not obvious to me. I thought it was related since it did not happen when using the godot editor, only while using VSCode. Thanks for looking at it.

DaelonSuzuka commented 11 months ago

It was not obvious to me.

Sorry, long day. I didn't need to be that aggressive. For what it's worth, here's how I knew:

"Caller thread" and "call_thread_group()" tell me it's thread related.

That massive NodePath is definitely a Node in the editor itself: it has @EditorNode@17637 and @EditorLog@7529 in it. Considering it's a RichTextLabel, it's probably the actual node that's displaying stdout/stderr.

The massive chain of containers is how the editor is arranged. Mess around building editor tools and you'll recognize this instantly.

only while using VSCode

It probably isn't only while using VSCode, but I suspect that when the editor regains focus it's checking to see if any files have been touched (VSCode with auto-save-focus-loss will touch files when it loses focus) and then tries to ask the file system manager (/root/@EditorNode@17637/@EditorFileSystem@694) to do... something that's thread related and incorrect. It's quite likely that opening a script in notepad and alt+tab/save/alt+tab back would produce the same message.

paul-mcnamee commented 11 months ago

We all have rough days so no worries, I appreciate your explanations and responses.

I tried the same setup with notepad as you suggested to see if the behavior was different.

This is the output that was generated from opening the script, changing a line, and saving the file:

Godot Engine v4.1.1.stable.official (c) 2007-present Juan Linietsky, Ariel Manzur & Godot Contributors.
  modules/gltf/register_types.cpp:73 - Blend file import is enabled in the project settings, but no Blender path is configured in the editor settings. Blend files will not be imported.
--- Debug adapter server started ---
--- GDScript language server started ---
  Parent node is busy setting up children, `add_child()` failed. Consider using `add_child.call_deferred(child)` instead.
  scene/main/window.cpp:1565 - Condition "!is_inside_tree()" is true.
  Parent node is busy setting up children, `add_child()` failed. Consider using `add_child.call_deferred(child)` instead.
  scene/main/window.cpp:1565 - Condition "!is_inside_tree()" is true.

Those are definitely from alt tabbing/godot losing focus, I saw another issue about that in the godot issues so they're aware of that already.

The other messages mentioning "Use call_deferred() or call_thread_group() instead." were absent.

I disabled the plugin in vscode and attempted to modify the file while the plugin was disabled and the output was the same as the notepad. I do think it is related to the plugin unfortunately. As soon as I re-enabled the plugin in vscode the errors appeared in the console.

If there's anything I can do to help let me know. I don't really have much experience with vscode plugins or godot but I can try if you point me in the right direction.

atirut-w commented 11 months ago

I do think it is related to the plugin unfortunately. As soon as I re-enabled the plugin in vscode the errors appeared in the console.

I think that narrows it down to Godot's LSP server.

paul-mcnamee commented 11 months ago

I do think it is related to the plugin unfortunately. As soon as I re-enabled the plugin in vscode the errors appeared in the console.

I think that narrows it down to Godot's LSP server.

Alright I'll setup some other editor which uses Godot's LSP server to see if that has the same errors.

paul-mcnamee commented 11 months ago

After installing emacs, vomiting because I installed emacs, setting up godot's LSP there, etc. I found that the error messages were tied to the editor setting Network -> Language Server -> "Use Thread" in godot.

I also found this issue which seems like it should be fixed in godot version 4.2 https://github.com/godotengine/godot/issues/79525