How to enable Webgl in Firefox on Ubuntu

By | January 4, 2023

WebGL

WebGL (Web Graphics Library) is a JavaScript API for rendering interactive 3D graphics and 2D graphics[2] within any compatible web browser without the use of plug-ins.

It is analogous to a 3D graphics api like OpenGL but runs inside a web browser and programmed in javascript instead of C or C++.

The important thing to know that is use the gpu for hardware acceleration of 3D graphics. So it allows the browser to utilise the power of dedicated graphics card like rtx3060. If a dedicated graphics card is not present, it should use the integrated gpu from the cpu.

Software based renderer

Note: You should not need to do any of the below if you are using the latest version of Ubuntu and Firefox.

The 'webgl.osmesalib' parameter has been deprecated and removed from latest versions of Firefox

Check the following url:
https://bugzilla.mozilla.org/show_bug.cgi?id=743755

***** OLD *****

Webgl might not work directly on your system if there is no supporting hardware or graphics card available. Even then webgl can be made available inside firefox through the software based OpenGL renderer like MESA.

To enable it following steps below. Install the Mesa off-screen rendering extension

$ sudo apt-get install libosmesa6

Next find out the location of the library installed by the package.

Use the dpkg-query command for this.

$ dpkg-query -L libosmesa6
/.
/usr
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libOSMesa.so.8.0.0
/usr/share
/usr/share/bug
/usr/share/bug/libosmesa6
/usr/share/bug/libosmesa6/control
/usr/share/bug/libosmesa6/script
/usr/share/doc
/usr/share/doc/libosmesa6
/usr/share/doc/libosmesa6/copyright
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/libosmesa6
/usr/lib/x86_64-linux-gnu/libOSMesa.so.6
/usr/lib/x86_64-linux-gnu/libOSMesa.so.8
/usr/share/doc/libosmesa6/changelog.Debian.gz
$

On my system it was located at the following location for example

/usr/lib/x86_64-linux-gnu/libOSMesa.so.6.5.3

The actual location on your system can be different.

Now open firefox and do the following

1. Go to about:config
2. Search for webgl.osmesalib
3. Type in the path of the mesa library in the value of this preference.
4. Restart firefox

Test it

Now open the following url
http://get.webgl.org/

It would say "Your browser supports WebGL" and play a spinning cube animation.

Cssdeck also has a webgl item here
http://cssdeck.com/labs/sakura

For technical information about webgl support in firefox check
http://www.doesmybrowsersupportwebgl.com/

It should say Yay and display additional information about the webgl support.

If they all work fine, then webgl is enabled properly.

Conclusion

The above method is now deprecated and should not be needed on any modern system with a capable igpu or graphics card.

About Silver Moon

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected].

5 Comments

How to enable Webgl in Firefox on Ubuntu
  1. ed

    installed as proposed (thinkpad t430s, firefox 88.0, linux mint cinnamon 20.1, webGL not working). search for libOSMesa.so.6.5.3 goes on forever without result. what is found is this:
    /usr/share/bug/libosmesa6
    /usr/share/doc/libosmesa6
    /usr/share/lintian/overrides/libosmesa6
    /var/cache/apt/archives/libosmesa6_20.2.6-0ubuntu0.20.04.1_amd64.deb
    /var/lib/dpkg/info/libosmesa6:amd64.list
    /var/lib/dpkg/info/libosmesa6:amd64.md5sums
    /var/lib/dpkg/info/libosmesa6:amd64.shlibs
    /var/lib/dpkg/info/libosmesa6:amd64.triggers
    /usr/lib/x86_64-linux-gnu/libOSMesa.so.6
    /usr/lib/x86_64-linux-gnu/libOSMesa.so.8
    /usr/lib/x86_64-linux-gnu/libOSMesa.so.8.0.0

    in about:config webgl.osmesalib cannot be found. the site http://www.doesmybrowsersupportwebgl.com loads forever and stays empty. sorry, but this method does not work here to help me getting webGL work on my notebook.

Leave a Reply

Your email address will not be published. Required fields are marked *