WebKitGTK+ accelerated composition on Wayland

As part of my work at Igalia browsers team, I am working on making WebKitGTK+ and Epiphany work on Wayland.

Just running non 3D websites on Wayland did not involve too much work. But running the OpenGL accelerated code in WebKit was a bit more complicated. Though, I’ve got a first working version.

Video: Epiphany on Wayland running WebGL and CSS-3D

On WebKitGTK+, we enable the use of hardware acceleration with OpenGL for:

  • WebGL: web pages with a canvas using WebGL are run using the 3D hardware available.
  • Accelerated composition of layers. With stuff like CSS-3D transformations, 3D hardware acceleration is handy to composite the layers of a webpage.
You can read more about accelerated compositing on these posts from Martin Robinson: WebKitGTK+ hackfest wrapup, and Accelerated compositing update.

On X11, we use XComposite, sharing a Window among the GTK+ widget (WebKitWebView) and the GL contexts for WebGL and accelerated composition. We have a tree of layers, each one rendering to a texture. Then these textures are composited rendering directly to the X11 window.

On Wayland, things are a bit different. Wayland protocol does not define a way to share a buffer among clients, nor a way to “insert” a window inside another window. My solution is just making the accelerated compositor render the layers to another texture. When the time comes for the WebKitWebView to be drawn (using Cairo), we render this texture too. If we build GTK+ for using EGL, then this process happens completely on GPU.

Next step will be adding support for accelerated composition in WebKit2GTK+. The main challenge here is that the WebKitWebView widget is on UI process and the WebGL contexts and layers rendering are in Web Process. So, if we want to avoid buffers going to/from GPU, we need to share them between the two processes. DRM authentication through EGL_mesa_drm extension could help here.

2 thoughts on “WebKitGTK+ accelerated composition on Wayland”

  1. Hi,
    I’m trying to enable webgl on epiphany 3.10 using libwebkit2gtk 2.3.2 on X (sorry if it is not wayland) with Ubuntu 3.10 gnome.
    However webgl experiment sites report that my browser is not supporting WebGL (Chrome and FF do!).
    So, how can I enable webgl on epiphany? Thanks!

Comments are closed.