rust-windowing / glutin

A low-level library for OpenGL context creation
Apache License 2.0
2k stars 477 forks source link

winit panicks failing to find x11 monitor #1018

Closed spearman closed 6 years ago

spearman commented 6 years ago

When I iterate over available monitors with events loop, nothing is returned, and attempting to call get_primary_monitor() will crash:

extern crate glium;
use glium::glutin;

fn main () {
  {
    let events_loop = glutin::EventsLoop::new();
    let mut available_monitors_count = 0;
    for i in events_loop.get_available_monitors() {
      available_monitors_count += 1;
    }
    println!("avilable monitors count: {}", available_monitors_count);
    let primary_monitor = events_loop.get_primary_monitor(); // crash 1
  }
  let events_loop = glutin::EventsLoop::new();  // crash 2
}

crash 1 with:

thread 'main' panicked at '[winit] Failed to find any x11 monitor', libcore/option.rs:916:5

crash 2 with:

thread 'main' panicked at 'Failed to call XInternAtom: XError { description: "BadRequest (invalid request code or no such operation)", error_code: 1, request_code: 140, minor_code: 42 }', libcore/result.rs:945:5

Previously the iter loop would show some available monitors, and the primary monitor would be returned, but I'm not sure exactly what has changed since the last time it worked. This is on end of life LTS Ubuntu (14.04) so it may be something out of date.

francesca64 commented 6 years ago

You'll get a much faster response to winit issues if you report them to winit: https://github.com/tomaka/winit