Skip to content

Allow BRP schedule.graph to initialize the schedules it is collecting.#23743

Open
andriyDev wants to merge 2 commits intobevyengine:mainfrom
andriyDev:brp-init-schedules
Open

Allow BRP schedule.graph to initialize the schedules it is collecting.#23743
andriyDev wants to merge 2 commits intobevyengine:mainfrom
andriyDev:brp-init-schedules

Conversation

@andriyDev
Copy link
Copy Markdown
Contributor

@andriyDev andriyDev commented Apr 10, 2026

Objective

Solution

  • Cache the ScheduleBuildMetadata whenever a schedule is built (the ScheduleBuilt event).
  • Lookup this metadata when BRP schedule.graph runs, and use it to extract the schedule data.
    • This metadata includes the edges for automatically inserted systems, making the resulting ScheduleData more accurate to the running schedule.
  • If the schedule needs to be built (has changed/hasn't run before), build the schedule which automatically caches its metadata.

Testing

  • Added a test for this.

@andriyDev andriyDev added this to the 0.19 milestone Apr 10, 2026
@andriyDev andriyDev added C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Dev-Tools Tools used to debug Bevy applications. D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 10, 2026
@andriyDev andriyDev force-pushed the brp-init-schedules branch from 63fc5bc to d579593 Compare April 10, 2026 00:46
let response = serde_json::from_value::<BrpScheduleGraphResponse>(response).unwrap();

// We expect 3 edges thanks to the cached metadata: f1 -> f2, f1 -> apply_deferred -> f2
assert_eq!(response.schedule_data.dependency.len(), 3);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

would heavily prefer we asserted that these systems are the systems we expect. I recently ran into a test suite that only used the counts like this in an ecosystem crate and it was more confusing to fix than it needed to be, since the test didn't include which items it expected to exist other than the count.

As an example (anything similar would be fine if you prefer .find or something):

Suggested change
assert_eq!(response.schedule_data.dependency.len(), 3);
assert!(response.schedule_data.systems[0].name.ends_with("f1"));
assert!(response.schedule_data.systems[1]
.name
.ends_with("apply_deferred"));
assert!(response.schedule_data.systems[2].name.ends_with("f2"));
assert_eq!(response.schedule_data.dependency.len(), 3);

@Zeophlite Zeophlite added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Dev-Tools Tools used to debug Bevy applications. C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Straightforward Simple bug fixes and API improvements, docs, test and examples 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.

4 participants