HactarCE/Hyperspeedcube

Crash on startup "unable to request graphics adapter"

Wheatwizard opened this issue · 5 comments

I've been trying to compile the program for nixos. After resolving the missing dependencies the compiled program crashes on startup.

Full log:

name = 'Hyperspeedcube'
operating_system = 'unix:NixOS'
crate_version = '1.0.5'
explanation = '''
Panic occurred in file 'src/render/state.rs' at line 198
'''
cause = 'unable to request graphics adapter'
method = 'Panic'
backtrace = '''

   0: 0x55954c71f452 - pollster::block_on::he08d1f98fc029209
   1: 0x55954c55e450 - hyperspeedcube::main::h8986dc330c20691a
   2: 0x55954c708503 - std::sys_common::backtrace::__rust_begin_short_backtrace::h654e4e32b09662ea
   3: 0x55954c6ba789 - std::rt::lang_start::{{closure}}::h9fb173e7cce2a6b5
   4: 0x55954d0225b8 - std::rt::lang_start_internal::h34bd518f25d68bbe
   5: 0x55954c55f275 - main
   6: 0x7f0bcb408ace - __libc_start_call_main
   7: 0x7f0bcb408b89 - __libc_start_main@@GLIBC_2.34
   8: 0x55954c4c4e05 - _start
   9:        0x0 - <unresolved>'''

I created a reproducible build using nix, which I ran on three different machines:

{ pkgs ?
  import (builtins.fetchGit {
    name = "nixpkgs-unstable-2021-07-19";
    url = "https://github.com/nixos/nixpkgs/";
    ref = "refs/heads/release-23.05";
    rev = "1e409aeb5a9798a36e1cca227b7f8b8f3176e04d";
  })
  {}
}:

pkgs.stdenv.mkDerivation rec {
  pname = "hyper-speed-cube";
  version = "0.1.0";
  src = ./.;
  buildInputs =
    [ pkgs.cargo
      pkgs.gcc
      pkgs.cmake
      pkgs.pkg-config
      pkgs.glib
      pkgs.fontconfig
      pkgs.atkmm
      pkgs.gtk3
      pkgs.python3
      pkgs.libxkbcommon
    ];
  buildPhase = ''
    cargo clean
    cargo build --release
  '';
}

All three machines produce this error when compiling with the above nix file. All three machines run nixos. I tried using clang instead of gcc to no effect but didn't fiddle around with the specific versions of anything of the other dependencies.

If you have nix you can use nix-build with the above to reproduce the build.

mmai commented

Hi @Wheatwizard . If it can be of any help, I managed to compile and execute the program with devenv using the following devenv.nix :

{ pkgs, ... }:

{
  # https://devenv.sh/packages/
  packages = [
    # for compilation errors
    pkgs.cmake
    pkgs.fontconfig
    pkgs.harfbuzz
    pkgs.freetype
    pkgs.expat
    pkgs.glib
    pkgs.atk 
    pkgs.gtk3 
    pkgs.pango
    pkgs.cairo
    pkgs.gdk-pixbuf 
    pkgs.zlib
    pkgs.xorg.libxcb

    # for execution errors (see https://github.com/emilk/egui/discussions/1587)
    pkgs.libxkbcommon
    pkgs.libGL

    # WINIT_UNIX_BACKEND=wayland
    pkgs.wayland

    # WINIT_UNIX_BACKEND=x11
    pkgs.xorg.libXcursor
    pkgs.xorg.libXrandr
    pkgs.xorg.libXi
    pkgs.xorg.libX11

    pkgs.vulkan-headers pkgs.vulkan-loader
  ];

  enterShell = ''
  cargo run --release
  '';

  # https://devenv.sh/languages/
  languages.rust.enable = true;

}

Sorry for the delay. Your nix file works for me, and copying the missing packages into my nix file also fixes the issue. Thank you.

Thanks for figuring this out @Wheatwizard and @mmai! Is there anything I should do as a developer to make sure this works well in the future?

7f32f36 is already a good step in the right direction, although it seems it is still missing some deps. Using something like nix to create dependable builds would be an ideal solution, but if your team doesn't already use nix it's probably not worth it to switch.

Yeah I'm the only developer and I use macOS right now. Hopefully the extra build step will help in the future. Thanks!