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] - Fixed criteria-less systems being re-ran unnecessarily #1754

Closed
wants to merge 7 commits into from

Conversation

Ratysz
Copy link
Contributor

@Ratysz Ratysz commented Mar 25, 2021

Fixes #1753.

The problem was introduced while reworking the logic around stages' own criteria. Before #1675 they used to be stored and processed inline with the systems' criteria, and systems without criteria used that of their stage. After, criteria-less systems think they should run, always. This PR more or less restores previous behavior; a less cludge solution can wait until after 0.5 - ideally, until stageless.

@Ratysz Ratysz added C-Bug An unexpected or incorrect behavior A-ECS Entities, components, systems, and events labels Mar 25, 2021
@Ratysz Ratysz added this to the Bevy 0.5 milestone Mar 25, 2021
@Ratysz
Copy link
Contributor Author

Ratysz commented Mar 25, 2021

That one looks like a new lint. I don't think I should fix that as part of this PR.

@Ratysz Ratysz 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 Mar 25, 2021
}
}
}
if let ShouldRun::YesAndCheckAgain = stage_should_run {
Copy link
Member

Choose a reason for hiding this comment

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

doesn't this double-run stage_run_criteria if line 843 returns YesAndCheckAgain

Copy link
Contributor Author

@Ratysz Ratysz Mar 25, 2021

Choose a reason for hiding this comment

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

Yes... yes it does. The perils of rushed single-commit bugfixes. 6e7a51b should take care of that.

To elaborate, this is a remnant of the usual fiddling during implementation. It doesn't break any explicit invariants, hence it passing the tests; but it shouldn't have been there - I simply missed it while going over the fix one last time.

self.stage_run_criteria.should_run(world)
{
let mut stage_should_run = self.stage_run_criteria.should_run(world);
if let ShouldRun::No | ShouldRun::NoAndCheckAgain = stage_should_run {
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't returning here on NoAndCheckAgain mean we don't check again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes: if we check again without running anything (which a No* implies) we're stuck in a loop.

@cart
Copy link
Member

cart commented Mar 26, 2021

Tests pass and this behaves as expected for everything i throw it at. Normally I would wait for your feedback here but I'd like to test on our users asap (and you did give the go-ahead on discord for changes needed). Feel free to follow up if you have suggestions.

@cart
Copy link
Member

cart commented Mar 26, 2021

bors r+

bors bot pushed a commit that referenced this pull request Mar 26, 2021
Fixes #1753.

The problem was introduced while reworking the logic around stages' own criteria. Before #1675 they used to be stored and processed inline with the systems' criteria, and systems without criteria used that of their stage. After, criteria-less systems think they should run, always. This PR more or less restores previous behavior; a less cludge solution can wait until after 0.5 - ideally, until stageless.

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
@bors bors bot changed the title Fixed criteria-less systems being re-ran unnecessarily [Merged by Bors] - Fixed criteria-less systems being re-ran unnecessarily Mar 26, 2021
@bors bors bot closed this Mar 26, 2021
@Ratysz Ratysz deleted the fix_1753 branch March 26, 2021 15:10
@Ratysz
Copy link
Contributor Author

Ratysz commented Mar 26, 2021

It's much cleaner now 👍

The only thing I can add is future plans, just to have them written down somewhere relevant: with stageless, this nested looping won't be necessary, because the outer loop would be the entire schedule itself. It should make the model that much simpler, but might have implications that are hard to see right now.

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 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.

Adding a state lets unrelated systems run twice after system sets v2
2 participants