diff --git a/src/core/api/qtwebenginecoreglobal.cpp b/src/core/api/qtwebenginecoreglobal.cpp index 0353dac7d6ac1b07bcd6cbcef897d0cedf5fabbb..4bb69ac21394287e183bab8b7c6f265b7cdb0757 100644 --- a/src/core/api/qtwebenginecoreglobal.cpp +++ b/src/core/api/qtwebenginecoreglobal.cpp @@ -42,6 +42,10 @@ #include <QGuiApplication> #ifndef QT_NO_OPENGL # include <QOpenGLContext> +#ifdef Q_OS_MACOS +#include <sys/types.h> +#include <sys/sysctl.h> +#endif #endif #include <QThread> @@ -52,6 +56,23 @@ Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context(); QT_END_NAMESPACE #endif +#ifndef QT_NO_OPENGL +#ifdef Q_OS_MACOS +static bool needsOfflineRendererWorkaround() { + size_t hwmodelsize = 0; + + if (sysctlbyname("hw.model", nullptr, &hwmodelsize, nullptr, 0) == -1) + return false; + + char hwmodel[hwmodelsize]; + if (sysctlbyname("hw.model", &hwmodel, &hwmodelsize, nullptr, 0) == -1) + return false; + + return QString::fromLatin1(hwmodel) == QLatin1String("MacPro6,1"); +} +#endif +#endif + namespace QtWebEngineCore { #ifndef QT_NO_OPENGL static QOpenGLContext *shareContext; @@ -74,7 +95,10 @@ QWEBENGINE_PRIVATE_EXPORT void initialize() #ifdef Q_OS_WIN32 qputenv("QT_D3DCREATE_MULTITHREADED", "1"); #endif - +#ifdef Q_OS_MACOS + if (needsOfflineRendererWorkaround()) + qputenv("QT_MAC_PRO_WEBENGINE_WORKAROUND", "1"); +#endif // No need to override the shared context if QApplication already set one (e.g with Qt::AA_ShareOpenGLContexts). if (qt_gl_global_share_context()) return; @@ -107,3 +131,4 @@ QWEBENGINE_PRIVATE_EXPORT void initialize() #endif // QT_NO_OPENGL } } // namespace QtWebEngineCore +