rust-windowing/glutin

Headless example panics on headless Linux system

Closed this issue · 1 comments

I am trying to run the headless.rs example in a Linux server environment (i.e. no Wayland and no X11). However it panics when trying to create the EventLoop.

$ RUST_BACKTRACE=1 cargo run --example headless
    Finished dev [unoptimized + debuginfo] target(s) in 0.23s
     Running `target/debug/examples/headless`
thread 'main' panicked at 'Failed to initialize any backend! Wayland status: NoCompositorListening X11 status: XOpenDisplayFailed', /home/neo/.cargo/registry/src/github.com-1285ae84e5963aae/winit-0.25.0/src/platform_impl/linux/mod.rs:612:9
stack backtrace:
   0: rust_begin_unwind
   1: std::panicking::begin_panic_fmt
   2: winit::platform_impl::platform::EventLoop<T>::new_any_thread
             at /home/neo/.cargo/registry/src/github.com-1285ae84e5963aae/winit-0.25.0/src/platform_impl/linux/mod.rs:612:9
   3: winit::platform_impl::platform::EventLoop<T>::new
             at /home/neo/.cargo/registry/src/github.com-1285ae84e5963aae/winit-0.25.0/src/platform_impl/linux/mod.rs:567:9
   4: winit::event_loop::EventLoop<T>::with_user_event
             at /home/neo/.cargo/registry/src/github.com-1285ae84e5963aae/winit-0.25.0/src/event_loop.rs:134:25
   5: winit::event_loop::EventLoop<()>::new
             at /home/neo/.cargo/registry/src/github.com-1285ae84e5963aae/winit-0.25.0/src/event_loop.rs:120:9
   6: headless::build_context
             at ./glutin_examples/examples/headless.rs:48:14
   7: headless::main
             at ./glutin_examples/examples/headless.rs:83:35
   8: core::ops::function::FnOnce::call_once
             at /build/rust/src/rustc-1.55.0-src/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Maybe I'm not understanding how this example is supposed to be used correctly. Is there a way to create an event loop withouth Wayland or X11? Or is there a way to gracefully fall back to an osmesa context if creating an event loop fails?

Headless was removed for now.