QuantumBadger / Speedy2D

Rust library for hardware accelerated drawing of 2D shapes, images, and text, with an easy to use API.
Apache License 2.0
381 stars 41 forks source link

interface 'wl_surface' has no event 2 (Arch linux + hyprland, window failing to stay open) #112

Open CrazieNewb opened 3 months ago

CrazieNewb commented 3 months ago

On arch linux with hyprland and wayland. Running the helloworld example outputs:

❯ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `target/debug/speedy_2d_interface`
ERROR [speedy2d::window_internal_glutin] Couldn't find primary monitor. Using first available monitor.
DEBUG [speedy2d::window_internal_glutin] Monitor #0 (primary): 0x07CB (BOE)
INFO [speedy2d::window_internal_glutin] Trying vsync=true, multisampling=16...
INFO [speedy2d::window_internal_glutin] Context created
INFO [speedy2d::window_internal_glutin] Centering window. Monitor size: PhysicalSize { width: 1920, height: 1080 }. Window outer size: PhysicalSize { width: 640, height: 240 }.
INFO [speedy2d::window_internal_glutin] Centering window. Monitor size: PhysicalSize { width: 1920, height: 1080 }. Window outer size: PhysicalSize { width: 640, height: 240 }.
INFO [speedy2d::window_internal_glutin] Using OpenGL version: 4.6 (Compatibility Profile) Mesa 24.0.3-arch1.1
INFO [speedy2d::glbackend] GL debug log enabled for glow backend
INFO [speedy2d::glwrapper] GL context manager created
INFO [speedy2d::renderer2d] Creating vertex shader
INFO [speedy2d::renderer2d] Using OpenGL 2.0 shaders
INFO [speedy2d::renderer2d] Creating fragment shader
INFO [speedy2d::renderer2d] Compiling program
INFO [speedy2d::glwrapper] Setting viewport size to 640x240
INFO [speedy2d::window_internal_glutin] Resized: PhysicalSize { width: 960, height: 1030 }
INFO [speedy2d::glwrapper] Setting viewport size to 960x1030
INFO [speedy2d::font_cache] No more space in existing textures (0). Creating new.
interface 'wl_surface' has no event 2
INFO [speedy2d::glwrapper] GL context manager is now inactive

The window opens for 1 frame and closes.

QuantumBadger commented 3 months ago

Thanks for the report -- the example works for me in Weston on Arch.

Does it work after a cargo update? If not, could you give details on which GPU and driver you're using please?

CrazieNewb commented 3 months ago

After cargo update to update from 2.0.0 to 2.1.0 nothing has changed. My CPU is 11th Gen i3-1115G4 and i have no GPU. The example worked on the same laptop on windows 11 if that helps narrow it down.

JustLinuxUser commented 1 month ago

I am having the same issue, and have been having it for a long time. I am on latest hyprland installed, and latest Speedy 2d version, just installed it with cargo add speedy2d. I also checked the winit crate, and the current latest version works perfectly, but not sure where this error is comming from

JustLinuxUser commented 1 month ago

I have some bad news! :smile: I think this crate needs to be updated up to lates glutin (which is rewritten from scratch) for this issue to go away. Good luck

ericsink commented 1 month ago

Digression: The other side of that bad news is that glutin dropped support for iOS in that rewrite. Speedy2D doesn't support iOS yet anyway, but still...

JustLinuxUser commented 1 month ago

For anyone struggling with this, you can set WINIT_UNIX_BACKEND=x11 and run the app in x11 mode, still works Example: WINIT_UNIX_BACKEND=x11 cargo run (Still hoping the update to new glutin is possible)

QuantumBadger commented 1 month ago

Thanks for the details everyone. I've gone ahead and rewritten Speedy2D's window handling code to use the latest version of Glutin!

https://github.com/QuantumBadger/Speedy2D/commit/3159dd1d92bd6d3771b94c7eede0295359ed6372

@JustLinuxUser / @CrazieNewb Could you try the latest version of Speedy2D from the master branch please, to check if this resolves the issue?

speedy2d = { git = "https://github.com/QuantumBadger/Speedy2D.git" }
JustLinuxUser commented 1 month ago

I am so sorry, but no, still having this issue! Here is the backtrace:

thread 'main' panicked at /home/andriy/.cargo/git/checkouts/speedy2d-f61a7bd07eee4969/ba5abfc/src/window_internal_glutin.rs:696:20:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
   2: core::panicking::panic
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:145:5
   3: core::option::unwrap_failed
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/option.rs:1985:5
   4: core::option::Option<T>::unwrap
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/option.rs:933:21
   5: speedy2d::window_internal_glutin::gl_config_picker
             at /home/andriy/.cargo/git/checkouts/speedy2d-f61a7bd07eee4969/ba5abfc/src/window_internal_glutin.rs:696:5
   6: core::ops::function::FnOnce::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:250:5
   7: glutin_winit::DisplayBuilder::build
             at /home/andriy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/glutin-winit-0.4.2/src/lib.rs:126:13
   8: speedy2d::window_internal_glutin::create_best_context
             at /home/andriy/.cargo/git/checkouts/speedy2d-f61a7bd07eee4969/ba5abfc/src/window_internal_glutin.rs:718:22
   9: speedy2d::window_internal_glutin::WindowGlutin<UserEventType>::new
             at /home/andriy/.cargo/git/checkouts/speedy2d-f61a7bd07eee4969/ba5abfc/src/window_internal_glutin.rs:386:13
  10: speedy2d::Window<UserEventType>::new_with_user_events
             at /home/andriy/.cargo/git/checkouts/speedy2d-f61a7bd07eee4969/ba5abfc/src/lib.rs:1433:27
  11: speedy2d::Window::new_with_options
             at /home/andriy/.cargo/git/checkouts/speedy2d-f61a7bd07eee4969/ba5abfc/src/lib.rs:1419:9
  12: speedy2d::Window::new_centered
             at /home/andriy/.cargo/git/checkouts/speedy2d-f61a7bd07eee4969/ba5abfc/src/lib.rs:1390:9
  13: day17_2::main
             at ./src/main.rs:240:18
  14: core::ops::function::FnOnce::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
JustLinuxUser commented 1 month ago

and WINIT_UNIX_BACKEND=x11 cargo run doesn't work either now. Same error