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

panic when calling Window::current_monitor() on wayland #618

Open
eirikblekesaune opened this issue Jun 17, 2020 · 10 comments
Open

panic when calling Window::current_monitor() on wayland #618

eirikblekesaune opened this issue Jun 17, 2020 · 10 comments

Comments

@eirikblekesaune
Copy link
Contributor

OS: Arch Linux
WM: Sway (Wayland)
wayland 1.18.0-2
wayland-protocols 1.20-1
mesa 20.1.1-1
vulkan-intel 20.1.1-1
vulkan-icd-loader 1.2.141-1

The example window_coordinates has a call to window.current_monitor() that causes panic.
It may be related to this winit issue: rust-windowing/winit#1257

Here is a short reproducer using winit directly:

use winit::{
    event_loop::{EventLoop},
    window::WindowBuilder,
};

fn main() {
    let event_loop = EventLoop::new();
    let window = WindowBuilder::new().build(&event_loop).unwrap();
    window.current_monitor();
}
@eirikblekesaune
Copy link
Contributor Author

eirikblekesaune commented Jun 17, 2020

Downgraded to wayland 1.18.0-1 and now the error doesn't occur in the winit reproducer above.
But the window_coordinates now gets another error:

[eirik@black nannou]$ cargo run --example window_coordinates
    Finished dev [unoptimized + debuginfo] target(s) in 0.16s
     Running `target/debug/examples/window_coordinates`
thread 'main' panicked at 'could not build default app window: NoAvailableAdapter', /home/eirik/git/nannou-org/nannou/nannou/src/app.rs:454:29
stack backtrace:
   0:     0x5612cb62ab65 - backtrace::backtrace::libunwind::trace::hc3f32ba24d88242a
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1:     0x5612cb62ab65 - backtrace::backtrace::trace_unsynchronized::h1f075597100358e7
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2:     0x5612cb62ab65 - std::sys_common::backtrace::_print_fmt::h4397782fec59f199
                               at src/libstd/sys_common/backtrace.rs:78
   3:     0x5612cb62ab65 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h39652f0242246c81
                               at src/libstd/sys_common/backtrace.rs:59
   4:     0x5612cb65204c - core::fmt::write::h540ac4a6a1232abc
                               at src/libcore/fmt/mod.rs:1076
   5:     0x5612cb627953 - std::io::Write::write_fmt::haa03b5883ee9e297
                               at src/libstd/io/mod.rs:1537
   6:     0x5612cb62d2f0 - std::sys_common::backtrace::_print::ha6d9bdf9f438acec
                               at src/libstd/sys_common/backtrace.rs:62
   7:     0x5612cb62d2f0 - std::sys_common::backtrace::print::ha1fba17a8e5f6bc7
                               at src/libstd/sys_common/backtrace.rs:49
   8:     0x5612cb62d2f0 - std::panicking::default_hook::{{closure}}::hbf9fcecd42c17d90
                               at src/libstd/panicking.rs:198
   9:     0x5612cb62d03c - std::panicking::default_hook::h39b8550780094336
                               at src/libstd/panicking.rs:218
  10:     0x5612cb62d927 - std::panicking::rust_panic_with_hook::hc8b48ce48004c103
                               at src/libstd/panicking.rs:477
  11:     0x5612cb62d52b - rust_begin_unwind
                               at src/libstd/panicking.rs:385
  12:     0x5612cb64fcd1 - core::panicking::panic_fmt::h78830ea6a34e7206
                               at src/libcore/panicking.rs:86
  13:     0x5612cb64faf3 - core::option::expect_none_failed::hf79bbb5ca7e09e08
                               at src/libcore/option.rs:1272
  14:     0x5612cacc9f28 - core::result::Result<T,E>::expect::h47f0d006e4d32ad9
                               at /home/eirik/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/result.rs:963
  15:     0x5612cacf0d15 - nannou::app::Builder<M,E>::run::h59ca6b20f4260ad0
                               at /home/eirik/git/nannou-org/nannou/nannou/src/app.rs:454
  16:     0x5612cacf1282 - nannou::app::SketchBuilder<E>::run::h172c9b2e348c7f48
                               at /home/eirik/git/nannou-org/nannou/nannou/src/app.rs:496
  17:     0x5612cace30d0 - window_coordinates::main::h1e8281e71ba2506c
                               at examples/nannou_basics/window_coordinates.rs:4
  18:     0x5612cad12deb - std::rt::lang_start::{{closure}}::he64623563859e1d4
                               at /home/eirik/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:67
  19:     0x5612cb62ddb8 - std::rt::lang_start_internal::{{closure}}::hcf986077e2da8d6b
                               at src/libstd/rt.rs:52
  20:     0x5612cb62ddb8 - std::panicking::try::do_call::h076edd10f2a91969
                               at src/libstd/panicking.rs:297
  21:     0x5612cb62ddb8 - std::panicking::try::h54343dd1a9d830aa
                               at src/libstd/panicking.rs:274
  22:     0x5612cb62ddb8 - std::panic::catch_unwind::h81799eb8afacafdd
                               at src/libstd/panic.rs:394
  23:     0x5612cb62ddb8 - std::rt::lang_start_internal::hf4abd869024c3270
                               at src/libstd/rt.rs:51
  24:     0x5612cad12dc7 - std::rt::lang_start::h42ed0729e5c1887a
                               at /home/eirik/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:67
  25:     0x5612cace59ba - main
  26:     0x7f05bf364002 - __libc_start_main
  27:     0x5612cacbc1ae - _start
  28:                0x0 - <unknown>

