0 votes

Hi,

i have a long running function (about 3-5 sec) which blocks the GUI.
It blocks the editor profiler too.
I tried with difference method to refresh the GUI, without a good result.

For example:
getnode("WAITING LABEL").show()
runLongFunction()
get
node("WAITING LABEL").hide()

I tried it with thread, the result is the same. No waiting label, no anim, etc. :/

Is there any solution for a long running function to easy visualize?

Thanx

asked Sep 20, 2018 in Engine by gejza (18 points)

Long tasks should be run in a seperate thread. If a thread is blocking your GUI maybe you're not using it correctly? Check this official example:
https://github.com/godotengine/godot-demo-projects/tree/3.0-d69cc10/misc/threads

1 Answer

0 votes

can you provide a rough structure of how your thread starts and ends?
I also had some problems with threads, maybe this link might help you:
https://godotengine.org/qa/33120/how-do-thread-and-wait_to_finish-work

answered Sep 24, 2018 by Andrea (519 points)

Finally i solve it.

My problem was: in main thread and in the long running function thread both i should update the GUI, but it works now.

Solution:
i have a semaphore, which i set, to signal the thread to enable running. (it's agains polling)
Then in the thread where i do the "heavy lifting", after GUI update, need a minimal wait, to give the main thread a little time to refresh the GUI.
If thread is ready, then sink semaphore, to be ready to run again.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.