nvidia drivers cannot be used by snaps in x11 mode

Bug #2088456 reported by Zygmunt Krynicki
126
This bug affects 24 people
Affects Status Importance Assigned to Milestone
snapd
Fix Committed
Undecided
Alessandro Astone

Bug Description

Running Ubuntu 24.10 (Oracular) with Nvidia 560 driver, manually switched to X11 mode on login, shows errors in some applications using the opengl API. Notably this is visible in:

desktop-security-center snap:

zyga@novigrad:~/Canonical/snapd$ desktop-security-center
Gtk-Message: 14:31:52.957: Not loading module "atk-bridge": The functionality is provided by GTK natively. Please try to not load it.

(security_center:185950): Gtk-WARNING **: 14:31:53.017: GTK+ module /snap/desktop-security-center/32/gnome-platform/usr/lib/gtk-2.0/modules/libcanberra-gtk-module.so cannot be loaded.
GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported.
Gtk-Message: 14:31:53.017: Failed to load module "canberra-gtk-module"

(security_center:185950): Gtk-WARNING **: 14:31:53.017: GTK+ module /snap/desktop-security-center/32/gnome-platform/usr/lib/gtk-2.0/modules/libcanberra-gtk-module.so cannot be loaded.
GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported.
Gtk-Message: 14:31:53.017: Failed to load module "canberra-gtk-module"

(security_center:185950): Gdk-CRITICAL **: 14:31:53.058: gdk_gl_context_make_current: assertion 'GDK_IS_GL_CONTEXT (context)' failed

** (security_center:185950): WARNING **: 14:31:53.058: Failed to initialize GLArea: Nie można utworzyć kontekstu GL

^ That last message is about failure to create a GL context.

Eager to see if this affects non-snap applications I've installed gtk-4-examples, ran the gtk4-demo program and switched to shadertoy example and click run. A similar message appears and the demo is not functional.

ProblemType: Bug
DistroRelease: Ubuntu 24.10
Package: nvidia-driver-560 560.35.03-0ubuntu5
ProcVersionSignature: Ubuntu 6.11.0-9.9-generic 6.11.0
Uname: Linux 6.11.0-9-generic x86_64
NonfreeKernelModules: zfs nvidia_modeset nvidia
ApportVersion: 2.30.0-0ubuntu4
Architecture: amd64
CasperMD5CheckResult: pass
CurrentDesktop: ubuntu:GNOME
Date: Mon Nov 18 14:29:53 2024
InstallationDate: Installed on 2023-12-02 (352 days ago)
InstallationMedia: Ubuntu 23.10.1 "Mantic Minotaur" - Release amd64 (20231016.1)
ProcEnviron:
 LANG=pl_PL.UTF-8
 PATH=(custom, no user)
 SHELL=/bin/bash
 TERM=xterm-256color
 XDG_RUNTIME_DIR=<set>
SourcePackage: nvidia-graphics-drivers-560
UpgradeStatus: Upgraded to oracular on 2024-10-16 (33 days ago)

Revision history for this message
Zygmunt Krynicki (zyga) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in nvidia-graphics-drivers-560 (Ubuntu):
status: New → Confirmed
Revision history for this message
AndreK (andre-k) wrote :

not only affects me too, but this screen is stuck like this for over a minute every time it is opened (see ecreenshot)
which may, or may not be related.

Revision history for this message
AndreK (andre-k) wrote :

And this bug affects firmware-updater too.

Revision history for this message
P. De Luna (codingkoala) wrote :

And this bug affects snap-store too.

Revision history for this message
P. De Luna (codingkoala) wrote :

as for the snap-store seems like the snap comes with some gtk 2.0 modules packed and they are being loaded after gtk 3.0 is already in use and this results in failure of loading any gtk 2.0 lib ... so I guess all packages like : snap-store , firmware-updater, desktop-security-center , etc. need to be repacked with gtk 3.0 libs

Revision history for this message
regs (coth-is) wrote (last edit ):

This is not limited to 560. Also happening with 565 and 550. And because of this WebGL and hardware acceleration do not work in browsers, making them very slow.

Revision history for this message
P. De Luna (codingkoala) wrote :

actually WebGL and HW acc. issue is limited to Firefox probably having the same 2.0 libs packed in snap, Chrome is working correctly so this is not a nvidia drivers version issue but as already found a wrong gtk modules version packed into snap files, must upgrade all system snap files to gtk 3.0 to fix them all.

