Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Threads Loading Demo, stuck in while loop / uses a not implemented funciton. #746

Open
rambda opened this issue Jun 3, 2022 · 0 comments
Labels

Comments

@rambda
Copy link

rambda commented Jun 3, 2022

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.

@rambda rambda added the bug label Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant