Bambu-studio appimage gives GLib-GObject-CRITICAL **: 16:47:37.245: invalid (NULL) pointer instance

I am trying to make my own bambu-studio package based on their provided AppImage, and I have the code in bambu.nix below:

{
  pkgs, lib, fetchurl, appimageTools
  ? import <nixpkgs> {}
}:
let
  pname = "bambu";
  version = lib.readFile /etc/nixos/bambu/version;
  fullname = lib.readFile /etc/nixos/bambu/fullname;
  src = fetchurl {
    url = "https://github.com/bambulab/BambuStudio/releases/download/v${version}/BambuStudio_ubu24-${fullname}.AppImage";
    sha256 = "Zo2rsb5Tx1gYnta8iZNShd6l4K9GIWVGsbr9aILpr/A=";
  };
  appimageContents = appimageTools.extract {
    inherit pname version src;
  };
in
appimageTools.wrapType2 rec {
  inherit pname version src;
  extraPkgs = pkgs: with pkgs; [
    assimp
    bash
    boost183
    cacert
    cairo
    cereal
    cgal_5
    curl
    dbus
    eigen
    expat
    ffmpeg
    fontconfig
    gccNGPackages.libstdcxx
    gdk-pixbuf
    glew
    glfw
    glib
    glibc
    glib-networking
    gmp
    gst_all_1.gstreamer
    gst_all_1.gst-plugins-base
    gst_all_1.gst-plugins-bad
    gst_all_1.gst-plugins-good
    gtk3
    hicolor-icon-theme
    libdrm
    libgcc
    libglvnd
    libpng
    libsecret
    libnoise
    mpfr
    nlopt
    opencascade-occt_7_6
    openexr
    openvdb
    onetbb
    pango
    python316
    systemdLibs
    wayland
    webkitgtk_4_1
    wxwidgets_3_1
    wxwidgets_3_2
    wxwidgets_3_3
    libx11
    libharu
    opencv
  ];
  profile = ''
    export SSL_CERT_FILE="${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
    export GIO_MODULE_DIR="${pkgs.glib-networking}/lib/gio/modules/"
  '';
}

The package compiles fine, however, when running the program, this error is produced:

$ /etc/profiles/per-user/cube/bin/bambu 

(process:20480): GLib-GObject-CRITICAL **: 17:01:44.729: invalid (NULL) pointer instance

(process:20480): GLib-GObject-CRITICAL **: 17:01:44.730: g_signal_handlers_disconnect_matched: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed

This happens with or without profile set in the nix file. I suspect the problem is in some libraries to display the window, since bambu --help in the command line works completely fine. I have looked at reports with similar problems, but I do not even have a .config or .cache or .var BambuStudio folder to delete. Bambu Studio Flatpak -> after Linux updates -> GLib-GObject-Critical - #6 by Melbo0 - Bambu Studio - Bambu Lab Community Forum

I have tried with appimage-run on the original AppImage, with the same error. I have also tested the same program version with arch linux, and it ran fine there, so I do not think it is an issue with the AppImage itself. appimage-run itself seems to have no problem running another appimage I happened to have, osu.AppImage. I am happy to test other appimages with similar dependencies as bambu-studio if you need any more information.

I managed to find this by running LD_DEBUG=libs bambu 2> testfile; grep 'libglib' testfile:

 32732:	find library=libglib-2.0.so.0 [0]; searching
 32732:	  trying file=/nix/store/gin29ra01zw7prjiksjb35zbjw8dsm30-bambu-02.09.01.70-extracted/bin/libglib-2.0.so.0
 32732:	  trying file=glibc-hwcaps/x86-64-v4/libglib-2.0.so.0
 32732:	  trying file=glibc-hwcaps/x86-64-v3/libglib-2.0.so.0
 32732:	  trying file=glibc-hwcaps/x86-64-v2/libglib-2.0.so.0
 32732:	  trying file=libglib-2.0.so.0
 32732:	  trying file=/lib/libglib-2.0.so.0
 32732:	 search path=/nix/store/p5dwcn4wpyjmhnnzj6iwwwjynyc6yif0-pcre2-10.49/lib/glibc-hwcaps/x86-64-v4:/nix/store/p5dwcn4wpyjmhnnzj6iwwwjynyc6yif0-pcre2-10.49/lib/glibc-hwcaps/x86-64-v3:/nix/store/p5dwcn4wpyjmhnnzj6iwwwjynyc6yif0-pcre2-10.49/lib/glibc-hwcaps/x86-64-v2:/nix/store/p5dwcn4wpyjmhnnzj6iwwwjynyc6yif0-pcre2-10.49/lib		(RUNPATH from file /lib/libglib-2.0.so.0)
 32732:	calling init: /lib/libglib-2.0.so.0
 32732:	calling fini: /lib/libglib-2.0.so.0 [0]
