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

resolve all internal ambiguities #10411

Merged
merged 21 commits into from
Jan 9, 2024

Conversation

jakobhellermann
Copy link
Contributor

@jakobhellermann jakobhellermann commented Nov 6, 2023

  • ignore all ambiguities that are not a problem
  • remove .before(Assets::<Image>::track_assets), that points into a different schedule (-> should this be caught?)
  • add some explicit orderings:
    • run poll_receivers and update_accessibility_nodes after window_closed in bevy_winit::accessibility
    • run bevy_ui::accessibility::calc_bounds after CameraUpdateSystem
    • run bevy_text::update_text2d_layout and bevy_ui::text_system after font_atlas_set::remove_dropped_font_atlas_sets
  • add app.ignore_ambiguity(a, b) function for cases where you want to ignore an ambiguity between two independent plugins A and B
  • add IgnoreAmbiguitiesPlugin in DefaultPlugins that allows cross-crate ambiguities like bevy_animation/bevy_ui
  • Fixes Bevy contains internal system-order ambiguities #9511

Before

Render
render_schedule_Render dot

PostUpdate
schedule_PostUpdate dot

After

Render
render_schedule_Render dot
PostUpdate
schedule_PostUpdate dot

@alice-i-cecile
Copy link
Member

maybe we can add a regression test for not introducing new ones.

Strongly in favor of this.

I'm fine with either solution 1 or 2 for fixing the outstanding ambiguity: I think we may actually want both.

I like splitting that work out of this PR though, and merging this ASAP.

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Meta About the project itself labels Nov 6, 2023
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed my opinion on the best path forward following discussion on Discord by @hymm :)

@alice-i-cecile
Copy link
Member

@jakobhellermann can you update the PR description and title to match the latest changes?

@alice-i-cecile alice-i-cecile added this to the 0.12.1 milestone Nov 6, 2023
/// Suppress warnings and errors that would result from systems in these sets having ambiguities
/// (conflicting access but indeterminate order) with systems in `set`.
#[track_caller]
pub fn ignore_ambiguities<M1, M2, S1, S2>(&mut self, a: S1, b: S2) -> &mut Self
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make this just sugar for configure_sets(a.ambiguous_with(b))?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thread 'main' panicked at /home/jakob/dev/rust/bevy/crates/bevy_ecs/src/schedule/config.rs:533:38:
configuring system type sets is not allowed

Copy link
Contributor

@hymm hymm Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we're being too strict here and should just deny using system type sets with in_set instead of any configuration. @maniwani any opinion?

edit: this is non-blocking and can be done in a separate pr.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 I think that's a pretty reasonable way to increase the flexibility of the API. in_set is definitely a mistake, but being able to configure public systems without an explicit label seems safe.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what's being asked here. in_set should already fail if given a system type set.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should configure_set(my_system.before(ArbitraryLabel)) work?

Copy link
Contributor

@maniwani maniwani Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last I remember, if you call configure_set or in_set with a system type set, it should immediately error at runtime. Maybe somebody changed that, but the error was intentional.

It'd be too easy to call that with a system that's in many places like apply_deferred.

You can pass a system type set into the ambiguity-related methods. However, for similar reasons, if there are multiple instances of that system in the schedule, you'll get a schedule build error.

Copy link
Contributor

@maniwani maniwani Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error on in_set should be obvious. Users shouldn't be adding any other kind of system to the type set.

The immediate error on configure_set is directed at stopping users from calling before, after, run_if, and in_set and it affecting every single instance of a system.

It'd be a little more complicated, but someone could tweak that so that configure_set doesn't error if you only call ambiguity methods. I don't know if that's generally "safe" to use tho. I think you'd have to get rid of that schedule build check too for this to work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, let's leave it as is for now.

@jakobhellermann jakobhellermann changed the title resolve (almost) all internal ambiguities resolve all internal ambiguities Nov 6, 2023
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Dec 14, 2023
@hymm
Copy link
Contributor

hymm commented Dec 15, 2023

Can you resolve conflicts? Since we're earlier in the cycle now, we'll probably find any problems caused by this pr before release, so I'm fine with merging even if someone from rendering doesn't approve.

@alice-i-cecile
Copy link
Member

Resolved conflicts, fingers crossed that CI still passes and we can finally merge this <3

@alice-i-cecile alice-i-cecile added S-Adopt-Me The original PR author has no intent to complete this work. Pick me up! and removed S-Adopt-Me The original PR author has no intent to complete this work. Pick me up! labels Jan 8, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 8, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 8, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 8, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 8, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 9, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 9, 2024
@hymm
Copy link
Contributor

hymm commented Jan 9, 2024

looks like the failure is real. Something about this line when no default features is used https://github.com/bevyengine/bevy/pull/10411/files#diff-f6e740177ada590c3b70e737730d436f3314a45a6455ce5f5efe6d9bdbfebe98R154

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 9, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 9, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 9, 2024
Merged via the queue into bevyengine:main with commit a657478 Jan 9, 2024
22 checks passed
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 A-Meta About the project itself C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
Status: Merged PR
Development

Successfully merging this pull request may close these issues.

Bevy contains internal system-order ambiguities
7 participants