P. De Luna (codingkoala)
affects: nvidia-graphics-drivers-560 (Ubuntu) → snap (Ubuntu)
Revision history for this message
regs (regs-pochta) wrote :

@P. De Luna (codingkoala)
WebGL doesn't work in PPA version of Firefox as well.

Revision history for this message
Misbach (misbach) wrote :

Is there a workaround until this gets fixed?

Revision history for this message
Giovanni Claudio (jokla) wrote :

I upgraded the NVIDIA driver to version 565.77 on Ubuntu 24.10, but the issue persists.

Revision history for this message
Alistair Buxton (a-j-buxton) wrote :

The following software works fine:

Blender (classic snap)
Steam games (snap - but provides its own runtime for games)
openscad-nightly (appimage)
gtk3-demo glarea example (apt)

The following software does not:

Firefox (snap)
openscad-nightly (snap)
gtk-3-demo glarea example (snap)

The commonality here is clear: snaps fail only if they are not classic and do not provide their own runtime. Anything unconfined works fine, regardless of how it was installed.

The issue where gtk-4-demo shadertoy example fails is likely unrelated: the other two GL examples (one of which is the same glarea example from gtk3) from that demo work fine when it is installed from apt.

Revision history for this message
Alistair Buxton (a-j-buxton) wrote :

Change package to snapd since that is where this type of bug is supposed to be reported

affects: snap (Ubuntu) → snapd (Ubuntu)
Revision history for this message
Alistair Buxton (a-j-buxton) wrote :

Actually we want the project, not the package.

affects: snapd (Ubuntu) → snapd
Revision history for this message
Alistair Buxton (a-j-buxton) wrote :

The gtk4 shadertoy demo can be made to work (outside snap) by running it like this:

    GDK_DEBUG=gl-prefer-gl gtk4-demo

This debug flag tells Gtk to avoid using GLES.

Revision history for this message
Alistair Buxton (a-j-buxton) wrote :

The shadertoy demo does not work because of this piece of code:

    gtk_shadertoy_new (void)
    {
      return g_object_new (gtk_shadertoy_get_type (),
                           "allowed-apis", GDK_GL_API_GL,
                           NULL);
    }

https://gitlab.gnome.org/GNOME/gtk/-/blob/main/demos/gtk-demo/gtkshadertoy.c?ref_type=heads#L120

This sets the "allowed-apis" to GL (as opposed to GLES, the Gtk4 default).

The problem is that changing the GL context type like this in the middle of a program is known to not work with at least some versions of the Nvidia driver. To quote ebassi:

"older versions of the closed source nVidia binary driver—do not allow mixing GL and GLES"

https://discourse.gnome.org/t/how-to-request-the-opengl-core-profile/20907/2

This would seem to imply that newer drivers do allow it, so I asked for clarification, and he responded:

"It's impossible to answer, because we don't know how the nvidia binary driver works, or what it supports"

So I take this to mean that there is no known version of the Nvidia driver where this works, and he said "older" because he has only tried it on older versions, none of which worked.

And indeed, I tested the shadertoy example on 24.04 with the 535 driver, and it failed in exactly the same way, despite GL acceleration working fine inside snaps there. I suspect the shadertoy has never worked on Nvidia.

So tl;dr we can definitely 100% exclude the shadertoy failure from this bug. It is an entirely different bug.

Revision history for this message
Yotam Benshalom (benshalom) wrote :

This issue prevents me from running app-center and security center (I get blank windows with the message "Unable to create a GL context"), and is probably the reason why all gtk4 apps started loading extremely slowly after I upgraded to plucky.
I use nvidia driver 565.77 on xorg.

Revision history for this message
Alistair Buxton (a-j-buxton) wrote :

So now I am investigating the problem in snap containers. As I wrote on the snapcraft forum, Firefox has a helper tool that checks the OpenGL environment. Under 24.04 and Nvidia 535, this tools produces identical output inside and outside the container. Under 24.10 and 560 it works outside the contain but fails inside it.

This program is not exposed as a command you can run with "snap run" so it is difficult to strace it with "snap run --strace". However there is another snap with similar functionality called "graphics-test-tools". This includes a copy of glxinfo, which similary works outside the container:

al@al-desktop:~$ /snap/graphics-test-tools/current/usr/bin/glxinfo
name of display: :0.0
display: :0 screen: 0
direct rendering: Yes
server glx vendor string: NVIDIA Corporation
server glx version string: 1.4
...etc

However it does not work when run inside snap:

