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

Setting the timer duration to zero panicks #8463

Closed
MWFIAE opened this issue Apr 22, 2023 · 2 comments · Fixed by #8467
Closed

Setting the timer duration to zero panicks #8463

MWFIAE opened this issue Apr 22, 2023 · 2 comments · Fixed by #8467
Labels
A-Time Involves time keeping and reporting C-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy

Comments

@MWFIAE
Copy link

MWFIAE commented Apr 22, 2023

Bevy version

bevy 0.10.1

What you did

I set a repeating timers duration to 0. I did so accidentally using the egui_inspector, but is also reproducible if setting it via code.

What went wrong

Bevy panicked, because it can't divide by 0.

thread 'Compute Task Pool (3)' panicked at 'attempt to divide by zero', C:<redacted>.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_time-0.10.1\src\timer.rs:228:21

Caused by this line of code:

                self.times_finished_this_tick =
                    (self.elapsed().as_nanos() / self.duration().as_nanos()) as u32;```

## Additional information

While in my case it happened for a repeating timer, similar panics can and will happen if for example the percent function of the timer is used, while the duration is set to 0.
@MWFIAE MWFIAE added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Apr 22, 2023
@MWFIAE
Copy link
Author

MWFIAE commented Apr 22, 2023

Also I'm not entirely sure what the expected behaviour would be in a case like that (except it not panicking :) ).

@alice-i-cecile alice-i-cecile added D-Trivial Nice and easy! A great choice to get started with Bevy A-Time Involves time keeping and reporting and removed S-Needs-Triage This issue needs to be labelled labels Apr 22, 2023
@alice-i-cecile
Copy link
Member

I'm not 100% sure what the correct behavior is here either, but it shouldn't be too hard to investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Time Involves time keeping and reporting C-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants