-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Avoid crash with EGLFS #15874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid crash with EGLFS #15874
Changes from 3 commits
e54e208
1b1aa92
c85da97
4d756a6
bcce816
a0e3606
4f82810
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ | |
| #endif | ||
|
|
||
| #ifdef MIXXX_USE_QOPENGL | ||
| #include <QGuiApplication> | ||
|
|
||
| #include "widget/tooltipqopengl.h" | ||
| #include "widget/winitialglwidget.h" | ||
| #endif | ||
|
|
@@ -156,22 +158,35 @@ void MixxxMainWindow::initializeQOpenGL() { | |
| // QGLFormat::hasOpenGL() has been removed. | ||
| if (!CmdlineArgs::Instance().getSafeMode() && QGLFormat::hasOpenGL()) { | ||
| #else | ||
| if (!CmdlineArgs::Instance().getSafeMode()) { | ||
| // With EGLFS there is always exactly one native window and one EGL window surface | ||
| // OpenGL windows cannot be embedded into our QWidgets main window we already have. | ||
| // https://doc.qt.io/qt-6/embedded-linux.html | ||
| bool isEglfs = QGuiApplication::platformName() == "eglfs"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we know if this string is normalised? Wondering if somebody passes
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://doc.qt.io/qt-6/qguiapplication.html#platformName-prop only one spelling is mentioned. I think we can trust it. |
||
|
|
||
| if (!CmdlineArgs::Instance().getSafeMode() && !isEglfs) { | ||
| #endif | ||
| QOpenGLContext context; | ||
| context.setFormat(WaveformWidgetFactory::getSurfaceFormat(m_pCoreServices->getSettings())); | ||
| if (context.create()) { | ||
| std::pair version = context.format().version(); | ||
|
JoergAtGithub marked this conversation as resolved.
|
||
| qDebug().noquote() | ||
| << "QOpenGLContext created:" | ||
| << QGuiApplication::platformName() | ||
| << context.format().renderableType() | ||
| << QString("V%1.%2").arg(QString::number(version.first), | ||
| QString::number(version.second)) | ||
| << context.format().profile(); | ||
| // This widget and its QOpenGLWindow will be used to query QOpenGL | ||
| // information (version, driver, etc) in WaveformWidgetFactory. | ||
| // The "SharedGLContext" terminology here doesn't really apply, | ||
| // but allows us to take advantage of the existing classes. | ||
| WInitialGLWidget* widget = new WInitialGLWidget(this); | ||
| widget->setGeometry(QRect(0, 0, 3, 3)); | ||
| SharedGLContext::setWidget(widget); | ||
| WInitialGLWidget* pWidget = new WInitialGLWidget(this); | ||
|
daschuer marked this conversation as resolved.
Outdated
|
||
| pWidget->setGeometry(QRect(0, 0, 3, 3)); | ||
| SharedGLContext::setWidget(pWidget); | ||
| // When the widget's QOpenGLWindow has been initialized, we continue | ||
| // with the actual initialization | ||
| connect(widget, &WInitialGLWidget::onInitialized, this, &MixxxMainWindow::initialize); | ||
| widget->show(); | ||
| connect(pWidget, &WInitialGLWidget::onInitialized, this, &MixxxMainWindow::initialize); | ||
| pWidget->show(); | ||
| return; | ||
| } | ||
| qDebug() << "QOpenGLContext::create() failed"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "waveform/waveform.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| #ifdef MIXXX_USE_QOPENGL | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <QGuiApplication> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <QOpenGLShaderProgram> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <QOpenGLWindow> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -185,17 +186,30 @@ WaveformWidgetFactory::WaveformWidgetFactory() | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| m_openGLShaderAvailable = QOpenGLShaderProgram::hasOpenGLShaderPrograms(pContext); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| m_openGLVersion = pContext->isOpenGLES() ? "ES " : ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // With EGLFS there is always exactly one native window and one EGL window surface | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // OpenGL windows cannot be embedded into our QWidgets main window we already have. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // That's why m_openGlesAvailable is not set to true. TODO: use GL Widgets for all | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // https://doc.qt.io/qt-6/embedded-linux.html | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| bool isEglfs = QGuiApplication::platformName() == "eglfs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (isEglfs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| m_openGLVersion = "EGLFS "; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (pContext->isOpenGLES()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| m_openGLVersion = "ES "; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This used to be init-ed to an empty string if not
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are here in the constructor, the constructor initializes the QString as empty. So nothing to do IMHO, except using QStringLiteral. I will also add a comment. |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| m_openGLVersion += majorVersion == 0 ? QString("None") : versionString; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Qt5 requires at least OpenGL 2.1 or OpenGL ES 2.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (pContext->isOpenGLES()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (majorVersion * 100 + minorVersion >= 200) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| m_openGlesAvailable = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (majorVersion * 100 + minorVersion >= 201) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| m_openGlAvailable = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!isEglfs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Qt5 requires at least OpenGL 2.1 or OpenGL ES 2.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
acolombier marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (pContext->isOpenGLES()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (majorVersion * 100 + minorVersion >= 200) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| m_openGlesAvailable = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (majorVersion * 100 + minorVersion >= 201) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| m_openGlAvailable = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we merge this condition to help readability?
Suggested change
Also wondering if we need to set
Suggested change
If not, could you please put a comment to highlight that these are expected to be set to false otherwise during another step? |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1365,10 +1379,12 @@ QString WaveformWidgetAbstractHandle::getDisplayName(WaveformWidgetType::Type ty | |||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| // static | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| QSurfaceFormat WaveformWidgetFactory::getSurfaceFormat(UserSettingsPointer config) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| QSurfaceFormat WaveformWidgetFactory::getSurfaceFormat(UserSettingsPointer pConfig) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // The first call should pass the config to set the vsync mode. Subsequent | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // calls will use the value as set on the first call. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| static const auto vsyncMode = config->getValue(kVSyncKey, 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| static const VSyncThread::VSyncMode vsyncMode = pConfig | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? pConfig->getValue(kVSyncKey, VSyncThread::ST_DEFAULT) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| : VSyncThread::ST_DEFAULT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| QSurfaceFormat format; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Qt5 requires at least OpenGL 2.1 or OpenGL ES 2.0, default is 2.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.