How to use GPU offloading with browser (firefox or chromium)?

Hi, folks.
I have laptop with nvidia prime (intel and nvidia cards in pair).
And applications in the browser using webgl are terribly slow (for example, Google maps).
I have installed nvidia drivers but for some reason the browser uses the mesa driver. (Mesa DRI Intel(R) UHD Graphics 620 (Kabylake GT2). I tried to enable gpu offloading with set env variables

__NV_PRIME_RENDER_OFFLOAD=1 \
__GLX_VENDOR_LIBRARY_NAME=nvidia \
firefox 

But it didn’t have any effect - still mesa,
even though it works great with glxgears

__NV_PRIME_RENDER_OFFLOAD=1 \
__GLX_VENDOR_LIBRARY_NAME=nvidia \
glxgears -info | grep  GL_RENDERER

# Output:
> GL_RENDERER = GeForce MX150/PCIe/SSE2

How can I fix the problem with low fps in the browser?
How can I switch to using a NVIDIA driver or at least a Intel driver, not mesa?
Based on which configuration files does Fedora decide what to use for video rendering?

P.S. time for debug info:
OS: Fedora 31 (Workstation Edition) x86_64
Host: HP Spectre x360 Convertible 15-bl1XX
Kernel: 5.5.15-200.fc31.x86_64
DE: GNOME
WM: Mutter
CPU: Intel i7-8550U (8) @ 4.000GHz
GPU1: Intel UHD Graphics 620
GPU2: NVIDIA GeForce MX150

lspci | egrep 'VGA|3D'
00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 620 (rev 07)
01:00.0 3D controller: NVIDIA Corporation GP108M [GeForce MX150] (rev a1)

lsmod | grep nvidia
nvidia_drm             57344  4
nvidia_modeset       1118208  3 nvidia_drm
nvidia_uvm           1097728  0
nvidia              20471808  138 nvidia_uvm,nvidia_modeset
ipmi_msghandler       118784  2 ipmi_devintf,nvidia
drm_kms_helper        233472  2 nvidia_drm,i915
drm                   585728  21 drm_kms_helper,nvidia_drm,i915

lsmod | grep video
uvcvideo              114688  0
videobuf2_vmalloc      20480  1 uvcvideo
videobuf2_memops       20480  1 videobuf2_vmalloc
videobuf2_v4l2         28672  1 uvcvideo
videobuf2_common       57344  2 videobuf2_v4l2,uvcvideo
videodev              266240  3 videobuf2_v4l2,uvcvideo,videobuf2_common
mc                     61440  4 videodev,videobuf2_v4l2,uvcvideo,videobuf2_common
video                  53248  1 i915

glxgears -info | egrep 'GL_RENDERER|GL_VERSION|GL_VENDOR'
GL_RENDERER   = Mesa DRI Intel(R) UHD Graphics 620 (Kabylake GT2) 
GL_VERSION    = 3.0 Mesa 19.2.8
GL_VENDOR     = Intel Open Source Technology Center

dmesg | grep nvidia       
[41862.606324] glxgears[143647]: segfault at 8 ip 00007fbd07962758 sp 00007fffbc37a270 error 4 in libGLX_nvidia.so.440.64[7fbd078c5000+a9000]

cat /usr/share/X11/xorg.conf.d/nvidia.conf
#This file is provided by xorg-x11-drv-nvidia
#Do not edit

Section "OutputClass"
	Identifier "nvidia"
	MatchDriver "nvidia-drm"
	Driver "nvidia"
	Option "AllowEmptyInitialConfiguration"
	Option "SLI" "Auto"
	Option "BaseMosaic" "on"
EndSection

Section "ServerLayout"
	Identifier "layout"
	Option "AllowNVIDIAGPUScreens"
EndSection
2 Likes

I have pretty much the same problem. Fedora 32 with Cinnamon using Xorg on an XPS 15, which has i915 integrated and GTX 960M discrete graphics, for the latter of which i am using the proprietary drivers, version 455.38. If i run Firefox without the magic environment variables, it uses the Intel graphics, and is fairly slow. If i run it with __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia then it uses no hardware acceleration at all, with a message “GLXtest process failed (exited with status 1): No visuals found” in about:support.

From a thread on the NVidia forums, it sounds like this might be a lack of Firefox support - the graphics environment when using Prime offload is a bit odd, and Firefox doesn’t recognise it, so bails. But i really don’t know!

I’d say that Firefox doesn’t support Nvidia drivers at all. See:

1 Like

Hello, this should be solved by Firefox 94, see Firefox 94 comes with EGL on X11 – Martin Stransky's Blog

1 Like

6 posts were split to a new topic: Nvidia & wayland on laptop