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

GraphicsContext::supported_resolutions panics on Wayland #1270

Open
pophilpo opened this issue Jan 28, 2024 · 0 comments
Open

GraphicsContext::supported_resolutions panics on Wayland #1270

pophilpo opened this issue Jan 28, 2024 · 0 comments

Comments

@pophilpo
Copy link

pophilpo commented Jan 28, 2024

Describe the bug
When calling ctx.gfx.supported_resolutions() program panics on calling Option::unwrap() on a None value

To Reproduce
Here's a small code snippet that panics

use ggez::GameResult;

fn main() -> GameResult {
    let window_mode = ggez::conf::WindowMode::default()
        .resizable(true)
        .dimensions(1024.0, 1024.0);

    let cb = ggez::ContextBuilder::new("Bug", "pophilpo").window_mode(window_mode);
    let (mut ctx, event_loop) = cb.build()?;
    ctx.gfx.supported_resolutions();
    Ok(())
}

Cargo run output:

Running `target/debug/bug-report`
Failed to initialize graphics, trying secondary backends.. Please mention this if you encounter any bugs!
thread 'main' panicked at /home/philipp/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ggez-0.9.3/src/graphics/context.rs:566:14:
called `Option::unwrap()` on a `None` value

Hardware and Software:

  • ggez version: "0.9.3"
  • OS: Arch Linux
  • Graphics card: Intel Corporation TigerLake-LP GT2 [Iris Xe Graphics] (rev 01)
  • Graphics card drivers: 4.6 (Compatibility Profile) Mesa 23.3.1-arch1.1
  • WM: sway version 1.8.1
  • Wayland version: 1.22.0-1

UPD
This seems to be a xinit issue:
When calling window.current_monitor() I get None, but as weird as it is, when calling window.available_monitors() I get my monitor and can check the resolution.

use ggez::{event, Context, GameResult};

fn main() -> GameResult {
    let window_mode = ggez::conf::WindowMode::default()
        .resizable(true)
        .dimensions(1024.0, 1024.0);

    let cb = ggez::ContextBuilder::new("Invoke", "Popov Philipp").window_mode(window_mode);
    let (mut ctx, event_loop) = cb.build()?;

    if let Some(_monitor) = ctx.gfx.window().current_monitor() {
        println!("I have a monitor!");
    } else {
        println!("There is no monitor...");
    }

    for monitor in ctx.gfx.window().available_monitors() {
        for mode in monitor.video_modes() {
            println!("{:?}", mode);
        }
    }

    Ok(())
}

Cargo run output:

Failed to initialize graphics, trying secondary backends.. Please mention this if you encounter any bugs!
There is no monitor...
Wayland(VideoMode { size: PhysicalSize { width: 3840, height: 2160 }, bit_depth: 32, refresh_rate_millihertz: 59997, monitor: MonitorHandle { proxy: wl_output@14 } })

I guess the only thing that can be done here is to handle the None value when calling window.available_monitors() instead of unwrapping.

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

No branches or pull requests

1 participant