Skip to content

Commit

Permalink
Remove warning about missed events due to false positives (#6730)
Browse files Browse the repository at this point in the history
# Objective

- Reverts #5730.
- Fixes #6173, fixes #6596.

## Solution

Remove the warning entirely.

## Changelog

You will no longer be spammed about

> Missed 31 `bevy_input::mouse::MouseMotion` events. Consider
reading from the `EventReader` more often (generally the best
solution) or calling Events::update() less frequently
(normally this is called once per frame). This problem is most
likely due to run criteria/fixed timesteps or consuming events
conditionally. See the Events documentation for
more information.

when you miss events. These warnings were often (but not always) a false positive. You can still check this manually by using `ManualEventReader::missed_events`
  • Loading branch information
alice-i-cecile committed Nov 23, 2022
1 parent 5b0563a commit f7fe0e6
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions crates/bevy_ecs/src/event.rs
Expand Up @@ -2,7 +2,7 @@

use crate as bevy_ecs;
use crate::system::{Local, Res, ResMut, Resource, SystemParam};
use bevy_utils::tracing::{trace, warn};
use bevy_utils::tracing::trace;
use std::ops::{Deref, DerefMut};
use std::{fmt, hash::Hash, marker::PhantomData};

Expand Down Expand Up @@ -352,15 +352,6 @@ impl<E: Event> ManualEventReader<E> {
events: &'a Events<E>,
) -> impl DoubleEndedIterator<Item = (&'a E, EventId<E>)>
+ ExactSizeIterator<Item = (&'a E, EventId<E>)> {
// if the reader has seen some of the events in a buffer, find the proper index offset.
// otherwise read all events in the buffer
let missed = self.missed_events(events);
if missed > 0 {
let plural = if missed == 1 { "event" } else { "events" };
let type_name = std::any::type_name::<E>();
warn!("Missed {missed} `{type_name}` {plural}. Consider reading from the `EventReader` more often (generally the best solution) or calling Events::update() less frequently (normally this is called once per frame). This problem is most likely due to run criteria/fixed timesteps or consuming events conditionally. See the Events documentation for more information.");
}

let a_index = (self.last_event_count).saturating_sub(events.events_a.start_event_count);
let b_index = (self.last_event_count).saturating_sub(events.events_b.start_event_count);
let a = events.events_a.get(a_index..).unwrap_or_default();
Expand Down

0 comments on commit f7fe0e6

Please sign in to comment.