WebGL and fgx acceleration on Wayland

WebGL on Wayland running in full speed.

Firefox on Linux have suffered by poor WebGL performance for long, long time. It was given by missing general acceleration on Linux as there are always broken gfx drivers on X11, various hacks and different standards, closed source drivers and so on. Long story short – to do gfx acceleration seriously on Linux have been PITA. For instance Chrome (which supports gfx acceleration on Linux/X11) shows long list of active exceptions and workarounds listen at chrome://gpu/ page.

It’s also reason why Firefox never enabled it by default although it also implements gfx acceleration – Mozilla does not have resources to spend too much time on every broken gfx card / driver.

Fortunately situation was changed with Wayland. Working gfx acceleration is a sort of prerequisite to even start a decent Wayland compositor like Mutter or Plasma so when Firefox is launched on Wayland we can pretty much expect working GL environment. Also dmabuf is widely supported by Wayland compositor so we finally have all pieces together to build fully accelerated browser on Linux which is equal to its Windows siblings.

Firefox supports two acceleration modes – WebRender and GL compositor. WebRender is the new one and it’s superior in web content rendering. GL compositor is the former one, less advanced but it’s still faster for some scenarios where bits are heavily shifted from one side to another one – video playback and WebGL.

Both WebRender and GL compositor have implemented dmabuf back end which means textures used by WebRender/GL compositor can be created directly at GPU and shared  without copy among compositor / GPU browser processes. Such GPU memory can be in the same time mapped as EGL framebuffer so we can render WebGL frames directly to GPU memory, handle them from webgl process to chrome process and render it as a texture to a web page.

All those pieces are tied together in recent nightly where we finally have full WebGL support on Wayland and it will be shipped as Firefox 75. If you run Fedora/Gnome you can try it by yourself. Just grab latest nightly from Mozilla, enable HW acceleration, set widget.wayland-dmabuf-webgl.enabled to true at about:config, restart browser and open your favorite WebGL application like maps.google.com or WebGL samples.

15 thoughts on “WebGL and fgx acceleration on Wayland

  1. Is the config “widget.wayland-dmabuf-webgl.enabled” the only one necessary to enable this feature, or should WebRender be enabled as well?


    1. You also need to enable GL compositor (by layers.acceleration.force-enabled) or WebRender (gfx.webrender.enabled and gfx.webrender.all). But WebRender it enabled by default on some nightly, you can check that at about:support page at “Compositor” field.

      Liked by 1 person

      1. Hardware is not an issue. Wayland itself have no requirement on hardware, on other side, compositors implementing Wayland rely on OpenGL by their choice.

        It’s great that we finally getting some fruits from Wayland development.

        Liked by 2 people

  2. > on Linux as there are always broken gfx drivers on X11, various hacks and different standards, closed source drivers and so on

    Ehm… Is it really true? Though I personally haven’t been with GNU/Linux long enough, but a decode ago Dolphin developers praised all GNU/Linux drivers except the prorietary fglrx of AMD https://dolphin-emu.org/blog/2013/09/26/dolphin-emulator-and-opengl-drivers-hall-fameshame/ And Mesa devs are both responsive regarding regressions and have a great test-suite. Regarding fglrx, it has been discontinued and died in preference of Mesa.

    So what you’re saying sounds very odd to me.

    Liked by 1 person

  3. Thanks for the great work!
    One question: I assume FF 75 will get the features, but not the defaults? When does Firefox plan to flip various kinds of hardware acceleration “on” by default?


  4. “You can verify that VA-API is enabled by running Firefox with MOZ_LOG=”PlatformDecoderModule:5″ env variable and check in the log output that VA-API is enabled and used.”

    Where is this log located. I read the bugzilla post about enabling this but I can’t find any information about this magic log that will confirm if it is working.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Create your website at WordPress.com
Get started
%d bloggers like this: