Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore system order ambiguities from specific components and resources. #9884

Closed
rj00a opened this issue Sep 21, 2023 · 2 comments · Fixed by #9895
Closed

Ignore system order ambiguities from specific components and resources. #9884

rj00a opened this issue Sep 21, 2023 · 2 comments · Fixed by #9895
Labels
A-ECS Entities, components, systems, and events C-Feature A new feature, making something new possible

Comments

@rj00a
Copy link
Contributor

rj00a commented Sep 21, 2023

What problem does this solve or what need does it fill?

Currently, it is possible to ignore system order ambiguities for whole sets of systems by using the ambiguous_with API. However, it would be useful to ignore ambiguities resulting from specific components or resources to handle the situation where ambiguous uses of those types should not be considered a bug.

Motivation

In my app, many systems need write-only access to a specific component in order to send gameplay packets. The systems are ordered in such a way to ensure game logic correctness, but they're not ordered strictly enough to resolve the ambiguities. Resolving the ambiguities "properly" would pollute the schedule with ordering constraints between modules that do not actually depend on each other for correctness. This harms local reasoning.

What solution would you like?

Add ambiguous_resource and ambiguous_component methods to App and Schedule at least.

use bevy_ecs::{
    prelude::*,
    schedule::{LogLevel, ScheduleBuildSettings},
};

#[derive(Resource)]
struct MyResource;

fn main() {
    let mut world = World::new();
    world.insert_resource(MyResource);

    Schedule::default()
        .set_build_settings(ScheduleBuildSettings {
            ambiguity_detection: LogLevel::Error,
            ..Default::default()
        })
        .add_systems((foo, bar)) // Ambiguous systems.
        .ambiguous_resource::<MyResource>() // Mark the resource as ambiguous.
        .run(&mut world); // Does not panic.
}

fn foo(_: ResMut<MyResource>) {}

fn bar(_: ResMut<MyResource>) {}

What alternative(s) have you considered?

Additional context

#8595 appears to solve a related but separate concern (that I would love to have a fix for!).

@rj00a rj00a added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Sep 21, 2023
@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events and removed S-Needs-Triage This issue needs to be labelled labels Sep 21, 2023
@alice-i-cecile
Copy link
Member

flecs doesn't have execution order ambiguities because its systems don't run in parallel :)

@hymm
Copy link
Contributor

hymm commented Sep 21, 2023

I can put together a pr for this. I'm currently knee deep in this code and it shouldn't be too hard because of that.

@rj00a rj00a changed the title Ignore system order ambiguities between specific components and resources. Ignore system order ambiguities from specific components and resources. Sep 21, 2023
github-merge-queue bot pushed a commit that referenced this issue Oct 4, 2023
# Objective

- Fixes #9884
- Add API for ignoring ambiguities on certain resource or components.

## Solution

- Add a `IgnoreSchedulingAmbiguitiy` resource to the world which holds
the `ComponentIds` to be ignored
- Filter out ambiguities with those component id's.

## Changelog

- add `allow_ambiguous_component` and `allow_ambiguous_resource` apis
for ignoring ambiguities

---------

Co-authored-by: Ryan Johnson <[email protected]>
regnarock pushed a commit to regnarock/bevy that referenced this issue Oct 13, 2023
# Objective

- Fixes bevyengine#9884
- Add API for ignoring ambiguities on certain resource or components.

## Solution

- Add a `IgnoreSchedulingAmbiguitiy` resource to the world which holds
the `ComponentIds` to be ignored
- Filter out ambiguities with those component id's.

## Changelog

- add `allow_ambiguous_component` and `allow_ambiguous_resource` apis
for ignoring ambiguities

---------

Co-authored-by: Ryan Johnson <[email protected]>
ameknite pushed a commit to ameknite/bevy that referenced this issue Nov 6, 2023
# Objective

- Fixes bevyengine#9884
- Add API for ignoring ambiguities on certain resource or components.

## Solution

- Add a `IgnoreSchedulingAmbiguitiy` resource to the world which holds
the `ComponentIds` to be ignored
- Filter out ambiguities with those component id's.

## Changelog

- add `allow_ambiguous_component` and `allow_ambiguous_resource` apis
for ignoring ambiguities

---------

Co-authored-by: Ryan Johnson <[email protected]>
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this issue Jan 9, 2024
# Objective

- Fixes bevyengine#9884
- Add API for ignoring ambiguities on certain resource or components.

## Solution

- Add a `IgnoreSchedulingAmbiguitiy` resource to the world which holds
the `ComponentIds` to be ignored
- Filter out ambiguities with those component id's.

## Changelog

- add `allow_ambiguous_component` and `allow_ambiguous_resource` apis
for ignoring ambiguities

---------

Co-authored-by: Ryan Johnson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants