Skip to content

Reads from VisualServer causing unnecessary sync #64094

Description

@lawnjelly

Godot version

3.5 stable, 4.0 alpha 13

System information

All

Issue description

This is just a reminder issue that we discovered today that some functions being called in VisualServer (gets) are potentially causing stalls in 3.x and 4.x. In general reading back data is discouraged except for the editor, and for one-off type operations like creating RIDs etc.

The example we found was #14971 which reduz says should not have been merged. We should instead be using something like call_deferred or VisualServerCallbacks to deferred return the result / signal without stalling.

The problematic function is:

virtual bool particles_get_emitting(RID p_particles) = 0;

The pattern of having something that could be read back every tick / frame is problematic. There may be several of these causing problems, e.g. also:

virtual bool particles_is_inactive(RID p_particles) = 0;
virtual AABB particles_get_current_aabb(RID p_particles) = 0;

There may be several of these we should convert to using deferred calls or alternative mechanisms where possible.

Steps to reproduce

Add a ParticleSystem2D with one shot mode, set to multithreaded renderer, and compile engine with #define DEBUG_SYNC.

Output is:

sync on: canvas_item_create
sync on: particles_create
sync on: particles_get_emitting
sync on: particles_get_emitting
sync on: particles_get_emitting
sync on: shader_create
sync on: particles_get_emitting
sync on: particles_get_emitting
sync on: particles_get_emitting
sync on: particles_get_emitting
sync on: particles_get_emitting
sync on: particles_get_emitting
sync on: particles_get_emitting
sync on: particles_get_emitting
sync on: particles_get_emitting
sync on: particles_get_emitting
sync on: particles_get_emitting
etc

Minimal reproduction project

N/A

Discussion

These tend to be added in PRs by contributors who are not familiar with the command queue and separation between scene side and servers. Perhaps we could increase the documentation in the code in this area and have some policies on how to approach such problems.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions