NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.33k stars 13.57k forks source link

NixOS: qt + glx broken / segfault / "Could not initialize GLX" #85866

Open rkoe opened 4 years ago

rkoe commented 4 years ago

Describe the bug It seems that all Qt-programs, using GLX are currently broken and cause a segfault:

$ designer 
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (8 8 8 0)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (1 8 8 0)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (1 1 8 0)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (1 1 1 0)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (1 1 1 0)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (8 8 8 0)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (1 8 8 0)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (1 1 8 0)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (1 1 1 0)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig (1 1 1 0)
Could not initialize GLX
Aborted (core dumped)

(I guess this occurs since 20.03 since some programs worked before, but I'm not completely sure.)

This may be related to #82959 but I'm not sure and since GL with Nix-packages on non-NixOS is quite different, I'm opening a new, NixOS-related bug.

To Reproduce

  1. use NixOS 20.03
  2. install any Qt-program which uses GLX, e.g. openscad or qt-designer (qt5.qttools)
  3. try to start the program, e.g. openscad or designer

Expected behavior Working program without segfault.

Metadata

mmilata commented 4 years ago

This may be related to #85865, but I'm not sure and since GL with Nix-packages on non-NixOS is quite different, I'm opening a new, NixOS-related bug.

Wrong issue number?:)

Also, I'm running 20.03 and tried openscad both from 20.03 as well as unstable channel and it does not segfault. I've got AMD GPU if that matters.

rkoe commented 4 years ago

Wrong issue number?:)

Thanks, I've fixed the number.

Also, I'm running 20.03 and tried openscad both from 20.03 as well as unstable channel and it does not segfault. I've got AMD GPU if that matters.

I guess that it's related to the graphics driver or some opengl packages/-configuration. But I don't know which -- and it worked before the update.

rkoe commented 4 years ago

After nix-env -u --always, OpenSCAD works again. But the Qt designer is still broken. :(

markuskowa commented 4 years ago

I am having the same problem with NixOS 20.03 (KDE desktop, trying to run nextcloud client). The problem can also be reproduced by just running glxinfo.

rollf commented 4 years ago

I have the same on OpenSuse with nixpkgs.

$ nix-shell -p nextcloud-client

[nix-shell:~]$ nextcloud
qt.glx: qglx_findConfig: Failed to finding matching FBConfig for QSurfaceFormat(version 2.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize -1, redBufferSize 1, greenBufferSize 1, blueBufferSize 1, alphaBufferSize -1, stencilBufferSize -1, samples -1, swapBehavior QSurfaceFormat::SingleBuffer, swapInterval 1, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::NoProfile)
qt.glx: qglx_findConfig: Failed to finding matching FBConfig for QSurfaceFormat(version 2.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize -1, redBufferSize 1, greenBufferSize 1, blueBufferSize 1, alphaBufferSize -1, stencilBufferSize -1, samples -1, swapBehavior QSurfaceFormat::SingleBuffer, swapInterval 1, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::NoProfile)
Could not initialize GLX
Aborted (core dumped)

[nix-shell:~]$ nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
"20.09pre221814.10100a97c89"

[nix-shell:~]$ glxinfo | head # runs just fine
name of display: :0
display: :0  screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
    GLX_ARB_context_flush_control, GLX_ARB_create_context, 
    GLX_ARB_create_context_no_error, GLX_ARB_create_context_profile, 
    GLX_ARB_fbconfig_float, GLX_ARB_framebuffer_sRGB, GLX_ARB_multisample, 
    GLX_EXT_create_context_es2_profile, GLX_EXT_create_context_es_profile,
bobismijnnaam commented 4 years ago

I'm also having problems that are related to this, I think. In particular, a program that uses Qt (mcrl2) gives the following errors (I include only two lines, but the first line in my snippet is repeated several times in the output):

qt.glx: qglx_findConfig: Failed to finding matching FBConfig for QSurfaceFormat(version 3.3, options QFlags<QSurfaceFormat::FormatOption>(DebugContext), depthBufferSize -1, redBufferSize 1, greenBufferSize 1, blueBufferSize 1, alphaBufferSize 0, stencilBufferSize 0, samples 1, swapBehavior QSurfaceFormat::SingleBuffer, swapInterval 1, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::CoreProfile)
No XVisualInfo for format QSurfaceFormat(version 3.3, options QFlags<QSurfaceFormat::FormatOption>(DebugContext), depthBufferSize -1, redBufferSize 1, greenBufferSize 1, blueBufferSize 1, alphaBufferSize 0, stencilBufferSize 0, samples 1, swapBehavior QSurfaceFormat::SingleBuffer, swapInterval 1, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::CoreProfile)

glxinfo also seems not to work:

$ nix-shell -p pkgs.glxinfo --run glxinfo
name of display: :1
Error: couldn't find RGB GLX visual or fbconfig

nixGLNvidia also does not resolve it for mcrl2 or glxinfo either:

$ nixGLNvidia $(nix run nixpkgs.glxinfo -c glxinfo)
Error: couldn't find RGB GLX visual or fbconfig
/home/bobe/.nix-profile/bin/nixGLNvidia: line 6: name: command not found

(mcrl2 prints nothing when used with nixGLNvidia, I think nixGLNvidia just hides the errors in that case. I also refactored the mcrl2 derivation to use wrapQtAppsHook, but the errors are still there and the application doesn't do any drawing.)

I want to add that glxinfo works fine if I install it through apt. I'm on Ubuntu 20.04. Is Qt/GL not supported by nix on Ubuntu, or is this a bug?

StephenWithPH commented 4 years ago

I was having vaguely similar problems. I found a solution that worked for me on a different issue:

https://github.com/NixOS/nixpkgs/issues/82959#issuecomment-657306112

bobismijnnaam commented 3 years ago

Thank you for the suggesting. Adding export changes the warning to:

QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed

At least the application starts now (ltsgraph), but it doesn't display anything (i.e. it just shows whatever was on that part of the screen before the application started).

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

fricklerhandwerk commented 3 years ago

This is still relevant. I have the same problem on Ubuntu 20.04 with https://github.com/lopsided98/nix-ros-overlay when building ROS environment that contains rviz, with nixpkgs 20.09:

$ nix-shell
# to get rid of error
# qt.glx: qglx_findConfig: Failed to finding matching FBConfig...
$ export QT_XCB_GL_INTEGRATION=none 
$ rosrun rviz rviz
# ...
[  INFO]: rviz version 1.13.16
[  INFO]: compiled against Qt version 5.15.2
[  INFO]: compiled against OGRE version 1.9.0 (Ghadamon)
[  INFO]: Forcing OpenGL version 0.
Segmentation fault
mikepurvis commented 2 years ago

We're also seeing what looks like this with @lopsided98's Gazebo 11 derivation on Ubuntu 20.04.

Disregard, it turned out to be something related to automatic executable wrapping instead! The GL-related warnings were a red herring and because I was doing some of the testing on a headless machine.

iwanders commented 2 years ago

Just to follow up on @mikepurvis 's comment. We solved our issues by properly wrapping the Qt applications with wrapQtAppsHook. To resolve the segmentation faults when the OpenGL context is being created we are using nixGL. These segmentation faults seem to be only a problem on non-NixOS systems, where the binaries from the nix store don't have access to the libraries installed by the graphics card drivers of the operating system (in our case the libs installed by the Nvidia driver).

exarkun commented 2 years ago

Just confirming that this is still broken as of 21.11.334934.8a053bc2255:

$ nix-shell -p openscad --run openscad
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
QOpenGLWidget: Failed to create context
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
QOpenGLWidget: Failed to create context
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: QOpenGLContext creation failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
qt.qpa.backingstore: composeAndFlush: makeCurrent() failed
QXcbIntegration: Cannot create platform offscreen surface, neither GLX nor EGL are enabled
/tmp/nix-shell-146113-0/rc: line 1: 146144 Segmentation fault      (core dumped) openscad
exarkun commented 2 years ago

Since this can be reproduced with glxinfo, which is not a Qt application, it seems like this probably has nothing to do with Qt. Instead, these Qt errors are just how Qt fails when the display server doesn't support OpenGL.

The real question becomes: Why doesn't the display server support OpenGL? Answer that and fix the config and these Qt programs will probably work.

exarkun commented 2 years ago

In my case, I switched from the "nvidia" driver to the "amdgpu" driver (the system has both video cards in it) and both glxinfo and openscad are working fine now.

I don't know why glx support is missing when using the "nvidia" driver. The web is littered with posts from people trying to solve that kind of issue on linux so I imagine there are a ton of possible misconfigurations that result in the situation.

Rots commented 1 month ago

also a problem on WSL