godot-demo-projects
godot-demo-projects copied to clipboard
Multiple Threads Loading Demo, stuck in while loop / uses a not implemented funciton.
Which demo project is affected:
https://github.com/godotengine/godot-demo-projects/tree/master/loading/multiple_threads_loading
OS/device including version:
not related
Issue description:
In resource_queue.gd
func _wait_for_resource(res, path):
_unlock("wait_for_resource")
while true:
print("stuck in loop")
VisualServer.sync()
OS.delay_usec(16000) # Wait approximately 1 frame.
_lock("wait_for_resource")
if queue.size() == 0 or queue[0] != res:
return pending[path]
_unlock("wait_for_resource")
OS.delay_usec(16000)
blocks the loading thread, so the ResourceInteractiveLoader in thread_process() cannot poll(), so the loop can never wait for the resource to be load, causing an endless loop.
Shouldn't we use yield(get_tree(), "idle_frame")
here? I tested it, and it looks fine.
There is a time_max
defined, probably to prevent an endless loop, but it's actaully not used anywhere...
Addtionally, VisualServer.sync()
is used here, but the docs says it's not implemented in 3.x, there is VisualServer.force_sync()
, which seems implemented according to the docs. But I don't actually quite understand what it does.
I guess the code for this demo was written during 2.x and has been updated until now, but has hardly been tested in real development. I don't know anything about threads, but I suggest that someone who does to improve the resource_queue.gd
.