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

Visual Shader Arrange Nodes button crashes Godot #82166

Closed
CarlisleJonah opened this issue Sep 23, 2023 · 2 comments · Fixed by #83678
Closed

Visual Shader Arrange Nodes button crashes Godot #82166

CarlisleJonah opened this issue Sep 23, 2023 · 2 comments · Fixed by #83678

Comments

@CarlisleJonah
Copy link

CarlisleJonah commented Sep 23, 2023

Godot version

v4.1.1.stable.mono.official [bd6af8e]

System information

Windows 10

Issue description

In the Visual Shader editor, clicking Arrange Nodes crashes Godot.

Steps to reproduce

Click Arrange Nodes in the Visual Shader editor with the reproduction project. Sometimes it works on first click, sometimes it takes a few clicks. Below is an image of the shader I was fiddling with that caused this to happen (I assume).

image

Minimal reproduction project

Test.zip

@fire
Copy link
Member

fire commented Sep 23, 2023

I want to investigate the Arrange button, but I'm not able for a few days. Help welcome.

@qycyfjy
Copy link

qycyfjy commented Sep 23, 2023

图片
The most direct reason is that function _place_block may be called recursively and stack overflow

_place_block(u, p_delta, r_layers, r_root, r_align, r_node_name, r_inner_shift, r_sink, r_shift, r_node_positions);

By observing the function arguments, I found that there may be something wrong with the r_layers: normally, we only need to know which nodes there are in a certain layer, it is unlikely that duplicate nodes will be needed. But this is not the case, sometimes, there will be repeated elements in a some layers.

By looking at the code before calling function _place_block, r_layers is obtained by calling the following function:

HashMap<int, Vector<StringName>> layers = _layering(selected_nodes, upper_neighbours);

Assume that layer one includes two nodes, "3" and "13", but in the layers returned by _layering(), the elements of that layer may be "3", "3", "13", which means a "3" is repeated (interesting, if repetition happens, that is the repetition of the first element, I'm not sure if it's always like this, I haven't dug into the algorithm of _layering() carefully).

One dirty workaround is to remove all repeated elements in every entry of the returned HashMap, i.e., Vector("3", "3", "13")->Vector("3", "13")

动画

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.

5 participants