summaryrefslogtreecommitdiffstats
path: root/abs/core/qt5-webengine/qtwebengine-no-gpu.patch
blob: 4662f5f35ff1dada114c19039efb4f58f4af0afe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
From: Antonio Larrosa <alarrosa@suse.com>
Subject: Disable GPU when using nouveau or running on wayland
References: boo#1005323, boo#1060990

Qt WebEngine uses multi-threaded OpenGL, which nouveau does not support.
It also crashes when running on wayland, the cause is not yet known.
Work around these issues by not doing GPU-accelerated rendering in such
cases.

Index: qtwebengine-everywhere-src-5.10.0/src/core/web_engine_context.cpp
===================================================================
--- qtwebengine-everywhere-src-5.10.0.orig/src/core/web_engine_context.cpp
+++ qtwebengine-everywhere-src-5.10.0/src/core/web_engine_context.cpp
@@ -93,6 +93,7 @@
 #include <QOffscreenSurface>
 #ifndef QT_NO_OPENGL
 # include <QOpenGLContext>
+# include <QOpenGLFunctions>
 #endif
 #include <QQuickWindow>
 #include <QStringList>
@@ -167,6 +168,39 @@ void dummyGetPluginCallback(const std::v
 }
 #endif
 
+#ifndef QT_NO_OPENGL
+QString openGLVendor()
+{
+    QString vendor;
+
+    QOpenGLContext *oldContext = QOpenGLContext::currentContext();
+    QSurface *oldSurface = 0;
+    if (oldContext)
+        oldSurface = oldContext->surface();
+
+    QScopedPointer<QOffscreenSurface> surface( new QOffscreenSurface );
+    surface->create();
+    QOpenGLContext context;
+    if (!context.create()) {
+        qDebug() << "Error creating openGL context";
+    }
+    else if (!context.makeCurrent(surface.data())) {
+        qDebug() << "Error making openGL context current context";
+    } else {
+        const GLubyte *p;
+        QOpenGLFunctions *f = context.functions();
+        if ((p = f->glGetString(GL_VENDOR)))
+            vendor = QString::fromLatin1(reinterpret_cast<const char *>(p));
+    }
+
+    context.doneCurrent();
+    if (oldContext && oldSurface)
+        oldContext->makeCurrent(oldSurface);
+
+    return vendor;
+}
+#endif
+
 } // namespace
 
 namespace QtWebEngineCore {
@@ -379,6 +413,27 @@ WebEngineContext::WebEngineContext()
     const char *glType = 0;
 #ifndef QT_NO_OPENGL
 
+    bool disableGpu = qEnvironmentVariableIsSet("QT_WEBENGINE_DISABLE_GPU");
+
+    if (!qEnvironmentVariableIsSet("QT_WEBENGINE_DISABLE_WAYLAND_WORKAROUND") && platform.startsWith("wayland", Qt::CaseInsensitive))
+    {
+        qWarning() << "Running on wayland. Qt WebEngine will disable usage of the GPU.\n"
+                      "Note: you can set the QT_WEBENGINE_DISABLE_WAYLAND_WORKAROUND\n"
+                      "environment variable before running this application, but this is \n"
+                      "not recommended since this usually causes applications to crash.";
+        disableGpu = true;
+    }
+
+    if (!qEnvironmentVariableIsSet("QT_WEBENGINE_DISABLE_NOUVEAU_WORKAROUND") && openGLVendor() == QStringLiteral("nouveau"))
+    {
+        qWarning() << "Nouveau openGL driver detected. Qt WebEngine will disable usage of the GPU.\n"
+                      "Note: you can set the QT_WEBENGINE_DISABLE_NOUVEAU_WORKAROUND\n"
+                      "environment variable before running this application, but this is \n"
+                      "not recommended since this usually causes applications to crash as\n"
+                      "Nouveau openGL drivers don't support multithreaded rendering";
+        disableGpu = true;
+    }
+
     bool tryGL =
             !usingANGLE()
             && (!usingSoftwareDynamicGL()
@@ -389,7 +444,7 @@ WebEngineContext::WebEngineContext()
                 || enableWebGLSoftwareRendering
 #endif
                 )
-            && !usingQtQuick2DRenderer();
+            && !usingQtQuick2DRenderer() && !disableGpu;
 
     if (tryGL) {
         if (qt_gl_global_share_context() && qt_gl_global_share_context()->isValid()) {