emilk/egui · error

Stopwatch is not running

Error message

Stopwatch is not running

What it means

Error "Stopwatch is not running" thrown in emilk/egui.

Source

Thrown at crates/eframe/src/stopwatch.rs:26

    /// None = not running
    start: Option<Instant>,
}

impl Stopwatch {
    pub fn new() -> Self {
        Self {
            total_time_ns: 0,
            start: None,
        }
    }

    pub fn start(&mut self) {
        assert!(self.start.is_none(), "Stopwatch already running");
        self.start = Some(Instant::now());
    }

    pub fn pause(&mut self) {
        let start = self.start.take().expect("Stopwatch is not running");
        let duration = start.elapsed();
        self.total_time_ns += duration.as_nanos();
    }

    pub fn resume(&mut self) {
        assert!(self.start.is_none(), "Stopwatch still running");
        self.start = Some(Instant::now());
    }

    pub fn total_time_ns(&self) -> u128 {
        if let Some(start) = self.start {
            // Running
            let duration = start.elapsed();
            self.total_time_ns + duration.as_nanos()
        } else {
            // Paused
            self.total_time_ns
        }

View on GitHub (pinned to b9a0723d88)

Solutions

  1. Call start() on the Stopwatch before calling pause(); pause() requires a running stopwatch.

Example fix

let mut sw = Stopwatch::new(); sw.start(); /* ... */ sw.pause();

When it happens

Trigger: Thrown at crates/eframe/src/stopwatch.rs:26 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of emilk/egui@b9a0723d88 (2026-08-19). Data as JSON: /api/errors/ea4a71d5411804ea. Report an issue: GitHub.