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

Using NodePath with certain default values shows an error in editor #54468

Closed
AnidemDex opened this issue Oct 31, 2021 · 18 comments
Closed

Using NodePath with certain default values shows an error in editor #54468

AnidemDex opened this issue Oct 31, 2021 · 18 comments

Comments

@AnidemDex
Copy link

AnidemDex commented Oct 31, 2021

Godot version

3.4 RC2

System information

Windows 11 x64

Issue description

If you try to use an exported NodePath variable with a default value of "", NodePath("") or NodePath() the editor will throw an error when trying to use a node that uses that variable:

image

ERROR: (Node not found: "" (relative to "/root/EditorNode/@@592/@@593/@@601/@@603/@@607/@@611/@@612/@@613/@@629/@@630/@@639/@@640/@@6275/@@6109/@@6110/@@6111/@@6112/@@6113/Control/Panel").)
   at: (scene/main/node.cpp:1325)

Is something very similar to when you try to use a node in a tool script.

This error doesn't breaks the editor or the game. but this was working on 3.3

Steps to reproduce

  1. Create a node and attach this script
export(NodePath) var ReferenceNode_path:NodePath = NodePath("") # Fails with "" || NodePath() || NodePath("")

onready var reference_node:Node = get_node(ReferenceNode_path) as Node

func custom_function() -> void:
	reference_node # <- Try using any of its properties after running the game

Minimal reproduction project

Thanks to eons on discord helping me to replicate this issue:
project.zip

@Jjony-dev
Copy link

I reproduced this error on linux x64 when editor try to suggest autocomplete options.

@Listwon
Copy link
Contributor

Listwon commented Nov 1, 2021

This error doesn't breaks the editor or the game

It doesn't break, but substantially affects the overall performance of the editor, as in large project I'm working on right now it's flooding the output with this kind of errors. Thanks for the repro steps!

@akien-mga
Copy link
Member

This error doesn't breaks the editor or the game, but this was working on 3.3

Can you check again?

I just tried and I can reproduce the bug, but for me it happens the same in 3.4 RC 2, 3.3.4-stable, 3.3-stable and even 3.2-stable. So it doesn't appear to be a regression.

@akien-mga akien-mga modified the milestones: 3.4, 3.5 Nov 1, 2021
@Listwon
Copy link
Contributor

Listwon commented Nov 1, 2021

MRP doesn't trigger ERROR: (Node not found: "" (relative to "/root/EditorNode/@@592/@@593/@@601/@@603/@@607/@@611/@@612/@@613/@@629/@@630/@@639/@@640/@@6275/@@6109/@@6110/@@6111/@@6112/@@6... type of error. Also I don't think that the MRP shows any bug. ERROR: (Node not found: "" (relative to "/root/Node").) is expected behaviour for empty path and I confirm that it happens the same in 3.3.4 and 3.3.3. So maybe my issue is something different as it happens only in 3.4/custom builds from 3.x.

@Listwon
Copy link
Contributor

Listwon commented Nov 1, 2021

I've bisected what causes my problem and it's this PR #49491 that triggers "Node not found" errors. It's most probably related to tool scripts in my project, but I don't have the MRP yet.

@akien-mga akien-mga modified the milestones: 3.5, 3.4 Nov 1, 2021
@akien-mga
Copy link
Member

CC @pycbouh

@YuriSizov
Copy link
Contributor

Sorry, I don't understand what problem is being reported. Like @akien-mga, I can reproduce the problem described in the OP with the attached MPR in both 3.4 RC2 and 3.3 stable.

@Listwon What exactly did you track down to be caused by the aforementioned PR? Can you provide a test project and the steps that only trigger the "Node not found" error in 3.4, but not in 3.3? Because the MRP attached by @AnidemDex triggers the error in either version (and indeed is the expected behavior, I think, like you yourself mention).

@akien-mga
Copy link
Member

The MRP was actually not reproduce the bug that @AnidemDex and @Listwon both seem to experience. The MRP covers only a normal error that happens from misusing the API in a script, while the "bug" here seems to be a misuse of the API in the editor code itself, hence the relative to "/root/EditorNode/@@592/@@593/@@601/@@603/@@607/@@611/@@612/@@613/@@629/@@630/@@639/@@640/@@6275/@@6109/@@6110/@@6111/@@6112/@@6113/Control/Panel" part.

But indeed we need a way to reproduce the bug to solve it.

@YuriSizov
Copy link
Contributor

