Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | VanDeiMin |
if I use threads, app freezes when executing thread.wait_to_finish(). It happens only on android devices. On desktop everything works just fine.
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | VanDeiMin |
if I use threads, app freezes when executing thread.wait_to_finish(). It happens only on android devices. On desktop everything works just fine.
Reply From: | godot_dev_ |
Could be a race condition, where your desktop has better specifications than your Android device and so the race condition never creates a deadlock on your desktop but does on the Android.
Try adding random CPU lag and see if you can recreate the situation where thread.waittofinish()
blocks on your desktop
I think this explanation is quite reasonable. It is possible that the problem is due to lack of compatibility, you can test this problem on similar compatible devices.
dabbygentle | 2022-12-16 03:21
Hi.
Thank You for the answer.
How can I add random lag?
My desktop: Wacom Mobile Studio on intel i7 with nvidia quadro m1000m
Androids I’ve tried: Samsung J6, A12, A50.
VanDeiMin | 2022-12-20 18:18
Reply From: | bsmxofficial |
The Thread may be still running when the wait_to_finish function called, this can block the calling thread. You have to wait for the function completion and then call wait_to_finish. I had the same issue and this code work’s fine:
#e.g. you can join the thread when the Node exit the tree.
func _exit_tree():
if thread.is_alive() == false:
#print the return value from function called in the thread.
print(thread.wait_to_finish())
There is some interesting information in Docs about that: See the Godot’s API Class Reference