Winit: Breaks on xrandr < 1.5

Created on 4 Jul 2019  路  11Comments  路  Source: rust-windowing/winit

I'm trying to run using the Cygwin X11 server packaged with MobaXterm, which supports RANDR 1.4;

jarred@greywind:~$ xrandr --version
xrandr program version       1.5.0
Server reports RandR version 1.4

jarred@greywind:~/projects/winit$ xrandr --listmonitors
RandR 1.5 not supported

jarred@greywind:~/projects/winit$ cargo run --example window
   Compiling winit v0.20.0-alpha1 (/home/jarred/projects/winit)
    Finished dev [unoptimized + debuginfo] target(s) in 12.09s
     Running `target/debug/examples/window`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: OsError { line: 106, file: "src/platform_impl/linux/x11/window.rs", error: XMisc("No monitors were detected.") }', src/libcore/result.rs:997:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
jarred@greywind:~/projects/winit$

I tried changing the error on line 106 in window.rs to just return a default DPI scale factor of 1.0, but that results in deeper "can't find monitor" errors:

jarred@greywind:~/projects/winit$ cargo run --example window
   Compiling winit v0.20.0-alpha1 (/home/jarred/projects/winit)
    Finished dev [unoptimized + debuginfo] target(s) in 10.21s
     Running `target/debug/examples/window`
EventsCleared
thread 'main' panicked at '[winit] Failed to find any monitors using XRandR.', src/libcore/option.rs:1034:5

I tried changing FORCE_RANDR_COMPAT to true in monitors.rs, but that didn't seem to fix anything.

good first issue Windows X11 needs investigation bug

All 11 comments

cc @murarth

This is where the platform = X11 vs platform = Windows breaks down, because this is both.

Maybe we need a platform = Cygwin (or CygwinX11) too.

My, I didn't notice this said Cygwin.

It's running under WSL, so I guess X11 is more appropriate - the code thinks it's all linux

I don't have a Windows installation, so I don't have any way to investigate this.

All I can contribute is that I've just tested the xrandr < 1.5 compatibility code and it still works for me, so this does appear to be a Cygwin-specific issue.

I did a little more digging - when in query_monitor_list, xrandr.XRR.GetScreenResourcesCurrent returns 0 outputs, 0 modes, and 0 crtcs. I re-tried this with the VcXsrv X11 server (which supports RANDR 1.5) and everything worked (with 1 mode, output, and crtc), so I'm thinking that this is actually a bug in the Cygwin X11 server? Other X11 applications work fine (even window managers), so my guess is that most of them aren't trying to directly query about the display hardware.

Looks like the error is getting caused when trying to calculate DPI, which looks at the monitor list to determine DPI and errors if there an't any monitors in the list. FWIW, I'd be okay with defaulting to a DPI factor of 1.0 when no monitors have been found, since we're already defaulting to a DPI factor of 1.0 if monitors have been found but the exact calculations fail.

Hey, I think I'm running into this issue?

thread 'main' panicked at '[winit] Failed to find any monitors using XRandR.', src/libcore/option.rs:1034:5
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:47
   3: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:36
   4: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:200
   5: std::panicking::default_hook
             at src/libstd/panicking.rs:214
   6: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:477
   7: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:384
   8: rust_begin_unwind
             at src/libstd/panicking.rs:311
   9: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
  10: core::option::expect_failed
             at src/libcore/option.rs:1034
  11: core::option::Option<T>::expect
             at /rustc/eae3437dfe991621e8afdc82734f4a172d7ddf9b/src/libcore/option.rs:314
  12: winit::platform::platform::x11::monitor::<impl winit::platform::platform::x11::xdisplay::XConnection>::get_monitor_for_window
             at /home/andrew/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.2/src/platform/linux/x11/monitor.rs:109
  13: winit::platform::platform::x11::EventsLoop::process_event::{{closure}}
             at /home/andrew/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.2/src/platform/linux/x11/mod.rs:552
  14: winit::platform::platform::x11::EventsLoop::with_window::{{closure}}
             at /home/andrew/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.2/src/platform/linux/x11/mod.rs:1251
  15: core::option::Option<T>::map
             at /rustc/eae3437dfe991621e8afdc82734f4a172d7ddf9b/src/libcore/option.rs:416
  16: winit::platform::platform::x11::EventsLoop::with_window
             at /home/andrew/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.2/src/platform/linux/x11/mod.rs:1243
  17: winit::platform::platform::x11::EventsLoop::process_event
             at /home/andrew/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.2/src/platform/linux/x11/mod.rs:477
  18: winit::EventsLoop::run_forever
             at /home/andrew/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.2/src/platform/linux/x11/mod.rs:297
  19: alacritty_terminal::window::Window::wait_events
             at /home/andrew/src/alacritty/alacritty_terminal/src/window.rs:240
  20: alacritty_terminal::event::Processor<N>::process_events
             at /home/andrew/src/alacritty/alacritty_terminal/src/event.rs:465
  21: alacritty::run
             at alacritty/src/main.rs:217
  22: alacritty::main
             at alacritty/src/main.rs:110
  23: std::rt::lang_start::{{closure}}
             at /rustc/eae3437dfe991621e8afdc82734f4a172d7ddf9b/src/libstd/rt.rs:64
  24: main
  25: __libc_start_main
  26: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

This triggers when I close my laptop, which seems to shutdown the monitor, and then crashes Alacritty.

@atamis Are you running on Windows or Linux? If you're on Linux, I believe you're running into #705. That being said, it seems both this issue and that one are being caused by the same underlying problem.

I'm on Linux, so you're probably right.

Can someone test to see if #1158 fixes this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Osspial picture Osspial  路  5Comments

francesca64 picture francesca64  路  4Comments

chemicstry picture chemicstry  路  3Comments

coderhwz picture coderhwz  路  3Comments

swiftcoder picture swiftcoder  路  3Comments