godotengine / godotengine/godot
[3.x] Particles2D and Multithreaded rendering throws error (Rare)
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
Tested in Godot 3.5.1, GLES2
[edit] Tested in Godot 3.6, GLES2
### System information
Ubuntu 24.04.1, 64bit, NVIDIA GeForce GTX 1050 Ti
### Issue description
When toggling emission of a CPUParticles2D node it will sometimes throw the error:
`emit_signal: Error calling method from signal 'frame_pre_draw': 'CPUParticles2D::': Method not found..`
This seems to only occur when multithreaded render mode is enabled.
The bug occurs quite rarely, and with varying behavior. Sometimes the error is just printed once, sometimes it keeps spamming very quickly, and sometimes it crashes the game process.
### Steps to reproduce
- Make a particle system and an animation that toggles it on and off (no other particle system settings are required, although the issue MRP has 'one-shot' enabled)
- Make a script that plays the animation repeatedly with a small random delay between plays.
- Duplicate it a few hundred times, to get the error to reproduce without having to wait for hours
- To speed up the reproduction, you can also increase engine_time_scale
Note how the error is printed when render mode in the project settings is "Multi-Threaded", and does not occur with "Single-Safe" render mode.
### Minimal reproduction project (MRP)
Reproduction project available at
github.com/Tugsav/godot-particle2d-multithreading-bug
Reproduction using time scale 50 should be pretty quick.
Reproduction without modifying time scale can take a while (i had the error occur after ~17 min)
Contributor guide
Research direction
Start with the linked minimal reproduction project and run it with engine time scale 50, comparing Multi-Threaded and Single-Safe render modes. Trace the CPUParticles2D emission toggling and the frame_pre_draw error, then confirm the fix by repeatedly running the reproduction without errors or crashes in the multithreaded mode.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics, game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100