Fix system param warnings on systems that cannot run anyways (#15397)

# Objective

Fix "system skipped" warnings when validation fails on systems that
wouldn't run because of run conditions.

## Solution

> I think the error is from a system defined as:
> 
> ```rust
> no_gpu_preprocessing::batch_and_prepare_sorted_render_phase::<SPI,
GFBD>
> .run_if(resource_exists::<BatchedInstanceBuffer<GFBD::BufferData>>),
> ```
> 
> So the `run_if` was preventing the panics. Maybe we need to skip
validation if `!system_conditions_met`, or at least silence the warning
in that case.

*By @chescock in
https://discord.com/channels/691052431525675048/692572690833473578/1287865365312831562*

Validation of system is skipped if the system was already skipped by run
conditions.

## Testing

Ran alien addict example, no more warnings.
This commit is contained in:
MiniaczQ 2024-09-23 22:25:49 +02:00 committed by GitHub
parent de3c70a8d3
commit 740d1cc9ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 23 deletions

View file

@ -568,19 +568,19 @@ impl ExecutorState {
should_run &= system_conditions_met;
// SAFETY:
// - The caller ensures that `world` has permission to read any data
// required by the system.
// - `update_archetype_component_access` has been called for system.
let valid_params = unsafe { system.validate_param_unsafe(world) };
if !valid_params {
warn_system_skipped!("System", system.name());
self.skipped_systems.insert(system_index);
if should_run {
// SAFETY:
// - The caller ensures that `world` has permission to read any data
// required by the system.
// - `update_archetype_component_access` has been called for system.
let valid_params = unsafe { system.validate_param_unsafe(world) };
if !valid_params {
warn_system_skipped!("System", system.name());
self.skipped_systems.insert(system_index);
}
should_run &= valid_params;
}
should_run &= valid_params;
should_run
}

View file

@ -81,14 +81,14 @@ impl SystemExecutor for SimpleExecutor {
should_run &= system_conditions_met;
let system = &mut schedule.systems[system_index];
let valid_params = system.validate_param(world);
if !valid_params {
warn_system_skipped!("System", system.name());
if should_run {
let valid_params = system.validate_param(world);
if !valid_params {
warn_system_skipped!("System", system.name());
}
should_run &= valid_params;
}
should_run &= valid_params;
#[cfg(feature = "trace")]
should_run_span.exit();

View file

@ -87,14 +87,14 @@ impl SystemExecutor for SingleThreadedExecutor {
should_run &= system_conditions_met;
let system = &mut schedule.systems[system_index];
let valid_params = system.validate_param(world);
if !valid_params {
warn_system_skipped!("System", system.name());
if should_run {
let valid_params = system.validate_param(world);
if !valid_params {
warn_system_skipped!("System", system.name());
}
should_run &= valid_params;
}
should_run &= valid_params;
#[cfg(feature = "trace")]
should_run_span.exit();