godot: Particles2D freezes the game during a few frames when emitting is set to true

Godot version: 3.0.2 stable

OS/device including version: Ubuntu 17.10 with AMD R5

Issue description: Setting emitting = true on a Particles2D node that was never emitting before, freezes the game for a couple of frames. Affects release builds too.

Steps to reproduce: Set emitting = true for the first time on a non emitting Particles2D node while the game is running.

Minimal reproduction project: particles-emit-bug.zip

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 1
  • Comments: 30 (24 by maintainers)

Most upvoted comments

If the game needs an extra loading time, it will be fine, but a full pause for the first time a particle is emitted is really bad.

Well, Vulkan won’t be an option for mobile and web for a couple of years, I guess that CPU particles will be the only workaround for this.

This is more or less normal in OpenGL, because shader compilation happens behind the scenes as soon as the shader is used.

The typical workaround is to make the shaders of all (or most) the materials visible on the first frame (even though they are behind an object), so stalls dont happen later.

From Godot, what could eventually be done is shader caching. This will solve the problem by caching all the shaders that the game uses, but the first time the game is run it will have to generate them anyway (so the solution mentioned above still applies). This happens because OpenGL shader binary that you can obtain for caching is GPU specific.

With Vulkan, this should be easier to solve, as shaders can be pre-compiled using SPIR-V.

This will be fixed in 3.2, where Vulkan/Shader Caching can be used.

As I mentioned before, I have tried without texture and without material (where should not work) and the emiting effect is the same, the problem seems to be in Particles2D or VisualServer (which toggles the emitting status).

I’ve actually noticed this in my project as well. I’m running Godot 3.0.2 on MacOS Sierra 10.12.6. I haven’t had the opportunity to try it on Windows, but I will as soon as I can.

In my usage, I am instancing a “bullet” that has a Particles2D node as a child of it. When that bullet is instanced for the first time, I noticed a few frames of visible stuttering/freeze. Every additional instance of the bullet (and particles) has no stutter/freeze.

Also, the particles in my case are emitting by default when they are instanced.

Note: I think this has been around since the 3.0 release.