here seems to be a misuse of the API in the editor code itself

Probably true, but I've seen such paths reported by the editor before, and well, this MRP does the same in 3.3.

image

So if there is a regression, something not yet determined is causing it.

@akien-mga
Copy link
Member

Oh I couldn't reproduce this error with the MRP, I only get the script error when running the project, nothing in the editor itself (even when setting them as tool scripts).

@YuriSizov
Copy link
Contributor

YuriSizov commented Nov 1, 2021

I just followed instructions that said to use the reference somehow 🙃 So I've added .name, and it throws those messages when trying to come up with auto-complete suggestions (so twice there because it first reacted on . and then on .name).

@Listwon
Copy link
Contributor

Listwon commented Nov 1, 2021

@pycbouh I'm trying to find it right now and prepare the MRP. What I found so far is that one of the scripts loaded by EditorResourcePicker::_get_allowed_types() (checked with VS debugger) on project loading tries to preload scenes in const Dictionary like this:

const SCENES:Dictionary = {
	"scene1":preload("res://preloaded_scene.tscn")
}

and I get Node not found errors. If I try to open one of those scenes, I'm flooded with cascade of similar errors
viewport_node

@AnidemDex
Copy link
Author

This error doesn't breaks the editor or the game, but this was working on 3.3

Can you check again?

I just tried and I can reproduce the bug, but for me it happens the same in 3.4 RC 2, 3.3.4-stable, 3.3-stable and even 3.2-stable. So it doesn't appear to be a regression.

here seems to be a misuse of the API in the editor code itself

Probably true, but I've seen such paths reported by the editor before, and well, this MRP does the same in 3.3.

[an image goes here]

So if there is a regression, something not yet determined is causing it.

image

Can reproduce on 3.3, wich is... weird. Someone on discord said that wasn't able to reproduce it on 3.3.4. I guess I have to replicate that by myself before opening this issue.

So, have I to close this issue? Modify its title?

Sorry for the problems in advance

@YuriSizov
Copy link
Contributor

So, have I to close this issue? Modify its title?

@AnidemDex I think what you've highlighted is an existing problem, but a problem nonetheless. If the problem you describe is the same as I noticed and it's related to the auto-completion, we can adjust the title/descripting in the OP and keep it open. Unless this is a duplicate.

However, @Listwon's report seems to be about something new. That probably deserves a new issue report so that we can properly track it and hopefully fix for the next 3.4 RC.

@akien-mga akien-mga modified the milestones: 3.4, 3.5 Nov 1, 2021
@akien-mga akien-mga changed the title [3.4 RC2] Using NodePath with certain default values shows an error in editor Using NodePath with certain default values shows an error in editor Nov 1, 2021
@akien-mga
Copy link
Member

@Listwon's issue might be related to daa0977 / #52126.

@Listwon
Copy link
Contributor

Listwon commented Nov 2, 2021

I'm still struggling to prepare the good MRP. It is of course related to NodePath issues, but also to EditorResourcePicker. The thing is - in project with over 600 scripts EditorResourcePicker::_get_allowed_types() loads them to check classes inheritance. One problem is - it's triggered multiple times automatically during project import (probably because of some tileset tool scripts updates in background). So it slows everything down unnecessarily by itself. The next problem is, every time I click on the Node with script attached, there is a hiccup, because it reloads all scripts again. While these scripts (~600) are loaded, they preload scenes and some of them have Viewports. Because of some issue with NodePath or other related issues, there are errors about incorrect NodePath. NodePath is correct on the scene itself, but maybe if it's preloaded from within the script, loaded by EditorResourcePicker::_get_allowed_types() or more precisely EditorNode::get_editor_data().script_class_is_parent(E->get(), base)), it lacks some context?

@YuriSizov
Copy link
Contributor

One problem is - it's triggered multiple times automatically during project import (probably because of some tileset tool scripts updates in background). So it slows everything down unnecessarily by itself.

The results are cached after the first run, so it shouldn't contribute to the slow down when it's the same base types. See #51211

@YuriSizov
Copy link
Contributor

@AnidemDex Errors with auto-complete are caused by user code. It fails trying to get the reference to the object, because it tries to execute get_node() to get the value from a node path which is in this case invalid. If you use get_node_or_null() instead, there are no more errors. I'm not sure if anything can be changed in the engine to address that, because it fails on executing the code that the user wrote.

@YuriSizov YuriSizov removed this from the 3.5 milestone Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants