Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

window.current_monitor() panics on Wayland when the window is hidden #1257

Closed
parasyte opened this issue Nov 2, 2019 · 7 comments
Closed
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - wayland F - duplicate This issue or pull request already exists

Comments

@parasyte
Copy link

parasyte commented Nov 2, 2019

Similar to #793 but panics in a completely different code path:

let output = get_outputs(&self.surface).last().unwrap().clone();

Backtrace

RUST_BACKTRACE=full cargo run --example invaders
    Finished dev [unoptimized + debuginfo] target(s) in 0.07s
     Running `target/debug/examples/invaders`
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21
stack backtrace:
   0:     0x55b548e031ab - backtrace::backtrace::libunwind::trace::h89fcc71e59e3bc5b
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/libunwind.rs:88
   1:     0x55b548e031ab - backtrace::backtrace::trace_unsynchronized::h0bad9be1379e729a
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/mod.rs:66
   2:     0x55b548e031ab - std::sys_common::backtrace::_print::hd3382a1f33c473da
                               at src/libstd/sys_common/backtrace.rs:47
   3:     0x55b548e031ab - std::sys_common::backtrace::print::h0ec6f03cfb8e76a6
                               at src/libstd/sys_common/backtrace.rs:36
   4:     0x55b548e031ab - std::panicking::default_hook::{{closure}}::h96cbf7b454e3f557
                               at src/libstd/panicking.rs:200
   5:     0x55b548e02e86 - std::panicking::default_hook::h95a8f00337383d83
                               at src/libstd/panicking.rs:214
   6:     0x55b548e0391d - std::panicking::rust_panic_with_hook::h92f98b46e22f14ed
                               at src/libstd/panicking.rs:477
   7:     0x55b548e034a2 - std::panicking::continue_panic_fmt::h25abfbb4e5b7043a
                               at src/libstd/panicking.rs:384
   8:     0x55b548e03386 - rust_begin_unwind
                               at src/libstd/panicking.rs:311
   9:     0x55b548e1f61d - core::panicking::panic_fmt::h7e9f94035af782b3
                               at src/libcore/panicking.rs:85
  10:     0x55b548e1f55c - core::panicking::panic::hda536e6f3accfb91
                               at src/libcore/panicking.rs:49
  11:     0x55b548654f6b - core::option::Option<T>::unwrap::h53f213eec78b21d3
                               at /rustc/625451e376bb2e5283fc4741caa0a3e8a2ca4d54/src/libcore/macros.rs:12
  12:     0x55b5486868a7 - winit::platform_impl::platform::wayland::window::Window::current_monitor::h1fc431212bb70582
                               at /home/m4b/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.20.0-alpha4/src/platform_impl/linux/wayland/window.rs:334
  13:     0x55b5483471ad - winit::platform_impl::platform::Window::current_monitor::h36ec4e3753050276
                               at /home/m4b/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.20.0-alpha4/src/platform_impl/linux/mod.rs:433
  14:     0x55b54831588e - winit::window::Window::current_monitor::h331f66498ad0d993
                               at /home/m4b/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.20.0-alpha4/src/window.rs:744
  15:     0x55b54831652d - invaders::create_window::h8db4b89ce4d72ed3
                               at examples/invaders/main.rs:144
  16:     0x55b548315c04 - invaders::main::h7e93825e303b3309
                               at examples/invaders/main.rs:26
  17:     0x55b5483324e0 - std::rt::lang_start::{{closure}}::h83eea46cd4c6445f
                               at /rustc/625451e376bb2e5283fc4741caa0a3e8a2ca4d54/src/libstd/rt.rs:64
  18:     0x55b548e03323 - std::rt::lang_start_internal::{{closure}}::h4e93c1949c7a1955
                               at src/libstd/rt.rs:49
  19:     0x55b548e03323 - std::panicking::try::do_call::h9440ccd4dc467eaa
                               at src/libstd/panicking.rs:296
  20:     0x55b548e07bfa - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:80
  21:     0x55b548e03e2d - std::panicking::try::hc046e7ee42ee744f
                               at src/libstd/panicking.rs:275
  22:     0x55b548e03e2d - std::panic::catch_unwind::h27dfc457c200aee0
                               at src/libstd/panic.rs:394
  23:     0x55b548e03e2d - std::rt::lang_start_internal::hea1b49a567afe309
                               at src/libstd/rt.rs:48
  24:     0x55b5483324b9 - std::rt::lang_start::hf88dabd11b766af7
                               at /rustc/625451e376bb2e5283fc4741caa0a3e8a2ca4d54/src/libstd/rt.rs:64
  25:     0x55b548316aca - main
  26:     0x7f49b4c81153 - __libc_start_main
  27:     0x55b5482f31ae - _start

Originally reported on parasyte/pixels#29

@parasyte parasyte changed the title window.current_monitor() panics on Wayland when the window is hidden window.current_monitor() panics on Wayland and X11 when the window is hidden Nov 5, 2019
@parasyte parasyte changed the title window.current_monitor() panics on Wayland and X11 when the window is hidden window.current_monitor() panics on Wayland when the window is hidden Nov 5, 2019
@goddessfreya goddessfreya added DS - wayland C - needs investigation Issue must be confirmed and researched B - bug Dang, that shouldn't have happened labels Nov 6, 2019
@parasyte
Copy link
Author

parasyte commented Nov 8, 2019

I just tested this for myself on a VM. I get the same panic running the invaders example in pixels, but it reproduces even without hiding the window. Something is really screwy, though. I don't see a window at all in Wayland. Even the winit examples don't show a window.

@elinorbgr
Copy link
Contributor

Something is really screwy, though. I don't see a window at all in Wayland. Even the winit examples don't show a window.

A wayland window does not appear on the screen until it has been drawn at least once. Before that is done, the window has no existence, and as such is not displayed, does not receive any event, and is not considered to be on any monitor.

@parasyte
Copy link
Author

parasyte commented Nov 9, 2019

I only see a window with WINIT_UNIX_BACKEND=x11. It doesn't work when set to wayland, which is my display manager according to echo $XDG_SESSION_TYPE.

WINIT_UNIX_BACKEND=wayland cargo run --example window

@parasyte
Copy link
Author

parasyte commented Nov 9, 2019

Something is really screwy, though. I don't see a window at all in Wayland. Even the winit examples don't show a window.

A wayland window does not appear on the screen until it has been drawn at least once. Before that is done, the window has no existence, and as such is not displayed, does not receive any event, and is not considered to be on any monitor.

Even with the winit examples, though? What?

@elinorbgr
Copy link
Contributor

The winit examples do not draw anything, that's a long running issue we've had, but we didn't yet find a satisfactory way to handle it.

In your case, the window never appearing is possibly due to the fact that you start the event loop before having drawn anything, so winit blocks waiting for events that never come as the window do not exist on screen yet. At least these symptoms match.

@parasyte
Copy link
Author

@vberger is there something "reasonable" to draw before entering the event loop? An empty window frame, perhaps? In my case I could draw the unscaled image and then attempt to resize and re-position the window. That would probably look very bad, though.

@kchibisov
Copy link
Member

Duplicate of #793

@kchibisov kchibisov marked this as a duplicate of #793 Aug 23, 2020
@kchibisov kchibisov added the F - duplicate This issue or pull request already exists label Aug 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - wayland F - duplicate This issue or pull request already exists
Development

No branches or pull requests

4 participants