Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to use QtWebEngine without OpenGL?

I'm trying to get QtWebEngine running on a VM and am having difficulties. According to the answer to this question:

Eventually I realised that OpenGL 3.3 wouldn't work easily on virtual machines .. yet. I had to boot from ubuntu usb and work from there by installing latest mesa 3d package.

Is there a way to get QtWebEngine to work without OpenGL? I'm not directly using any OpenGL calls, nor do I need any 3d capabilities. I just want to embed a QWebEngineView to display dynamic HTML pages. I'm guessing this should be possible since Chrome works on the same VM without an issue.

like image 586
Claudiu Avatar asked Sep 27 '22 12:09

Claudiu


1 Answers

I don't think there is a way to use the Qt WebEngine without OpenGL. It is not very explicitly said in the documentation, but here's what I understood from what I found.

About Chromium

As it is said here, QtWebEngine integrates chromium's fast moving web capabilities into Qt. Plus, it is Chromium that allows the manipulation of OpenGL via the Qt Quick scene graph (source) :

Chromium is tightly integrated to the Qt Quick scene graph, which is based on OpenGL ES 2.0 or OpenGL 2.0 for its rendering. This provides you with one-pass compositing of web content and all the Qt Quick UI. The integration to Chromium is transparent to developers, who just work with Qt and JavaScript.

It is also said that both the render process and the GUI process should share an OpenGL context :

Because the render process is separated from the GUI process, they should ideally share an OpenGL context to enable one process to access the resources uploaded by the other, such as images or textures.

About the Qt WebEngine itself

We just talked about the Qt's GUI : in fact, the Qt WebEngine is not dependent of this GUI (page rendering and JavaScript execution are separated from the GUI process into the Qt WebEngine process), but remember that if you want your application to work, you will need to share an OpenGL context between both processes. In particular, this is achieved by default with a QSurfaceFormat, which has a OpenGLContextProfile accessible by the function QSurfaceFormat::profile(). Now, we look back at the Qt WebEngine platform notes which states :

If a new default QSurfaceFormat with a modified OpenGL profile has to be set, it should be set before the application instance is declared, to make sure that all created OpenGL contexts use the same OpenGL profile.

On OS X, if the default QSurfaceFormat is set after the application instance, the application will exit with qFatal(), and print a message that the default QSurfaceFormat should be set before the application instance.

If we look at the source code of Qt, calls to OpenGL are made in several important files, like qtwebengine\src\core\web_engine_context.cpp or qtwebengine\src\webengine\api\qtwebengineglobal.cpp. Moreover, I also found calls to OpenGL in functions from the sources in qtwebengine\src\3rdparty\chromium\, so I suspect that Chromium needs to call OpenGL functions sometimes.

In short

The Qt WebEngine is using Chromium (which doesn't necessarily use OpenGL) and also Qt GUI, which uses an OpenGL context which has to be shared by the Web Engine. Thus, my conclusion is that you can't use the Qt WebEngine without OpenGL.

like image 166
IAmInPLS Avatar answered Sep 29 '22 07:09

IAmInPLS