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

[Merged by Bors] - Fix crash when using Duration::MAX #4900

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions crates/bevy_winit/src/winit_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ pub enum UpdateMode {
/// Once the app has executed all bevy systems and reaches the end of the event loop, there is
/// no way to force the app to wake and update again, unless a `winit` event (such as user
/// input, or the window being resized) is received or the time limit is reached.
Reactive { max_wait: Duration },
Reactive {
/// The maximum time to wait before the event loop runs again. Note that if the duration is
Copy link
Member

Choose a reason for hiding this comment

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

These should be line split, and the advice should be more precise. What do we need to set the value to in order to get an indefinite wait?

In many ways, this is actually a feature, so we should demonstrate how to use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well the problem is that it's platform dependent. Some platforms store Instants as u32s, others store them as u64s so the answer is "dunno, you figure it out." :) That said, using Duration::MAX is effectively the same as waiting for ever so I made a note of that.

/// too high, Bevy will wait indefinitely.
max_wait: Duration,
},
/// The event loop will only update if there is a winit event from direct interaction with the
/// window (e.g. mouseover), a redraw is requested, or the maximum wait time has elapsed.
///
Expand All @@ -85,5 +89,9 @@ pub enum UpdateMode {
/// window is not focused, to only re-draw your bevy app when the cursor is over the window, but
/// not when the mouse moves somewhere else on the screen. This helps to significantly reduce
/// power consumption by only updated the app when absolutely necessary.
ReactiveLowPower { max_wait: Duration },
ReactiveLowPower {
/// The maximum time to wait before the event loop runs again. Note that if the duration is
/// too high, Bevy will wait indefinitely.
max_wait: Duration,
},
}