egui: eframe X11 crash after using thread spawn

Describe the bug Random crash 1 out of 4 times when spawning a thread with thread::spawn on X11

[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
rustyboi: ../../src/xcb_io.c:269: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.

To Reproduce Steps to reproduce the behavior:

  • Create a simple eframe app
  • Build it, it shoul start just fine
  • Add thread::spawn with loop{}
  • Build it again, it should start randomly crashing on start

Expected behavior N/A

Screenshots изображение

Desktop (please complete the following information):

  • OS: Pop OS + KDE Plasma X11 (gdm3)
  • Browser: N/A

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 28 (14 by maintainers)

Commits related to this issue

Most upvoted comments

@emilk exactly, even in software render egui runs quite fast.

I finally installed an Ubuntu VM and ran into this exact issue ^^ probably because of using a software renderer like @ambihelical suspected.

for glutin > v0.28.0 or patched glutin, turn off vsync.

// When compiling natively:
fn main() {
    // Log to stdout (if you run with `RUST_LOG=debug`).
    // tracing_subscriber::fmt::init();

    let mut options = eframe::NativeOptions {
        // Let's show off that we support transparent windows
        transparent: true,
        drag_and_drop_support: true,
        ..Default::default()
    };
	
    // like so
    options.vsync = false;
    
    eframe::run_native(
        "egui demo app",
        options,
        Box::new(|cc| Box::new(egui_demo_lib::WrapApp::new(cc))),
    );
}

the error will be gone.

the PR: https://github.com/rust-windowing/glutin/pull/1387 finally being merged a while ago, waiting for glutin > v0.28.0 release