Skip to content

Commit 5b84b15

Browse files
committed
Trigger disabling offline renderers on late 2013 Mac Pros
This reads the hw.model string through sysctlbyname and sets the environment variable QT_MAC_PRO_WEBENGINE_WORKAROUND to tell the Cocoa platform plugin to not enable offline renderers upon creation of the platform OpenGL context. Task-number: QTBUG-70062 Change-Id: I986d9d76a80f96a215f3fcd08b3d47e546682e35 Reviewed-by: Jüri Valdmann <[email protected]>
1 parent 6fffee8 commit 5b84b15

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/core/api/qtwebenginecoreglobal.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
#include <QGuiApplication>
4343
#ifndef QT_NO_OPENGL
4444
# include <QOpenGLContext>
45+
#ifdef Q_OS_MACOS
46+
#include <sys/types.h>
47+
#include <sys/sysctl.h>
48+
#endif
4549
#endif
4650
#include <QThread>
4751

@@ -52,6 +56,23 @@ Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
5256
QT_END_NAMESPACE
5357
#endif
5458

59+
#ifndef QT_NO_OPENGL
60+
#ifdef Q_OS_MACOS
61+
static bool needsOfflineRendererWorkaround() {
62+
size_t hwmodelsize = 0;
63+
64+
if (sysctlbyname("hw.model", nullptr, &hwmodelsize, nullptr, 0) == -1)
65+
return false;
66+
67+
char hwmodel[hwmodelsize];
68+
if (sysctlbyname("hw.model", &hwmodel, &hwmodelsize, nullptr, 0) == -1)
69+
return false;
70+
71+
return QString::fromLatin1(hwmodel) == QLatin1String("MacPro6,1");
72+
}
73+
#endif
74+
#endif
75+
5576
namespace QtWebEngineCore {
5677
#ifndef QT_NO_OPENGL
5778
static QOpenGLContext *shareContext;
@@ -74,7 +95,10 @@ QWEBENGINE_PRIVATE_EXPORT void initialize()
7495
#ifdef Q_OS_WIN32
7596
qputenv("QT_D3DCREATE_MULTITHREADED", "1");
7697
#endif
77-
98+
#ifdef Q_OS_MACOS
99+
if (needsOfflineRendererWorkaround())
100+
qputenv("QT_MAC_PRO_WEBENGINE_WORKAROUND", "1");
101+
#endif
78102
// No need to override the shared context if QApplication already set one (e.g with Qt::AA_ShareOpenGLContexts).
79103
if (qt_gl_global_share_context())
80104
return;
@@ -107,3 +131,4 @@ QWEBENGINE_PRIVATE_EXPORT void initialize()
107131
#endif // QT_NO_OPENGL
108132
}
109133
} // namespace QtWebEngineCore
134+

0 commit comments

Comments
 (0)