Skip to content

Deferred::apply runs even if the system never ran. #21549

@andriyDev

Description

@andriyDev

Bevy version and features

What you did

// My app does not include the diagnostics plugin, so the DiagnosticsBuffer within Diagnostics will fail to apply.

fn my_optional_diagnostics_system(mut diagnostics: If<Diagnostics>) {
  // I only want these measurements to be sent when diagnostics exist.
}

What went wrong

The SystemBuffer in DiagnosticsBuffer gets applied, resulting in a panic since the DiagnosticsStore does not exist.

While the DiagnosticsBuffer probably should avoid panicking in this case, we also probably shouldn't be applying Deferred if the system never ran! This is most visible using the If type to automatically skip systems when the DiagnosticsStore is missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorS-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions