Open NielsMayer opened 5 years ago
As corollary, the same crash could occur in hellowidget example but it would happen because widgets are not supported, and not because of the issue with initializing nanovg.
13:54:33: Debugging starts QOpenGLWidget is not supported on this platform. qt.qpa.webgl: WebGL QPA platform plugin: Raster surfaces are not supported 13:54:50: Debugging has finished
From the link at beginning of this page:
Since it’s for OpenGL (ES) things only, WebGL streaming does not work with Widgets or any other non-OpenGL stuff. In fact, if you try to launch some “non-compatible” Qt application using WebGL QPA, most likely you’ll get the following error: qt.qpa.webgl: WebGL QPA platform plugin: Raster surfaces are not supported
To clarify, the 'hellowidget' example is not part of this bug. All the other examples are.
Hi Niels, your output shows Creating suitable QNanoBackend for OpenGL 2.0 context Using backend: "OpenGL 2"
So it is no wonder that nanvg init returns a nullptr. The question is why qnanopainter detects open gl instead of gles. The code uses bool isGLES = (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES); so it looks like qt returns it wrong.
The docs says: Note: A desktop OpenGL implementation may be capable of creating ES-compatible contexts too. Therefore in most cases it is more appropriate to check QSurfaceFormat::renderableType() or use the convenience function isOpenGLES().
Note: This function requires that the QGuiApplication instance is already created.
Regards, Gunnar
To Build with Qt5.15 and wasm, one needs to explicitly force
equals(QT_ARCH,"wasm") {
DEFINES += QNANO_BUILD_GLES_BACKENDS
}
Or you get error using the default build (which doesn't detect WASM -- the .pro and .pri files need the above change to make this work automatically.)
In file included from ../../libqnanopainter/private/qnanobackendgl2.cpp:12:
../../libqnanopainter/nanovg/nanovg_gl_wrapped.h:750:51: error: use of undeclared identifier 'GL_GENERATE_MIPMAP'
QNANO_GLFWRAPPER glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
Note that wasm requires GLES, per https://wiki.qt.io/Qt_for_WebAssembly#General_Notes
"Qt will detect OpenGL support as OpenGL ES. In reality the browser will be providing WebGL. WebGL is based on ES and is very similar, but there are some incompatibilities. See WebGL and OpenGL Differences"
Thanks! I pushed patch above according to your help which should fix this.
Qt5.12LTS has the ability to run apps on the browser: https://blog.qt.io/blog/2018/11/23/qt-quick-webgl-release-512/
Unfortunately, QNanoPainter-based apps crash under the new WebGL backend.
In order to debug qnanopainter examples under Qtcreator 4.8.0, with the new webgl backend: (0) Load qnanopainter.pro in qtcreator (1) Click "Projects" mode -> "Build & Run" -> "Your Desktop platform" -> Run a) Under "run configuration" select "gallery" then click Add->"Clone Selected" b) Name the cloned run configuration, for example, "gallery-webgl" c) Under "Command line arguments" for run configuration "gallery-webgl" enter
-platform webgl:port=8998
(2) Select run configuration "gallery-webgl" and click the "Start Debugging" button. a) application will launch and wait for browser. (3) in browser visit " http://localhost:8998 " (4) The QtQuick component menus of app "gallery" will now be visible in the browser. (5) Clicking any of the menus in the browser will crash the app once QNanoPainter is invoked. The other examples will crash immediately on startup (in the same code) as they init QNanoPainter right away.The crash occurs at https://github.com/QUItCoding/qnanopainter/blob/master/libqnanopainter/qnanopainter.cpp#L157
Q_ASSERT_X(m_nvgContext, "QNanoPainter::QNanoPainter", "Could not init nanovg!");
Prior to the crash the following output is provided on stdout/stderr (note environment "QSG_RENDER_LOOP=threaded" and "QSG_INFO=1", running on Kubuntu 18.04LTS)