egui-baseview icon indicating copy to clipboard operation
egui-baseview copied to clipboard

The window close does not stop / drop the egui loop

Open alamminsalo opened this issue 3 years ago • 3 comments

When reopening vst plugin window, the earlier draw loop continues to run, leading to multiple simultaneous ui-processes running.

Steps to reproduce: add times_opened usize to editor and pass incremented copy of it to window state. Then close and reopen window couple of times:

    fn close(&mut self) {
        self.is_open = false;
        if let Some(mut window_handle) = self.window_handle.take() {
            (window_handle.0).close();
        }
    }

    fn open(&mut self, parent: *mut ::std::ffi::c_void) -> bool {
        match self.is_open() {
            true => false,
            false => {
                // info!("Open editor");
                self.is_open = true;
                self.times_opened += 1;

                let settings = Settings {
                    ...
                };

                let window_handle = EguiWindow::open_parented(
                    &VstParent(parent),
                    settings,
                    (
                        self.times_opened,
                    ),
                    |_egui_ctx, _queue, _state| {},
                    |egui_ctx: &CtxRef, _, (times_opened)| {
                        info!("{}: draw", times_opened);
                        ui::draw_ui(egui_ctx); // ui draw func
                    },
                );

                self.window_handle = Some(WindowParent(window_handle));
                true
            }
        }

If opened 2 times, this prints continuously

1: draw
2: draw
1: draw
2: draw
...

alamminsalo avatar Mar 29 '22 05:03 alamminsalo

Oh sorry, I'm really late to this one.

I've just made some changes that updates to using egui 0.19, so can you test if this is still an issue?

BillyDM avatar Sep 21 '22 22:09 BillyDM

Hi, I experienced the same issue, this is on MacOS. I experimented by changing the dependency to this commit of baseview https://github.com/RustAudio/baseview/commit/2c1b1a7b0fef1a29a5150a6a8f6fef6a0cbab8c4 , which conveniently addresses the following issue: Fix window cleanup logic on macOS. I can confirm update stopped being called after I closed the window.

valsteen avatar Feb 10 '24 23:02 valsteen