New graphics integration in Qt WebEngine 6.6 and even 6.5

With the 6.5.1 release, there will be one new change our users might notice. Qt WebEngine has previously forced the Qt Quick SceneGraph to use the OpenGL backend on Windows and macOS, even though the Qt defaults were using D3D11 and Metal respectively. With Qt 6.5.1 Qt WebEngine will now run with the Metal and D3D11 default QSG backends.

This has been a long time coming. Chrome has always preferred using ANGLE on Windows. Where Qt did offer ANGLE in Qt5 but defaulted to WGL (Windows OpenGL), since Qt6 the ANGLE backend has been removed from Qt Gui, and WebEngine required Chromium to run in WGL mode. This has caused many issues, due to buggy Windows OpenGL drivers, and due to not using the same backend as Chrome itself.

In the last 6 months Chrome has switched to using ANGLE on all their desktop platforms, and also removed the integration code to native OpenGL on Linux/X11 (GLX) and macOS (CGL). On top of this Chrome has plans to move rendering from ANGLE (GL implementation) to Dawn (WebGPU implementation).

Given the diverging differences in backends we can no longer expect Chromium and Qt to run on similar graphics backends, so we will need to bridge whatever Chromium is doing with whatever Qt is doing. The solution will be to render to native GPU memory buffers. On macOS using IOSurface, and on Windows using DXGI. We statically link Qt WebEngine Chromium with ANGLE. Let Chromium render however it wants to native backed buffers, and then pass these GPU memory buffers to the Qt Quick Scene graph in the native Qt RHI graphics modes (currently supporting Metal and D3D11).

This should increase stability and performance for Windows and macOS users in 6.5.1, but if it unexpectedly causes any problems for anyone in 6.5.1, the old behaviour can be restored by setting QSG_RHI_BACKEND=opengl, or by calling QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL).

For Qt 6.6 this will go further and we will remove the old native OpenGL backends from our fork of Chromium. Chromium itself removed the code long ago, and it is getting increasingly difficult to maintain this old abandoned code. Instead we will import the native GPU memory buffers into OpenGL just like we do for Metal and D3D11. There are a few concerns however, such as the poor quality of WGL_NV_DX_interop2
implementations in Windows OpenGL drivers, and missing functionality in NVidia proprietary drivers on Linux to generate GBM buffers (GBM being the "native" graphics buffers of Linux). This means work is still ongoing for the transition in 6.6.

One other side effect of this work, was already shipped in 6.5.0. With the support for native GPU memory buffers, we can now also handle hardware video acceleration on Linux. Luckily even the NVidia drivers support importing GBM buffers for this purpose, even if the rest of the GBM extension is missing.


Blog Topics:

Comments