godotengine / godot

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

Shaders using TIME make editor unusable after some time #93061

Open KoBeWi opened 2 weeks ago

KoBeWi commented 2 weeks ago

Tested versions

4.3 beta1 I did not experience it before.

System information

Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1060 (NVIDIA; 31.0.15.4633) - Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 Threads)

Issue description

https://github.com/godotengine/godot/assets/2223172/c68c897a-2398-445a-b9fb-a83d55370846

The ItemBlock has a shader that uses TIME. After the editor was open for a few hours, rendering this object makes the editor unusable. Same happens in other scenes with TIME shaders or particles. The problem goes away after editor restart.

Note that TIME being the problem is an assumption. I tested it with this one shader and with particles.

Steps to reproduce

  1. Have a CanvasIteme with shader that uses TIME
  2. Wait a few hours with editor open
  3. Check your scene

Minimal reproduction project (MRP)

Shader used in the above scene:

shader_type canvas_item;

uniform float intensity : hint_range(0, 1);

void vertex() {
    VERTEX.x += sin(TIME * 10.0 + VERTEX.y) * 60.0 * intensity;
}

void fragment() {
    vec2 uv = UV;
    uv.y += sin(TIME * 10.0 + UV.x * 10.0) * 0.1 * intensity;
    if (uv.y < 0.0 || uv.y > 1.0) {
        COLOR = vec4(0);
    }
}
AkiYama-Ryou commented 2 weeks ago

the same question when: void fragment() { COLOR.a = sin(TIME); } and ctrl+s

KoBeWi commented 1 week ago

So I tried to investigate this a bit and I managed to reproduce it immediately after launch, but only once.

But this made me think that I wrongly assumed the cause of this issue. Every time it happened, the editor would update scene groups at launch (due to a bug) and then the editor would wait in the background while I was busy with something else 🙃 Turns out the group update is what caused the issue, but since I used the editor only after some time has passed, I though the issue starts after some time.

When I managed to reproduce the bug now, it also happened after groups update, so it might be something related to EdtiorProgress actually. However I can't reproduce it anymore, even after repeating the same steps (though maybe I missed something), so that information is not really helpful for testing.

KoBeWi commented 6 days ago

I didn't see it happening for some time. With how the issue appears to be random (and seems to depend on another bug) and we didn't really get other reports than mine, I think it can be given less priority. If it's really caused by EditorProgress, it might be some bug that existed before and was now uncovered.