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

Egui, Windows: hot-egui example crashes on reload if updated to eframe version > 0.19.0 #31

Open
gabrieldechichi opened this issue May 26, 2023 · 1 comment

Comments

@gabrieldechichi
Copy link

gabrieldechichi commented May 26, 2023

The hot-egui example crashes on reload, if eframe is updated to version any version above 0.19.0 (0.20.0, 0.21.0 or 0.22.0), with the following error:

Running `target\debug\hot-egui.exe`
error: process didn't exit successfully: `target\debug\hot-egui.exe` (exit code: 0xc000041d)

Machine specs:

OS: Windows 11 Home (10.0.22621)
CPU: AMD Ryzen 7 5800H
GPU: Geforce RTX 3600

Repro steps:

  • Switch eframe version on hot-egui example from 0.19.0 to any 0.2x.x version
  • Run sample with cargo watch -w lib -x 'build -p lib' and cargo run --features reload
  • Make a change to the render function on lib/src/lib.rs (I usually remove/add the ui.heading)
  • Application freezes and crashes a couple after reload

This is most likely due to a change on eframe, but I'm unsure how to debug this. Any suggestions?

@gabrieldechichi gabrieldechichi changed the title Egui, Windows: hot-egui example crashes on reload if updated to eframe 0.22.0 Egui, Windows: hot-egui example crashes on reload if updated to eframe version > 0.19.0 May 26, 2023
@branpk
Copy link

branpk commented Sep 15, 2023

Fwiw - I get a crash as described on Windows when using egui, but with egui-winit + egui-wgpu instead of eframe.

The solution is to make sure that egui isn't updating or rendering when the dll is reloaded. Here's how I did it in my case:

let mutex: Arc<Mutex<()>> = Arc::new(Mutex::new(()));

// once at start:
let observer = hot_reload::subscribe();
std::thread::spawn(move || loop {
    let block_reload = observer.wait_for_about_to_reload();
    let lock = mutex.lock().unwrap();
    drop(block_reload);
    observer.wait_for_reload();
});

// before rendering/updating the egui state:
let lock = mutex.lock().unwrap();
...

I think it'd be a little trickier if you don't own the main loop, but it should still be doable.

Edit: simplified and made the code more robust

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants