You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Game sometimes hangs when calling load from a thread, then calling wait_to_finish. I'm not sure, but I think it specifically happens when loading a resource that's not already in the cache. Adding a pause in the thread before the call to load with something like yield(get_tree().create_timer(0.001), "timeout") keeps the game from hanging, so I'm guessing it's some sort of mutex, race condition problem?
Add the following script to a node and set the file_path property to a resource not in the cache.
extends Node2D
export (String, FILE) var file_path
func _ready():
var thread = Thread.new()
thread.start(self, "hang_on_load", file_path)
thread.wait_to_finish()
func hang_on_load(path):
# Loading will work if you uncomment this line
# yield(get_tree().create_timer(0.0001), "timeout")
return load(path)
One type of error that was occuring was the scene tree calling
`can_process()` on pieces that had just left the scene tree, but they
were still in the "idle_physics_process" group as the _physics_process
notification was being fired. This was solved by not removing the piece
from the scene tree early, and letting the queue_free() operation
remove it from the scene tree instead.
The game would also sometimes freeze at random intervals, with no errors
being thrown. After some debugging, I found that this freezing was
originating from the `load` call in `ResourceManager`, which was being
run inside a thread - thus I think the issue is the same as
godotengine/godot#55566. I implemented the same workaround mentioned
in that issue, and the game no longer freezes.
This commit closes#216.
Godot version
3.4-1
System information
Arch Linux 5.15.5.arch1-1
Issue description
Game sometimes hangs when calling load from a thread, then calling wait_to_finish. I'm not sure, but I think it specifically happens when loading a resource that's not already in the cache. Adding a pause in the thread before the call to load with something like
yield(get_tree().create_timer(0.001), "timeout")
keeps the game from hanging, so I'm guessing it's some sort of mutex, race condition problem?Possibly the same issue as #51225
Steps to reproduce
Add the following script to a node and set the file_path property to a resource not in the cache.
Minimal reproduction project
thread_loading_bug.zip
The text was updated successfully, but these errors were encountered: