What's new in WebKitGTK 2.46?

A couple of weeks ago the WebKitGTK team released version 2.46 of the GTK port of the WebKit project. While 2.44 was a significant release (making GTK4 the default toolkit for WebKitGTK), once again 2.46 marks an important milestone for the project, with the introduction of the new Skia rendering backend. Let’s have a look at what is new in this exciting release.

Skia replaces Cairo as the rendering backend

We announced some time ago that a new rendering backend with Skia was on the works and that it will eventually replace Cairo. This release series is the first where Skia is used, bringing important improvements in rendering and performance. Depending on hardware configurations, we have observed MotionMark score improvements up to four times better (4x) on powerful desktops with discrete GPUs, and low-end laptops, using integrated GPUs, managing to double (2x) their scores.

Bar chart with MotionMark scores: one for Skia at 617.42 points, another for Cairo at 162.57
Scores for WebKitGTK 2.46.1 running on Linux, AMD Epyc 7281 CPU with a Radeon RX 560 GPU.
Scores may vary!

Performance measurements are highly-dependant on the hardware where they run and how WebKit was built. The figures above are from one particular setup. The speedup that the switch to Skia will give you are expected to be, of course, different!

WebKit Build

Clang is recommended by the Skia developers, so version 18.1.8 was used with LTO optimization options, ICF, and -march=x86-64-v3. This is representative of common compiler options that packagers use.

WebKitGTK was built from the official 2.46.1 release tarball, using the following CMake invocation:

OPT='-flto=thin -march=x86-64-v3'
LDOPT='-flto=thin -Wl,-O1,--sort-common,--icf=safe'

CC=clang \
CXX=clang++ \
CFLAGS="$OPT -fdata-sections -ffunction-sections" \
CXXFLAGS="$OPT -fdata-sections -ffunction-sections" \
LDFLAGS="$LDOPT -fuse-ld=lld -Wl,--gc-sections" \
cmake -Bbuilddir -DPORT=GTK \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=$HOME/.prefix/gtk4cairo
    -GNinja

The same was used for the Cairo build, adding -DUSE_SKIA=OFF, and changing the installation path.

Hardware

The box used is a rather beefy desktop computer, although a few years old by now, which showed scores 3.8x better with Skia:

  • Dual AMD Epyc 7281 processor at 2.1 GHz (32 cores, 64 SMT threads).
  • AMD Radeon RX 560 GPU with 4 GiB of video memory.
  • 128 GiB of system memory.

We also tested on an aging laptop with the following specifications, which achieved scores 2.65x better with Skia:

  • Intel Skylake Core i7-6600U processor at 2.6 GHz (2 cores, 4 SMT threads).
  • Intel HD Graphics 520 integrated GPU.
  • 20 GiB of system memory.

The result from this second computer is the reason why we are confident that any reasonably recent desktop or laptop should get a good performance boost with this WebKitGTK release.

The Cairo backend is still present and will be selected automatically at build time for big-endian architectures, where Skia is not yet supported. We plan to remove support for Cairo in the near future, and this approach allows us to ship the new renderer while solving the remaining issues. At any rate, the Cairo renderer is no longer receiving active development.

It is important to notice that it is recommended to build WebKitGTK with Clang instead of GCC. This recommendation comes from upstream Skia; see their supported and preferred compilers page for details.

Revamped graphics stack

Tha switch to Skia has made possible a significant number of changes and improvements in the WebKit graphics stack. These changes relate to accelerated canvas, accelerated CSS filters, color spaces, and more. Carlos García has written extensively about these changes in his blog, we recommend reading his article for more details.

Trace point profiling with sysprof

Sysprof is a profiling and performance analysis tool for Linux. Thanks to integration with the libsysprof-capture library, it is now possible to use Sysprof to record trace points to do profiling and performance analysis of WebKit internals. This is a major improvement that will allow us to more effectively analyze the code paths that are more performance-sensitive and find ways to optimize them. It will also allow vendors to profile their specific hardware configurations and specific use-cases as well.

For a more in-depth presentation of the integration with Sysprof, please read Georges Stavacras’ blog post on the topic.

API changes

Additions:

Deprecations:

  • WebKitWebView::insecure-content-detected signal.
  • WebKitWebContext:use-system-appearance-for-scrollbars property.
  • webkit_web_context_set_use_system_appearance_for_scrollbars() and webkit_web_context_get_use_system_appearance_for_scrollbars().

Changes:

  • The non-standard HTMLDocument functions width() and height() have been removed, so now the DOM API functions webkit_dom_html_document_get_width() and webkit_dom_html_document_get_height() always return zero. The DOM API has been deprecated for many years and the change is expected to have little impact.

Web Platform changes

The changes to supported Web Platform features between releases of WebKit are always substantial, and for that reason listing all of those changes here would be a major endeavour. The following is an incomplete list of some of the features that have been enabled, removed, and marked in preview state since 2.44, in no particular order:

  • CSS Container/Style Queries
  • CSS text-wrap-style
  • CSS background-clip: border-area
  • CSS text-underline-position: left|right
  • CSS scrollbar-width
  • CSS View Transitions
  • CSS Grid Masonry layout (preview)
  • CSS ::target-text pseudo element
  • WebCrypto X25519 algorithm (preview)
  • AppCache support has been removed
  • New Promise.try() method
  • New Observable methods, like .map() and .filter()

Other noteworthy changes

  • Accelerated Compositing is now enabled by default in layout tests. Previously, AC mode would be enabled on-demand, and that behaviour can still be configured through the API.
  • The screensaver should not be triggered anymore when watching videos.
  • The Web Inspector gained support for loading JavaScript garbage collector snapshots for inspection.
  • Suport for the WebP image format is now always enabled.
  • WebDriver clients may now connect to an already running process, instead of always needing to spawn a new one.
  • The gst-libav AAC decoders are now disabled due to outstanding bugs. Distributors are encouraged to use the GStreamer FDK AAC decoder (part of gst-plugins-bad) instead.

On top of all of the above, there are countless bug fixes and improvements to WebKit, so many that it would be impossible to list them all here. For more details, you can always check the release notes for the 2.45.x release series from the news section and the Git commit history.

The WebKitGTK team is already working on 2.48, which will be even more awesome. Until then!