@eirikblekesaune
Copy link
Contributor Author

No luck with stable rust either.

@eirikblekesaune
Copy link
Contributor Author

I have tested it with i3 X11 now, and this example works fine there.

@mitchmindtree
Copy link
Member

Thanks for reporting and diving into this @eirikblekesaune!

I'm also using wayland (nixos + gnome) but am unable to reproduce either error in window_coordinates.rs locally.

[nix-shell:~/programming/rust/nannou]$ gnome-shell --version
GNOME Shell 3.36.3

I did notice that the wayland crate versions I'm pulling in seem to be a lot more recent:

   Compiling wayland-sys v0.23.6                                                                                                              
   Compiling wayland-scanner v0.23.6                                                                                                          
   ...
   Compiling wayland-client v0.23.6                                                                                                           
   Compiling wayland-protocols v0.23.6                                                                                                        
   Compiling winit v0.22.2

Just to be sure, you are building the master branch of nannou yes? If you've had nannou cloned locally for a while, it might also be worth running cargo update to ensure use of the latest version of each dependency.

If you can also produce this bug using your code snippet above with the latest master branch of winit, it might be helpful to share your code for reproducing the bug on that issue (or in a new issue) at the winit issue tracker if you have not already done so. I'm sure they'll appreciate having an easy way to reproduce the bug.

@eirikblekesaune
Copy link
Contributor Author

Thank you @mitchmindtree !
I have tried to update the crates and ensured that I am building on the 'master' branch. But the bug still occures. I looked more closely over the issues that have been reported to winit and it seems to me that there already is an issue related to this, and it is a complex one from what I understand: rust-windowing/winit#793
Being a novice Rust programmer I'm out of my depths in attempting to fix this issue but I have poked around, throwing some tracer bullets into local copies of the dependencies, and it is good fun. I saw that the failed call in winit/window.rs:398 is actually due to that the smithay_client_toolkit, on line 62, the create_surface function returns None.

Maye you could test on your system that this line returns a surface for you?

@cwyc
Copy link

cwyc commented Nov 15, 2020

Hi @mitchmindtree , I wonder if you would mind sharing the nix environment you're using. I'm also running nixos and gnome, and I'm having this same problem.

@mitchmindtree
Copy link
Member

@cwyc here is my nix configuration. The env/rust-dev.nix is the shell I use for all my rust development, including nannou. It might have more stuff than you need though, as I use it for all of my rust dev, not just nannou.

@cwyc
Copy link

cwyc commented Nov 26, 2020

@mitchmindtree Thanks. Turns out what your setup had that was missing in mine was the line adding vulkan-loader and the xorg libraries to $LD_LIBRARY_PATH. Maybe that's relevant to this issue.

@gilescope
Copy link

If you are getting this error on nixos then this issue did the trick for me: bevyengine/bevy#136

@anpin
Copy link

anpin commented Sep 24, 2022

for anyone else having this error on nixos I'll post shell.nix which worked for me maybe some of these dependencies are not needed, but that is the version which ended up working for me after few attempts

let
  pkgs = import <nixpkgs> { };
in with pkgs;
mkShell {
  name = "nannou-sample";
  nativeBuildInputs = with pkgs; [
    pkgconfig
    clang
    lld
  ];
  buildInputs = with pkgs; [
    wayland
    xorg.libX11
    xorg.libXcursor
    xorg.libXrandr
    xorg.libXi
    vulkan-loader
    udev
    cmake
    gcc
    cargo
    rustc
  ];
  shellHook = ''
              export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${
                pkgs.lib.makeLibraryPath [
                  udev
                  vulkan-loader
                ]
              }"'';
  RUST_SRC_PATH = rustPlatform.rustLibSrc;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants