why add_child function ask call_deferred only on web export ?

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

to explain the situation quickly : when I have a KinematicBody2D enters in a Area2D and triggers the body_entered signal that calls my Global.next_level() function.

During the next_level process, I load and instance nodes from an “res://myScene.tscn”.

Nothing is output in editor’s debug and Linux export ; If I call Global.next_level() from another way (e.g. input event) even on web export.

But only on web export, and with the signal trigger add_child function wirte this messages in output :

ERROR: Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead.
    at: body_set_shape_disabled (servers/physics_2d/physics_2d_server_sw.cpp:652) - Condition "body->get_space() && flushing_queries" is true.
ERROR: Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead.
    at: body_set_shape_as_one_way_collision (servers/physics_2d/physics_2d_server_sw.cpp:660) - Condition "body->get_space() && flushing_queries" is true.

Why should I use call_deferred in this context?

:bust_in_silhouette: Reply From: exuin

I think the error message tells you, the engine is busy flushing queries. It’s strange that it only happens on web export, I usually get that message while running the game from the editor.