-
Hello, I've created my app by modifying the eframe native template and when trying to run it in a new thread from other crate using ThreadPool, I get this:
Is there any simple way of fixing it without patching egui or eframe ? I really only need this to work on Linux for now. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Seems there no way.Maybe you could run them independent and communicate between them using other protocols instead of channel. |
Beta Was this translation helpful? Give feedback.
-
@kubo-von This package does not support running a even loop outside of the main thread, and I suggest you to use winsafe. It supports that well. |
Beta Was this translation helpful? Give feedback.
-
Actually there is a way under Linux to do this: [dependencies.winit]
default-features = false
features = ["wayland"]
version = "0.28.7"
[dependencies.eframe]
default-features = false
features = ["default_fonts", "glow", "wayland"]
version = "0.23.0" Then do this in rust: use std::thread;
use eframe::egui;
use eframe::EventLoopBuilderHook;
use winit::platform::wayland::EventLoopBuilderExtWayland;
fn main() {
let _handle = thread::spawn(|| {
let event_loop_builder: Option<EventLoopBuilderHook> = Some(Box::new(|event_loop_builder| {
event_loop_builder.with_any_thread(true);
}));
let native_options = eframe::NativeOptions {
event_loop_builder,
..Default::default()
};
eframe::run_simple_native("App", native_options, update).expect("failed to run app");
});
loop {}
}
fn update(ctx: &eframe::egui::Context, _: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("hello");
});
} |
Beta Was this translation helpful? Give feedback.
-
I've stopped on a solution, when the main thread spawns a separate executable GUI process, and communicates with it on websockets. In case of panic in main ‒ both are being killed. |
Beta Was this translation helpful? Give feedback.
Actually there is a way under Linux to do this:
Add this to your Cargo.toml
Then do this in rust: