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

Random silent crashes possibly related to ScheduleRunnerPlugin #609

Closed
ashneverdawn opened this issue Oct 1, 2020 · 2 comments · Fixed by #610
Closed

Random silent crashes possibly related to ScheduleRunnerPlugin #609

ashneverdawn opened this issue Oct 1, 2020 · 2 comments · Fixed by #610
Labels
P-Crash A sudden unexpected crash

Comments

@ashneverdawn
Copy link
Contributor

ashneverdawn commented Oct 1, 2020

I have this weird issue where bevy will randomly crash silently.
The issue tends to happen sooner the higher the framerate is set to.

use bevy::{app::ScheduleRunnerPlugin, prelude::*};
use std::time::{Duration, Instant};

fn main() {
  App::build()
    .add_plugin(ScheduleRunnerPlugin::run_loop(Duration::from_secs_f64(1.0 / 120.0)))
    .add_resource(Timer(Instant::now(), 0))
    .add_system(bevy_update.system())
    .run();
  println!("bevy shutdown unexpectedly!");
}
pub struct Timer(Instant, u64);
pub fn bevy_update(mut timer: ResMut<Timer>) {
  let elapsed = Instant::now().duration_since(timer.0).as_secs();
  if elapsed != timer.1 && elapsed % 3 == 0 {
    timer.1 = elapsed;
    println!("seconds elapsed: {}", elapsed);
  }
}

Tested on master:
at 240fps, I get it 1-5 secs in.
at 120fps, 10-30 secs in.
at 60fps, 30-60 secs in.
at 30fps, it happened 255 secs in.

This was tested on an old 2014 macbook pro, so if you're on a more recent machine, you may have to up the framerate to successfully reproduce it in a timely manner.

Note: What I refer to as "framerate" is from this line:

    .add_plugin(ScheduleRunnerPlugin::run_loop(Duration::from_secs_f64(1.0 / 120.0)))
@Moxinilian Moxinilian added the P-Crash A sudden unexpected crash label Oct 1, 2020
@DJMcNab

This comment has been minimized.

@DJMcNab
Copy link
Member

DJMcNab commented Oct 1, 2020

I've got it
If your tick takes longer than the wait duration, the schedule runner exits, because the exit condition of tick doesn't determine between no wait and app exit requested, which is clearly wrong.

while let Some(delay) = tick(&mut app, wait) {

DJMcNab added a commit to DJMcNab/bevy that referenced this issue Oct 1, 2020
@cart cart closed this as completed in #610 Oct 1, 2020
cart pushed a commit that referenced this issue Oct 1, 2020
mrk-its pushed a commit to mrk-its/bevy that referenced this issue Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-Crash A sudden unexpected crash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants