Godot version:
3.1
OS/device including version:
Linux, kernel 5.0.9
OpenGL ES 2.0 Renderer: Mesa DRI Intel(R) UHD Graphics 620 (Kabylake GT2)
As well as iOS and iphones (see comments)
Issue description:
When spawning CPUParticles2D nodes, screen flickers and/or flashes erratically.
EDIT: It seems that spawning particles exclusively in _physics_process fixes/reduces the issue. Spawning them in other ways, directly or such as children of an instanced node, causes the issue. Projects exported to iOS are particularly buggy.
Steps to reproduce:
It's sufficient to spawn dynamically CPUParticles2D nodes (see minimal project attached)
Minimal reproduction project:
debug.zip
I can't reproduce the issue on Mageia 7, kernel 5.1.0-rc7, mesa 19.0.3.
Both my IGP and dGPU handle it fine:
OpenGL ES 2.0 Renderer: Mesa DRI Intel(R) HD Graphics 630 (Kaby Lake GT2).
OpenGL ES 2.0 Renderer: AMD VEGAM (DRM 3.30.0, 5.1.0-desktop-0.rc7.2.mga7, LLVM 8.0.0)
Tested 3.1-stable, 3.1.1-stable and current master, all work fine for me.
I tested this debug project on MacOSX 10.13.6. In original state it doesn't flicker nor GLES2, neither GLES3.
When I added a texture to CPUParticle it start flickering for both video drivers.
OpenGL ES 3.0 Renderer: NVIDIA GeForce GT 1030 OpenGL Engine
https://vimeo.com/334515804
OpenGL ES 2.0 Renderer: NVIDIA GeForce GT 1030 OpenGL Engine
https://vimeo.com/334516016
This is an example of flickered moment:

Also I can see flickering on Android (GLES 2.0) much often than on iOS (GLES 3.0) All flickering related to usage of many CPUParticles2D at one time.
I can confirm I have flickering when also exporting the project to iOS. So the original name of this issue should be renamed since it seems to plague any platform.
And yes, my minimum reproduction project should have included a texture. Sorry about that.
Finally, things seem to get worse for me if if the editor is opened for longer and the project is run (and stopped) many times.
I also have this issue on my computer, running up-to-date Arch Linux on Godot 3.1.1-stable.
The flickering only seems to exist initially- it tapers off after a few seconds of spawning CPUParticles2D nodes. Really weird.
This issue also seems to exist on my machine without even adding a texture to the nodes, as I was able to reproduce it via the minimum reproduction project. D:
This is a recorded video example of the bug in a project exported to iOS. You can see artifacts as lines flashing on the screen of random color.
You can see 3 random diagonal lines flickering, in the span of a few seconds.
They disappear when switching to gles3 or taking out all the cpuParticles2D in the game.
https://link.resilio.com/#f=IMG_0073.TRIM.MOV&t=6&i=BZSSECEVLJD6ASEBAU57RMCMMQKWAENPG&e=1557637321&v=2.6
Running Windows 10 Godot 3.1.1-stable and ES 2.0 Renderer on GeForce GTX 970/PCIe/SSE2. Can confirm, screen flickering especially if you instance a large amount (like hundreds) of CPUParticles2D in a single frame. They don't even have to be emitting, just having the node there causes flickering. Not spawning CPUParticles2D stops the issue entirely.
I have tried a lot of combination and just have found one which not flickering:
GLES3
NV workaround = True
FB Allocation = 3D w/o effects
Hdr = OFF
But the most important step - instantiate particle in _physics_process (not in regular _process).
I will try another combinations, may be only one component leads to flickering state.
It looks like using _physics_process is a complete workaround for this issue. Could anybody check it on another OS?
I am trying to use your workaround that issue but it's nearly impossible since I seem to get the same bug even if the particle are spawned or instanced (even as part of an instance) from any bit of code that does not reside in _physics_process.
As an example, if I spawn an instance which contains GLES2 CPUParticles2D on click, I get erratic behaviours at times, once I export to iOS. This is quite broken :(
EDIT: updated the title to reflect that the bug affects iOS, Windows, Linux
@aleksfadini Great! At least it will help to detect how _physics_process environment differs from _process behaviour. I think that core developers could faster fix it with this information.
@aleksfadini MacOSX too
added OSX to the description. Thank you for putting it in high priority, and thanks again to the awesome Godot devs for taking care of this!!
It seems like in current master this issue was fixed. I checked on 197b65f32ac811f79bc5599fbfe8cf83914b6873
MacOSX 10.14.4 Gles2/Gles3 looks ok.
Could anybody check it on another OSes?
Tested again with the MRP + assigned texture to the CPUParticles2D. Same system as https://github.com/godotengine/godot/issues/28719#issuecomment-489557078 with slightly newer drivers and kernel.
With the master branch I don't see any flickering, using either GLES2 or GLES3 and both my Intel and AMD GPUs.
With 3.1.1-stable, I only get some flickering with GLES2 on AMD, when first starting the game. Then it runs further without flicker.
Since I can't reproduce all the issues that seem to be described here, I can't really say if it's fixed.
Cherrypicking this commit, if you are not on master, may fix this problem: https://github.com/godotengine/godot/commit/24b7f088927e17d80e1e21573b16bee8d3d5d50b
Confirmed on Android and Linux, cherry-picking https://github.com/godotengine/godot/commit/24b7f088927e17d80e1e21573b16bee8d3d5d50b (Ensure non-emitting particles not processed on entering tree) on top of 3.1-stable fixed the problem so far.
If I understand correctly this is fixed in the current master branch / 3.2 beta?
I'll close then, please comment if you can still reproduce the issue on 3.2.
It still happens to my playtesters on 3.2 beta 6, they both have Windows 10 64 bits. Instead of using CPUParticles2D or Particles2D I used my own, but I tried using them and the bug was more intense. I'm assuming this is caused by the many add_child() calls because reducing the particles lowers the intensity of the bug and putting them on _physics_process() is almost a complete workaround this issue, but give it enoug particles and it'll start happening again.
Edit: Confused beta5 with 6.