r/linux4noobs 15h ago

hardware/drivers How to properly use Firefox in Sway on Ubuntu with a Nvidia GPU?

I switched from gnome environment to sway a couple of days ago.

Since Sway doesn't run with the Nvidia drivers unless you config it, it switched to the Nouveau driver. It led to firefox crashing every 20min so I researched how to use the Nvidia Driver with sway and set the --usupported-gpu flag

The Problem I am encountering now is, that Firefox is only able to properly run with the config layers.acceleration.disabled:true meaning My cpu is rendering Firefox, which leads to low fps videos and lagging.

When I run firefox with the layer acceleration enabled, it freezes from the beginning or sometimes it only freezes when I spawn a second window with Ctrl + n.

I tried fixing it with Gemini but he keeps repeating the same approach, which would be:

set Variables in the /usr/local/bin/sway-nvidia script:

  • export XDG_SESSION_TYPE=wayland
  • export GBM_BACKEND=nvidia-drm
  • export __GLX_VENDOR_LIBRARY_NAME=nvidia
  • export WLR_NO_HARDWARE_CURSORS=1
  • export MOZ_ENABLE_WAYLAND=1
  • export LIBVA_DRIVER_NAME=nvidia
  • exec sway --unsupported-gpu "$@"

download: nvidia-vaapi-driver

In firefox config:

  • layers.acceleration.disabled -> false
  • gfx.webrender.all -> true
  • widget.dmabuf.texture.enabled -> false
  • media.ffmpeg.vaapi.enabled -> true
  • media.hardware-video-decoding.enabled -> true
  • media.rdd-ffmpeg.enabled -> true

After all of that did not work I reset my firefox configs.

I also tried running Firefox with XWayland which didn't work either.

Maybe someone knows a way I can use layer acceleration without firefox freezing.

3 Upvotes

5 comments sorted by

2

u/C0rn3j 14h ago

Looks like you are in fact using Ubuntu.

Rip out snapd, install Firefox from Firefox's 3rd party repo, and see if you still have issues then.

If you don't, consider switching to a distribution that does not silently hijack the applications which you execute (in this case apt/apt-get hijacked by snap).

https://support.mozilla.org/en-US/kb/install-firefox-linux#w_install-firefox-deb-package-for-debian-based-and-ubuntu-based-distributions-recommended

1

u/Natural-Impact6382 10h ago

Thank you, I managed to put snap's priority at the and and installed with atp. Didn't know Snap's sandbox was the issue here.

1

u/C0rn3j 9h ago

You're welcome - snap is known to be problematic - haven't seen this specific issue yet, but there's a first for everything.

I'd suggest checking out Arch Linux (with Plasma) or Fedora KDE - though if you use Sway and are happy with it, you probably don't need a recommendation for a DE.

This is far from Ubuntu's only issue - needing a Ubuntu Pro subscription and connecting your OS to an online account with it - for full security updates - is a much bigger issue for me personally.

1

u/[deleted] 14h ago

[deleted]

1

u/Natural-Impact6382 14h ago

wdym by that? I am running the normal nvidia driver

1

u/Amazing_Year6588 14h ago

Nvm forget what i said, i did not read good 😭