# Objective

- Fix issue @mockersf identified with `example-showcase` where time was
not being received correctly from the render world.

## Solution

- Refactored to ensure `TimeReceiver` is always cleared even if it isn't
being used in the main world.

## Testing

- `cargo run -p example-showcase -- --page 1 --per-page 1 run
--screenshot-frame 200 --fixed-frame-time 0.0125 --stop-frame 450
--in-ci --show-logs`
This commit is contained in:
Zachary Harrold 2025-01-23 13:44:16 +11:00 committed by GitHub
parent 784a9d36bd
commit c7ddec571d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -144,28 +144,28 @@ pub fn time_system(
#[cfg(feature = "std")] time_recv: Option<Res<TimeReceiver>>, #[cfg(feature = "std")] time_recv: Option<Res<TimeReceiver>>,
#[cfg(feature = "std")] mut has_received_time: Local<bool>, #[cfg(feature = "std")] mut has_received_time: Local<bool>,
) { ) {
match update_strategy.as_ref() {
TimeUpdateStrategy::Automatic => {
#[cfg(feature = "std")] #[cfg(feature = "std")]
let new_time = if let Some(time_recv) = time_recv {
// TODO: Figure out how to handle this when using pipelined rendering. // TODO: Figure out how to handle this when using pipelined rendering.
if let Ok(new_time) = time_recv.0.try_recv() { let sent_time = match time_recv.map(|res| res.0.try_recv()) {
Some(Ok(new_time)) => {
*has_received_time = true; *has_received_time = true;
new_time Some(new_time)
} else { }
Some(Err(_)) => {
if *has_received_time { if *has_received_time {
log::warn!("time_system did not receive the time from the render world! Calculations depending on the time may be incorrect."); log::warn!("time_system did not receive the time from the render world! Calculations depending on the time may be incorrect.");
} }
Instant::now() None
} }
} else { None => None,
Instant::now()
}; };
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
let new_time = Instant::now(); let sent_time = None;
real_time.update_with_instant(new_time); match update_strategy.as_ref() {
TimeUpdateStrategy::Automatic => {
real_time.update_with_instant(sent_time.unwrap_or_else(Instant::now));
} }
TimeUpdateStrategy::ManualInstant(instant) => real_time.update_with_instant(*instant), TimeUpdateStrategy::ManualInstant(instant) => real_time.update_with_instant(*instant),
TimeUpdateStrategy::ManualDuration(duration) => real_time.update_with_duration(*duration), TimeUpdateStrategy::ManualDuration(duration) => real_time.update_with_duration(*duration),