al@al-desktop:~$ graphics-test-tools.glxinfo
name of display: :0.0
X Error: BadValue
  Request Major code 152 (GLX)
  Request Minor code 24 ()
  Value 0x0
  Error Serial #66
  Current Serial #67

Revision history for this message
Alistair Buxton (a-j-buxton) wrote :

BUT if you run it as a snap on 24.04 / 535 then it does work... just like glxtest.

This snap contains other test tools: eglinfo and vulkaninfo, and both of these appear to work correctly. It is only glxinfo which does not work, which explains why this problem is only happening on X11.

Revision history for this message
Aras Zagros (zeveen) wrote :

I have this issue too, it causes many weird inconveniences, the system starts slow, there is a noticeable lag/delay for some apps such as "Additional Drivers".

May users have reported the same here:

https://askubuntu.com/questions/1530113/nautilus-files-crashes-on-x11-after-upgrade-to-ubuntu-24-10-works-fine-on-way

Revision history for this message
Nico (nnico) wrote (last edit ):

How can we change the settings the security center controls on the command line?

2080 Ti Nvidia drivers here.

This really bothers me, what can we do to get people to look at this? It's probably Nvidia's fault, and they probably do not care.

Pretty much all Flutter apps do not work. I also had other snaps do not work because if this that do not use flutter if I recall correctly.

I also have an issue that I do not know it's related, and I had the same on 22.04 LTS b4 made a fresh new 24.10 installation. My system just refuses to even start in the Wayland session. It's the default now AFAIK, but somehow even a fresh 24.10 installation defaulted to X11. When I log out and manually try to log in to a Wayland session, it simply crashes or something and just silently kicks me back to the login screen again. Not sure if this is related, but I bet it's about those fucking Nvidia drivers again.

So this seems to be an X11 only bug, but I can not even escape it by using Wayland. Was the first try to make it default, not like 8 years ago. How TF is this thing still just not working on the latest Ubuntu version for my system.

I also have other issues like that sometimes I play videos in Brave, the Browser has such severe slowdowns that it needs to be restarted I do not know if this is related, but I think it may have something to do with GPU acceleration and things like that.

How good are the open drivers for Nvidia these days? I boot windows for gaming anyway, but I think it's still very much preferred or needed to use the NV binary drivers, even for simple desktop use with video and things.

summary: - nvidia-560 driver causes issues in x11 mode (desktop-security-center,
- gtk-4-examples)
+ nvidia-560 driver cannot be used by snaps in x11 mode
Changed in snapd:
assignee: nobody → Alessandro Astone (aleasto)
tags: added: udeng-6157
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Re: nvidia-560 driver cannot be used by snaps in x11 mode

Alessandro, if you use Plucky for development here, keep in mind bug 2096642 will get in the way.

Revision history for this message
Piotr Wilkin (ilintar) wrote :

Can confirm this goes back to old drivers as well, tried reinstalling nvidia-535 and it has the same issue. Any workarounds?

Changed in snapd:
status: Confirmed → In Progress
Revision history for this message
Alessandro Astone (aleasto) wrote :
summary: - nvidia-560 driver cannot be used by snaps in x11 mode
+ nvidia drivers cannot be used by snaps in x11 mode
Revision history for this message
Si Dedman (si-dedman) wrote :

Nice work Alé! Do you know how long it usually takes to be merged & released in the next cycle?

Revision history for this message
Ernest Lotter (ernestl) wrote :

Fix included in snapd 2.69

Changed in snapd:
milestone: none → 2.69
status: In Progress → Fix Committed
Revision history for this message
Si Dedman (si-dedman) wrote :

Having upgraded snapd to 2.69 (sudo snap refresh snapd --edge), the snap store now works - yay!

But I'd already swapped snap firefox for deb firefox in the hope that it would solve the issue whereby Zoom won't open from links (https://superuser.com/questions/1343020/how-to-configure-firefox-open-zoom-urls-using-zoom-application; IDK yet if this is solved due to the change, haven't had time to test).

So now I have deb firefox and webgl pages still don't work (e.g. https://mpatlas.org/mpaguide/).

P. De Luna (@codingkoala) suggested: "this is not a nvidia drivers version issue but as already found a wrong gtk modules version packed into snap files, must upgrade all system snap files to gtk 3.0 to fix them all."

Does anyone else have any thoughts about the plausibility of this, either in my scenario or generally? And if it seems viable, is there an advised method for this? Cheers

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.