rust-windowing/glutin

glutin-winit: `DisplayBuilder`'s `build` method fails on NixOS

4JX opened this issue ยท 5 comments

4JX commented

Don't have much idea of the inner workings of glutin as I use it by proxy in egui so bear with me

I'm currently using egui with the glow backend which early-exits here due to an error caused when building a Window via glutin_winit here (error definition)

Test run with the issue being present
L5P-Keyboard-RGB on ๎‚  main [$!] via ๐Ÿฆ€ v1.73.0 via โ„๏ธ  impure (legion-kb-rgb-0.19.4-env) 
ยป RUST_LOG=trace RUST_BACKTRACE=full nix run .                      
warning: Git tree '/home/infinity/Documents/GitHub/L5P-Keyboard-RGB' is dirty
No subcommands found, starting in GUI mode. To view the possible subcommands type "legion-kb-rgb --help".
[2023-12-08T23:53:14Z DEBUG eframe] Using the glow renderer
[2023-12-08T23:53:14Z TRACE mio::poll] registering event source with poller: token=Token(0), interests=READABLE
[2023-12-08T23:53:14Z DEBUG eframe::native::run] Entering the winit event loop (run_return)โ€ฆ
[2023-12-08T23:53:14Z DEBUG eframe::native::glow_integration] trying to create glutin Display with config: ConfigTemplateBuilder { template: ConfigTemplate { color_buffer_type: Rgb { r_size: 8, g_size: 8, b_size: 8 }, alpha_size: 8, depth_size: 0, stencil_size: 0, num_samples: None, min_swap_interval: None, max_swap_interval: None, config_surface_types: WINDOW, api: None, transparency: false, single_buffering: false, stereoscopy: None, float_pixels: false, max_pbuffer_width: None, hardware_accelerated: None, max_pbuffer_height: None, native_window: None } }
[2023-12-08T23:53:14Z ERROR eframe::native::run] Exiting because of error: Found no glutin configs matching the template: ConfigTemplate { color_buffer_type: Rgb { r_size: 8, g_size: 8, b_size: 8 }, alpha_size: 8, depth_size: 0, stencil_size: 0, num_samples: None, min_swap_interval: None, max_swap_interval: None, config_surface_types: WINDOW, api: None, transparency: false, single_buffering: false, stereoscopy: None, float_pixels: false, max_pbuffer_width: None, hardware_accelerated: None, max_pbuffer_height: None, native_window: None }. Error: Error { raw_code: None, raw_os_message: None, kind: BadConfig } during event Resumed
[2023-12-08T23:53:14Z DEBUG eframe::native::run] Asking to exit event loopโ€ฆ
[2023-12-08T23:53:14Z DEBUG eframe::native::run] Received Event::LoopDestroyed - saving app stateโ€ฆ
[2023-12-08T23:53:14Z DEBUG eframe::native::run] eframe window closed
The application panicked (crashed).
Message:  called `Result::unwrap()` on an `Err` value: NoGlutinConfigs(ConfigTemplate { color_buffer_type: Rgb { r_size: 8, g_size: 8, b_size: 8 }, alpha_size: 8, depth_size: 0, stencil_size: 0, num_samples: None, min_swap_interval: None, max_swap_interval: None, config_surface_types: WINDOW, api: None, transparency: false, single_buffering: false, stereoscopy: None, float_pixels: false, max_pbuffer_width: None, hardware_accelerated: None, max_pbuffer_height: None, native_window: None }, Error { raw_code: None, raw_os_message: None, kind: BadConfig })
Location: app/src/main.rs:102

  โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” BACKTRACE โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
                                โ‹ฎ 8 frames hidden โ‹ฎ                               
   9: legion_kb_rgb::main::h481bdb5a66d029a2
      at <unknown source file>:<unknown line>
  10: std::sys_common::backtrace::__rust_begin_short_backtrace::h9ce7f2825e7f4390
      at <unknown source file>:<unknown line>
  11: std::rt::lang_start::{{closure}}::hf44d85b012dcf313
      at <unknown source file>:<unknown line>
  12: std::rt::lang_start_internal::hc0b4e50f058f62ce
      at <unknown source file>:<unknown line>
  13: main<unknown>
      at <unknown source file>:<unknown line>
  14: __libc_start_call_main<unknown>
      at <unknown source file>:<unknown line>
  15: __libc_start_main@@GLIBC_2.34<unknown>
      at <unknown source file>:<unknown line>
  16: _start<unknown>
      at <unknown source file>:<unknown line>

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.

Other related issues are:
emilk/egui#3516
NixOS/nixpkgs#271793

This error seems to be independent of eframe's version as my app originally worked just fine in 0.23 before I adapted it to 0.24 to try to see if it would fix the issue which is why I believe this is glutin specific. The issue is also independent of using X11/Wayland, tested both under GNOME.

NixOS is quite special in how it handles program installs, dependencies and whatnot so it's probably to blame, but I would like to know if there's some pointers I could follow about what could be wrong. A first guess would be that it's not finding something it expects to just kind of be available since NixOS packaged programs are pretty isolated from the rest of the system and eachother (everything is basically self contained with it's own definition for dependencies and co.), and the location of the available stuff can change.

For anyone else hunting this down, it seems to be caused by a regression somewhere in the October set of commits to the unstable branch (time between my last flake update before I did a working release and the first issue)

It seems it just can't find a suitable config? I don't see what glutin should do about it, it's all on the app to handle fallback? Does example in glutin works?

4JX commented

It seems it just can't find a suitable config? I don't see what glutin should do about it, it's all on the app to handle fallback? Does example in glutin works?

I assume you mean running cargo run --example window

No the example does not work, I need to pull a few dependencies for it to start up "normally" but even then it errors out with Error: Error { raw_code: None, raw_os_message: None, kind: NotFound }

it's expected that you install dependencies though. NixOS can't even run anything OpenGL without special wrappers.

4JX commented

The dependencies part I know is expected, but what I am lost is as to where the breakage occurs for the NotFound/BadConfig errors.

4JX commented

Finally fixed it, dependency version mismatch between the build and system versions (or so I assume since it runs now that I updated the flake that builds it).