what is the difference between yield(get_tree(), "idle_frame") and call_deferred ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By thenegativehunter

the question is what is the difference between these two?

i decided to put this question here for the ones that have the same question but no answer.

what i have discovered is that the idle_frame signal fires only once every frame.

meaning if you were to call yield(get_tree(), "idle_frame") inside a function that is running during idle frame, due to another yield like this one, it will wait for the next.

but call_deferred simply means call during idle frame. meaning if you are at frame 1000, and use call_deferred inside a function that is already running at idle frame, it might be called in the same idle frame and not the next one.

i think godot engine puts everything you ask to be called with “call_deferred” in a stack and won’t exit idle frame until that stack is empty.

however what is not clear to me is if idle_frame signal is fired before any deferred calls or after all deferred calls.

beware when combining deferred and yield calls