WebKitGTK Working On Accelerated Composited Rendering With DMA-BUF

Written by Michael Larabel in GNOME on 3 April 2023 at 06:36 AM EDT. 19 Comments
GNOME
While WebKitGTK already provides accelerated compositing support, there are different code paths depending upon whether Wayland or X11 are used and various other complexities involved as well as differences between using the GTK3 and GTK4 toolkits. WebKitGTK developers have been working to instead shift their multiple different code paths toward one route by way of DMA-BUF.

WebKitGTK already makes use of DMA-BUF buffer sharing for WebGL and media rendering while moving forward they are shifting to make use of it as well for rendered buffer sharing between the web and UI processes. Igalia developer Carlos Garcia Campos explained in a new blog post today:
"We are already using DMABUF in WebKit for different things like WebGL and media rendering, so we thought that we could also use it for sharing the rendered buffer between the web and UI processes. That would be a more efficient solution but it would also drastically reduce the amount of combinations to maintain. The web process always uses the surfaceless platform, so it doesn’t matter if it’s under Wayland or X11. Then we create a surfaceless context as the render target and use EGL and GBM APIs to export the contents as a DMABUF buffer. The UI process imports the DMABUF buffer using EGL and GBM too, to be passed to GTK as a texture that is painted in the web view.

This theoretically recudes all the previous combinations to just one (note that we removed GLX support entirely, making EGL a requirement for accelerated compositing), but there’s a problem under X11: GTK3 doesn’t support EGL on X11 and GTK4 defaults to EGL but falls back to GLX if it doesn’t find an EGL config that perfectly matches the screen visual. In my system it never finds that EGL config because mesa doesn’t expose any 32 bit depth config. So, in the case of GTK3 we have to manually download the buffer to CPU and paint normally using Cairo, but in the case of GTK4 + GLX, GTK uploads the buffer again to be painted using GLX. I don’t think it’s possible to force GTK to use EGL from the API, but at least you can use GDK_DEBUG=gl-egl.
WebKitGTK 2.41.1

WebKitGTK 2.41.1 is the first unstable release of this cycle and already includes the DMABUF support that is used by default. We encourage everybody to try it out and provide feedback or report any issue. Please, export the contents of webkit://gpu and attach it to the bug report when reporting any problem related to graphics. To check if the issue is a regression of the DMABUF implementation you can use WEBKIT_DISABLE_DMABUF_RENDERER=1 to use the WPE renderer or X11 instead. This environment variable and the WPE render/X11 code will be eventually removed if DMABUF works fine."

More details on this new DMA-BUF approach for accelerated composited rendering with WebKitGTK can be found via Carlos' blog.

WebKitGTK logo


WebKitGTK 2.4.1.1 as the new development release with making use of DMA-BUF and WebKit IPC for rendering was released on Thursday. WebKitGTK is the WebKit rendering engine port used by various GNOME/GTK applications like GNOME Web / Epiphany and other HTML/CSS needs on the GNOME desktop.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week