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

Move scene spawner systems to SpawnScene schedule #9260

Merged
merged 6 commits into from
Aug 15, 2023

Conversation

lewiszlw
Copy link
Member

@lewiszlw lewiszlw commented Jul 24, 2023

Objective

Changelog

  • Move scene spawner systems to a new SpawnScene schedule which is after Update and before PostUpdate (schedule order: [PreUpdate][Update][SpawnScene][PostUpdate])

Migration Guide

  • Move scene spawner systems to a new SpawnScene schedule which is after Update and before PostUpdate (schedule order: [PreUpdate][Update][SpawnScene][PostUpdate]), you might remove system ordering code related to scene spawning as the execution order has been guaranteed by bevy engine.

@lewiszlw lewiszlw changed the title Pust scene_spawner_system in PreUpdate Move scene_spawner_system to PreUpdate Jul 24, 2023
@Shatur
Copy link
Contributor

Shatur commented Jul 24, 2023

Please, fill the migration guide and changelog properly.

@lewiszlw
Copy link
Member Author

Please, fill the migration guide and changelog properly.

Done.

@Shatur
Copy link
Contributor

Shatur commented Jul 24, 2023

Migration guide describes what users need to do in order to migrate. So you need to ask users to remove .after(scene::scene_spawner_system) if their systems was in Update and add .after(scene::scene_spawner_system) if they have systems that runs on PreUpdate and they want it to run before scene spawn.

@mockersf mockersf 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 Jul 29, 2023
crates/bevy_scene/src/lib.rs Outdated Show resolved Hide resolved
crates/bevy_scene/src/lib.rs Outdated Show resolved Hide resolved
lewiszlw and others added 2 commits July 30, 2023 18:01
Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com>
Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com>
@lewiszlw lewiszlw changed the title Move scene_spawner_system to PreUpdate Move scene_spawner_system to PostUpdate Jul 30, 2023
.add_systems(Update, scene_spawner_system)
// Systems `*_bundle_spawner` must run before `scene_spawner_system`
.add_systems(PreUpdate, scene_spawner);
.add_systems(PostUpdate, (scene_spawner, scene_spawner_system).chain());
Copy link
Contributor

Choose a reason for hiding this comment

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

For reviewers: If we run it in PostUpdate, should run it after propagate_transforms?..

Copy link
Member

Choose a reason for hiding this comment

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

IMO it should run before propagate_transforms and require a command application between them as it would otherwise be improperly placed in the following tick.

Copy link
Contributor

@Shatur Shatur Jul 30, 2023

Choose a reason for hiding this comment

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

Oh, yes, I wanted to write "before".
But why do we need a command flush? Scenes spawned in exclusive system with all necessary parenting.

Copy link
Contributor

@Shatur Shatur Jul 31, 2023

Choose a reason for hiding this comment

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

@james7132 alternatively we could move it to PreUpdate as I suggested in the issue first. Currently we have scene_spawner_system in Update and I think it's not a good choice.

Copy link
Member

Choose a reason for hiding this comment

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

Ah sorry, wasn't too familiar with the scene systems. Sounds good to me to have it just run before propagate_transforms in that case.

@mockersf mockersf removed 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 Jul 30, 2023
@mockersf mockersf self-requested a review July 30, 2023 21:22
Copy link
Member

@james7132 james7132 left a comment

Choose a reason for hiding this comment

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

Just looking to ensure that the system runs before the propagation systems, otherwise LGTM.

@james7132 james7132 added C-Bug An unexpected or incorrect behavior A-Scenes Serialized ECS data stored on the disk C-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide labels Aug 3, 2023
@james7132 james7132 added this to the 0.12 milestone Aug 3, 2023
crates/bevy_scene/src/lib.rs Outdated Show resolved Hide resolved
Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com>
@lewiszlw lewiszlw changed the title Move scene_spawner_system to PostUpdate Move scene_spawner_system to PreUpdate Aug 7, 2023
.add_systems(Update, scene_spawner_system)
// Systems `*_bundle_spawner` must run before `scene_spawner_system`
.add_systems(PreUpdate, scene_spawner);
.add_systems(PreUpdate, (scene_spawner, scene_spawner_system).chain());
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.add_systems(PreUpdate, (scene_spawner, scene_spawner_system).chain());
.add_systems(PostUpdate, (scene_spawner, scene_spawner_system).chain().before(propagate_transform));

Copy link
Contributor

Choose a reason for hiding this comment

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

We discussed it in Discord and decided that it's better to put it in PostUpdate to have fully updated transform.
@lewiszlw I really sorry you had to change it so many times 😄
But this one you can't apply from the browser, you need to import propagate_transform.

Copy link
Member Author

Choose a reason for hiding this comment

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

No worries. Should be .before(TransformSystem::TransformPropagate)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, looks like this is what mostly used in the codebase.

Copy link
Contributor

Choose a reason for hiding this comment

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

Before you make any change, take a look at what cart suggesting, I think it makes sense: #9260 (comment)
Because both solution (PreUpdate and PostUpdate) have downsides, this is why we have such hard time deciding it.

Copy link
Contributor

@Shatur Shatur left a comment

Choose a reason for hiding this comment

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

Judging by the messages in the discord, option 3 from #9260 (comment) is the most reasonable choice. Please add a new schedule and put these systems here.

@cart
Copy link
Member

cart commented Aug 11, 2023

Agreed!

@lewiszlw lewiszlw changed the title Move scene_spawner_system to PreUpdate Move scene spawner systems to SpawnScene schedule Aug 14, 2023
@lewiszlw lewiszlw requested a review from Shatur August 14, 2023 02:37
@Shatur Shatur requested review from nicopap and cart August 14, 2023 07:16
@cart cart added this pull request to the merge queue Aug 14, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 14, 2023
Shatur added a commit to projectharmonia/bevy_replicon that referenced this pull request Aug 15, 2023
Scene spawning will happen after `Update`, so two updates will
be needed anyway, see bevyengine/bevy#9260
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Aug 15, 2023
Merged via the queue into bevyengine:main with commit 55a7109 Aug 15, 2023
20 checks passed
Shatur added a commit to projectharmonia/bevy that referenced this pull request Aug 15, 2023
# Objective

- Fixes bevyengine#9250

## Changelog

- Move scene spawner systems to a new SpawnScene schedule which is after
Update and before PostUpdate (schedule order:
[PreUpdate][Update][SpawnScene][PostUpdate])

## Migration Guide

- Move scene spawner systems to a new SpawnScene schedule which is after
Update and before PostUpdate (schedule order:
[PreUpdate][Update][SpawnScene][PostUpdate]), you might remove system
ordering code related to scene spawning as the execution order has been
guaranteed by bevy engine.

---------

Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com>
Shatur added a commit to projectharmonia/bevy that referenced this pull request Aug 19, 2023
# Objective

- Fixes bevyengine#9250

## Changelog

- Move scene spawner systems to a new SpawnScene schedule which is after
Update and before PostUpdate (schedule order:
[PreUpdate][Update][SpawnScene][PostUpdate])

## Migration Guide

- Move scene spawner systems to a new SpawnScene schedule which is after
Update and before PostUpdate (schedule order:
[PreUpdate][Update][SpawnScene][PostUpdate]), you might remove system
ordering code related to scene spawning as the execution order has been
guaranteed by bevy engine.

---------

Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com>
github-merge-queue bot pushed a commit that referenced this pull request Aug 19, 2023
# Objective

#9260 added this schedule, but it's not in prelude like other schedules.

## Solution

Add to prelude.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Scenes Serialized ECS data stored on the disk C-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move scene_spawner_system to PostUpdate.
7 participants