ldd /nix/store/gin29ra01zw7prjiksjb35zbjw8dsm30-bambu-02.09.01.70-extracted/bin/bambu-studio

also shows:

linux-vdso.so.1 (0x000076fb020cb000)
libstdc++.so.6 => not found
libfontconfig.so.1 => not found
libGL.so.1 => not found
libm.so.6 => /nix/store/pqyiidz5mi73wv5f91d48s9plcqyj5bz-glibc-2.44-57/lib/libm.so.6 (0x000076fafa2df000)
libavcodec.so.61 => not found
libswscale.so.8 => not found
libavutil.so.59 => not found
libgtk-3.so.0 => not found
libgdk-3.so.0 => not found
libpangocairo-1.0.so.0 => not found
libpango-1.0.so.0 => not found
libcairo.so.2 => not found
libgdk_pixbuf-2.0.so.0 => not found
libgio-2.0.so.0 => not found
libgobject-2.0.so.0 => not found
libglib-2.0.so.0 => not found
libX11.so.6 => not found
libgstreamer-1.0.so.0 => not found
libgstvideo-1.0.so.0 => not found
libwebkit2gtk-4.1.so.0 => not found
libjavascriptcoregtk-4.1.so.0 => not found
libpangoft2-1.0.so.0 => not found
libdbus-1.so.3 => not found
libwayland-server.so.0 => not found
libgstbase-1.0.so.0 => not found
libc.so.6 => /nix/store/pqyiidz5mi73wv5f91d48s9plcqyj5bz-glibc-2.44-57/lib/libc.so.6 (0x000076fafa000000)
/lib64/ld-linux-x86-64.so.2 => /nix/store/pqyiidz5mi73wv5f91d48s9plcqyj5bz-glibc-2.44-57/lib64/ld-linux-x86-64.so.2 (0x000076fb020cd000)
libwayland-client.so.0 => not found
libgcc_s.so.1 => /nix/store/pkkjnyk4z46n18fkyqwlg24p272apb69-xgcc-16.2.0-libgcc/lib/libgcc_s.so.1 (0x000076fb0208b000)

not sure why it says not found… it also seems like the packages installed by extraPkgs are all marked as ‘not found’.

the output also produces fatal errors:

     32453:	/nix/store/cgzr5afjdbx30j7g44z2h92i8h3828k2-systemd-minimal-libs-262/lib/libudev.so.1: error: symbol lookup error: undefined symbol: keyctl (fatal)
     32453:	/nix/store/cgzr5afjdbx30j7g44z2h92i8h3828k2-systemd-minimal-libs-262/lib/libudev.so.1: error: symbol lookup error: undefined symbol: add_key (fatal)
     32453:	/nix/store/cgzr5afjdbx30j7g44z2h92i8h3828k2-systemd-minimal-libs-262/lib/libudev.so.1: error: symbol lookup error: undefined symbol: request_key (fatal)
     32453:	/nix/store/cgzr5afjdbx30j7g44z2h92i8h3828k2-systemd-minimal-libs-262/lib/libudev.so.1: error: symbol lookup error: undefined symbol: kcmp (fatal)
     32453:	/nix/store/cgzr5afjdbx30j7g44z2h92i8h3828k2-systemd-minimal-libs-262/lib/libudev.so.1: error: symbol lookup error: undefined symbol: open_tree_attr (fatal)
     32453:	/nix/store/cgzr5afjdbx30j7g44z2h92i8h3828k2-systemd-minimal-libs-262/lib/libudev.so.1: error: symbol lookup error: undefined symbol: rt_tgsigqueueinfo (fatal)
     32453:	/nix/store/cgzr5afjdbx30j7g44z2h92i8h3828k2-systemd-minimal-libs-262/lib/libudev.so.1: error: symbol lookup error: undefined symbol: fchmodat2 (fatal)
     32453:	/nix/store/cgzr5afjdbx30j7g44z2h92i8h3828k2-systemd-minimal-libs-262/lib/libudev.so.1: error: symbol lookup error: undefined symbol: setxattrat (fatal)
     32453:	/nix/store/cgzr5afjdbx30j7g44z2h92i8h3828k2-systemd-minimal-libs-262/lib/libudev.so.1: error: symbol lookup error: undefined symbol: removexattrat (fatal)

and further down, closest to the GLib-GObject-CRITICAL error:

    32712:	/nix/store/gin29ra01zw7prjiksjb35zbjw8dsm30-bambu-02.09.01.70-extracted/bin/bambu-studio: error: symbol lookup error: undefined symbol: soup_uri_new (fatal)

not sure if this is relevant.