Why does a particle effect cause a pause the first time emitting is turned to true?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Socrates

I have a scene where an enemy explodes. The explosion is a particle effect. The first time the particle effect emits particles the game hangs for about a quarter of a second. If the particle effect fires again, it is fine, even though the second time it fires is a different instance. I suspect it’s because the particle effect’s texture (or possibly it’s material) is being loaded from disk, but how do i prevent this?

:bust_in_silhouette: Reply From: Zylann

It’s because the processing shader used by particles is being compiled for the first time.
Currently the only way to avoid this is to make it compiled beforehands, by instancing the particle system somewhere not in view during game loading.

It’s a known issue, even with 2D particles, or any kind of shader: Particles2D freezes the game during a few frames when emitting is set to true · Issue #17263 · godotengine/godot · GitHub