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

[Merged by Bors] - Make StartupSet a base set #7574

Conversation

TimJentzsch
Copy link
Contributor

@TimJentzsch TimJentzsch commented Feb 8, 2023

Objective

Closes #7573

  • Make StartupSet a base set

Solution

  • Add #[system_set(base)] to the enum declaration
  • Replace .in_set(StartupSet::...) with .in_base_set(StartupSet::...)

Note: I don't really know what I'm doing and what exactly the difference between base and non-base sets are. I mostly opened this PR based on discussion in Discord. I also don't really know how to test that I didn't break everything. Your reviews are appreciated!


Changelog

  • StartupSet is now a base set

Migration Guide

StartupSet is now a base set. This means that you have to use .in_base_set instead of .in_set:

Before

app.add_system(foo.in_set(StartupSet::PreStartup))

After

app.add_system(foo.in_base_set(StartupSet::PreStartup))

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Feb 8, 2023
@alice-i-cecile alice-i-cecile added this to the 0.10 milestone Feb 8, 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.

This is almost the correct set of changes, assuming that you didn't end up missing any uses :)

Base sets are intended to be "broad organization tools for schedules" that try to warn users about free-floating systems. I think this makes sense for both of these sets: running startup systems or rendering systems that are not ordered relative to these sets is likely to result in very surprising ambiguities.

To finish this up, just define a default base set for the CoreSchedule::Startup. I don't think the RenderSchedule should have one: there's no clear default.

@alice-i-cecile alice-i-cecile requested a review from cart February 8, 2023 21:29
@alice-i-cecile alice-i-cecile added the X-Controversial There is active debate or serious implications around merging this PR label Feb 8, 2023
@TimJentzsch
Copy link
Contributor Author

To finish this up, just define a default base set for the CoreSchedule::Startup.

Done.

I think there is also an opportunity to make this more readable with system chaining, but the diff is quite large already so I'll do that in a follow-up PR.

@TimJentzsch TimJentzsch requested review from alice-i-cecile and removed request for cart and maniwani February 8, 2023 22:07
@TimJentzsch
Copy link
Contributor Author

Whoops, I didn't mean to remove the review requests, and I also can't add them back. Sorry about that

Comment on lines 113 to 114
let mut schedule = Schedule::new();

Copy link
Contributor

@maniwani maniwani Feb 13, 2023

Choose a reason for hiding this comment

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

Does the render schedule have a default base set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I went by Alice's comment:

I don't think the RenderSchedule should have one: there's no clear default.

But I can add one if needed :)

Copy link
Member

Choose a reason for hiding this comment

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

Looking at how rendering systems were defined and ordered, it wasn't at all clear what the correct "default" would be.

Copy link
Contributor

@maniwani maniwani Feb 13, 2023

Choose a reason for hiding this comment

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

Are there any errors that pop up if you add a system to a schedule that has base sets but doesn't pick one as default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How would I best test that?

Copy link
Contributor

@hymm hymm Feb 13, 2023

Choose a reason for hiding this comment

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

It should be as simple as trying render_schedule.add_system(my_system). I'm pretty sure that should error with something like "my_system needs to be put into a base set", but worth checking.

edit: tested this and it doesn't error. Feels like it should or why bother changing them to be base sets.

Copy link
Contributor

@hymm hymm Feb 13, 2023

Choose a reason for hiding this comment

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

It might make sense to change this to only change the startup schedule to use base sets, but move changing the render schedule to a different pr. Feels like there's a missing configuration option to require that a base set be set, but not set a default set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I reverted the RenderSet changes and updated the PR description.

@alice-i-cecile
Copy link
Member

Totally fine with splitting out the RenderSet changes: they're much less important. Remember to update the title and description.

@TimJentzsch TimJentzsch changed the title Make StartupSet and RenderSet base sets Make StartupSet a base set Feb 14, 2023
@TimJentzsch
Copy link
Contributor Author

Done.

@alice-i-cecile alice-i-cecile removed the X-Controversial There is active debate or serious implications around merging this PR label Feb 14, 2023
@TimJentzsch
Copy link
Contributor Author

I "tested" the changes by running some random examples, it doesn't seem to crash.

Question: With it being a base set, can .in_base_set(StartupSet::Startup) be removed/replaced somehow because StartupSet::Startup is the default now?

@alice-i-cecile
Copy link
Member

Question: With it being a base set, can .in_base_set(StartupSet::Startup) be removed/replaced somehow because StartupSet::Startup is the default now?

This should be removed now :)

@TimJentzsch
Copy link
Contributor Author

Done, .in_base_set(StartupSet::Startup) calls have been removed.

@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 Feb 14, 2023
@alice-i-cecile
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request Feb 19, 2023
# Objective

Closes #7573

- Make `StartupSet` a base set

## Solution

- Add `#[system_set(base)]` to the enum declaration
- Replace `.in_set(StartupSet::...)` with `.in_base_set(StartupSet::...)`

**Note**: I don't really know what I'm doing and what exactly the difference between base and non-base sets are. I mostly opened this PR based on discussion in Discord. I also don't really know how to test that I didn't break everything. Your reviews are appreciated!

---

## Changelog

- `StartupSet` is now a base set

## Migration Guide

`StartupSet` is now a base set. This means that you have to use `.in_base_set` instead of `.in_set`:

### Before

```rs
app.add_system(foo.in_set(StartupSet::PreStartup))
```

### After

```rs
app.add_system(foo.in_base_set(StartupSet::PreStartup))
```
@bors bors bot changed the title Make StartupSet a base set [Merged by Bors] - Make StartupSet a base set Feb 19, 2023
@bors bors bot closed this Feb 19, 2023
@TimJentzsch TimJentzsch deleted the 7573-startupset-renderset-base-sets branch February 19, 2023 09:00
myreprise1 pushed a commit to myreprise1/bevy that referenced this pull request Feb 20, 2023
# Objective

Closes bevyengine#7573

- Make `StartupSet` a base set

## Solution

- Add `#[system_set(base)]` to the enum declaration
- Replace `.in_set(StartupSet::...)` with `.in_base_set(StartupSet::...)`

**Note**: I don't really know what I'm doing and what exactly the difference between base and non-base sets are. I mostly opened this PR based on discussion in Discord. I also don't really know how to test that I didn't break everything. Your reviews are appreciated!

---

## Changelog

- `StartupSet` is now a base set

## Migration Guide

`StartupSet` is now a base set. This means that you have to use `.in_base_set` instead of `.in_set`:

### Before

```rs
app.add_system(foo.in_set(StartupSet::PreStartup))
```

### After

```rs
app.add_system(foo.in_base_set(StartupSet::PreStartup))
```
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-Bug An unexpected or incorrect behavior 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
None yet
Development

Successfully merging this pull request may close these issues.

Make StartupSet and RenderSet base sets
4 participants