godotengine / godotengine/godot
Typed array multhithreading issue
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
Reproduced in 4.4 dev4, 4.4 dev7
### System information
Godot v4.4.dev4 - Windows 10.0.19045 - Multi-window, 2 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 (NVIDIA; 32.0.15.6094) - AMD Ryzen 5 1500X Quad-Core Processor (8 threads)
### Issue description
Cannot append to a typed array from a new thread when the type is a custom class_name, e.g MyClass, the array remains empty. It works fine if the array is not typed or the type is built in like Node2D.
I am aware the docs mention appending as an operation that is not thread safe, but neither using a mutex nor set_thread_safety_checks_enabled(false) nor both helped fix this.
### Steps to reproduce
Run attached MRP. Observe appending on line 14 of a.gd and the array remaining empty after that.
### Minimal reproduction project (MRP)
[thread_test.zip](https://github.com/user-attachments/files/18309702/thread_test.zip)
Contributor guide
Research direction
Start by running the attached thread_test.zip minimal reproduction and inspect the append on line 14 of a.gd. Compare the behavior of untyped arrays, built-in typed arrays, and arrays typed with the custom class_name while using the reported thread-safety settings. Done means appending the custom-class value from the new thread no longer leaves the array empty.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- godot
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100