summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2023-10-26 09:59:13 +0200
committerMichal Klocek <michal.klocek@qt.io>2023-11-01 08:03:29 +0000
commit088408f5472b125746a3313f4a8e0f30774cebfe (patch)
tree66aad87d17eae5ecc9f7e5bf97fffcbe6ceb2f53
parentd40ba15ec9cbc2e3c86d2cdf35aec6abd1d2a405 (diff)
Remove in main-thread gpu-thread support
This has not been working since 5.15. Task-number: QTBUG-71126 Change-Id: I04afed657a960cec9fc8782416c82fcb3de8de21 Reviewed-by: Michal Klocek <michal.klocek@qt.io>
-rw-r--r--src/core/CMakeLists.txt1
-rw-r--r--src/core/browser_main_parts_qt.cpp46
-rw-r--r--src/core/web_engine_context.cpp27
-rw-r--r--src/core/web_engine_context.h3
-rw-r--r--src/core/web_engine_context_threads.cpp102
5 files changed, 12 insertions, 167 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 0a8e937b1..993033b90 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -191,7 +191,6 @@ foreach(arch ${archs})
web_contents_delegate_qt.cpp web_contents_delegate_qt.h
web_contents_view_qt.cpp web_contents_view_qt.h
web_engine_context.cpp web_engine_context.h
- web_engine_context_threads.cpp
web_engine_error.cpp web_engine_error.h
web_engine_library_info.cpp web_engine_library_info.h
web_engine_settings.cpp web_engine_settings.h
diff --git a/src/core/browser_main_parts_qt.cpp b/src/core/browser_main_parts_qt.cpp
index 9cdce0eeb..a61319d36 100644
--- a/src/core/browser_main_parts_qt.cpp
+++ b/src/core/browser_main_parts_qt.cpp
@@ -146,55 +146,9 @@ private:
seqMan->controller_.get());
}
}
- // Both Qt and Chromium keep track of the current GL context by using
- // thread-local variables, and naturally they are completely unaware of each
- // other. As a result, when a QOpenGLContext is made current, the previous
- // gl::GLContext is not released, and vice-versa. This is fine as long as
- // each thread uses exclusively either Qt or Chromium GL bindings, which is
- // usually the case.
- //
- // The only exception is when the GL driver is considered thread-unsafe
- // (QOpenGLContext::supportsThreadedOpenGL() is false), in which case we
- // have to run all GL operations, including Chromium's GPU service, on the
- // UI thread. Now the bindings are being mixed and both Qt and Chromium get
- // quite confused regarding the current state of the surface.
- //
- // To get this to work we have to release the current QOpenGLContext before
- // executing any tasks from Chromium's GPU service and the gl::GLContext
- // afterwards. Since GPU service just posts tasks to the UI thread task
- // runner, we'll have to instrument the entire UI thread message pump.
- class ScopedGLContextChecker
- {
-#if QT_CONFIG(opengl)
- public:
- ScopedGLContextChecker()
- {
- if (!m_enabled)
- return;
-
- if (QOpenGLContext *context = QOpenGLContext::currentContext())
- context->doneCurrent();
- }
-
- ~ScopedGLContextChecker()
- {
- if (!m_enabled)
- return;
-
- if (gl::GLContext *context = gl::GLContext::GetCurrent())
- context->ReleaseCurrent(nullptr);
- }
-
- private:
- bool m_enabled = WebEngineContext::isGpuServiceOnUIThread();
-#endif // QT_CONFIG(opengl)
- };
-
void handleScheduledWork()
{
- ScopedGLContextChecker glContextChecker;
-
QDeadlineTimer timer(std::chrono::milliseconds(2));
base::MessagePump::Delegate::NextWorkInfo more_work_info = m_delegate->DoWork();
while (more_work_info.is_immediate() && !timer.hasExpired())
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 5d9dd7214..7887d0ce7 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -37,9 +37,12 @@
#include "components/web_cache/browser/web_cache_manager.h"
#include "content/app/mojo_ipc_support.h"
#include "content/browser/devtools/devtools_http_handler.h"
+#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/browser/scheduler/browser_task_executor.h"
#include "content/browser/startup_data_impl.h"
#include "content/browser/startup_helper.h"
+#include "content/browser/utility_process_host.h"
+#include "content/gpu/in_process_gpu_thread.h"
#include "content/public/app/content_main.h"
#include "content/public/app/content_main_runner.h"
#include "content/public/browser/browser_main_runner.h"
@@ -55,6 +58,8 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/main_function_params.h"
#include "content/public/common/network_service_util.h"
+#include "content/renderer/in_process_renderer_thread.h"
+#include "content/utility/in_process_utility_thread.h"
#include "gpu/command_buffer/service/gpu_switches.h"
#include "gpu/config/gpu_finch_features.h"
#include "media/audio/audio_manager.h"
@@ -303,13 +308,11 @@ static void logContext(const char *glType, base::CommandLine *cmd)
"Using Supported QSG Backend: %s\n"
"Using Software Dynamic GL: %s\n"
"Using Shared GL: %s\n"
- "Using Multithreaded OpenGL: %s\n\n"
"Init Parameters:\n %s",
glType, type, profile, sharedFormat.majorVersion(), sharedFormat.minorVersion(),
qUtf8Printable(QSGRhiSupport::instance()->rhiBackendName()),
usingSupportedSGBackend() ? "yes" : "no", usingSoftwareDynamicGL() ? "yes" : "no",
qt_gl_global_share_context() ? "yes" : "no",
- !WebEngineContext::isGpuServiceOnUIThread() ? "yes" : "no",
qPrintable(params.join(" ")));
#else
qCDebug(webEngineContextLog,
@@ -465,7 +468,6 @@ void WebEngineContext::destroy()
// on IO thread (triggered by ~BrowserMainRunner). But by that time the UI
// task runner is not working anymore so we need to do this earlier.
cleanupVizProcess();
- destroyGpuProcess();
// Flush the UI message loop before quitting.
flushMessages();
@@ -595,18 +597,6 @@ ProxyAuthentication WebEngineContext::qProxyNetworkAuthentication(QString host,
const static char kChromiumFlagsEnv[] = "QTWEBENGINE_CHROMIUM_FLAGS";
const static char kDisableSandboxEnv[] = "QTWEBENGINE_DISABLE_SANDBOX";
-const static char kDisableInProcGpuThread[] = "QTWEBENGINE_DISABLE_GPU_THREAD";
-
-// static
-bool WebEngineContext::isGpuServiceOnUIThread()
-{
- static bool threadedGpu =
-#if QT_CONFIG(opengl) && !defined(Q_OS_MACOS)
- QOpenGLContext::supportsThreadedOpenGL() &&
-#endif
- !qEnvironmentVariableIsSet(kDisableInProcGpuThread);
- return !threadedGpu;
-}
static void initializeFeatureList(base::CommandLine *commandLine, std::vector<std::string> enableFeatures, std::vector<std::string> disableFeatures)
{
@@ -947,6 +937,13 @@ bool WebEngineContext::closingDown()
return m_closingDown;
}
+void WebEngineContext::registerMainThreadFactories()
+{
+ content::UtilityProcessHost::RegisterUtilityMainThreadFactory(content::CreateInProcessUtilityThread);
+ content::RenderProcessHostImpl::RegisterRendererMainThreadFactory(content::CreateInProcessRendererThread);
+ content::RegisterGpuMainThreadFactory(content::CreateInProcessGpuThread);
+}
+
} // namespace
QT_BEGIN_NAMESPACE
diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h
index 5a2fd4c3e..50b080db1 100644
--- a/src/core/web_engine_context.h
+++ b/src/core/web_engine_context.h
@@ -84,8 +84,6 @@ public:
static base::CommandLine *initCommandLine(bool &useEmbeddedSwitches,
bool &enableGLSoftwareRendering);
- static bool isGpuServiceOnUIThread();
-
private:
friend class base::RefCounted<WebEngineContext>;
friend class ProfileAdapter;
@@ -93,7 +91,6 @@ private:
~WebEngineContext();
static void registerMainThreadFactories();
- static void destroyGpuProcess();
std::unique_ptr<base::RunLoop> m_runLoop;
std::unique_ptr<ContentMainDelegateQt> m_mainDelegate;
diff --git a/src/core/web_engine_context_threads.cpp b/src/core/web_engine_context_threads.cpp
deleted file mode 100644
index ce39b198b..000000000
--- a/src/core/web_engine_context_threads.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-
-#include "web_engine_context.h"
-
-#include "base/functional/bind.h"
-#include "base/task/thread_pool.h"
-#include "base/threading/platform_thread.h"
-#include "base/threading/thread_restrictions.h"
-#include "content/browser/gpu/gpu_main_thread_factory.h"
-#include "content/browser/renderer_host/render_process_host_impl.h"
-#include "content/browser/utility_process_host.h"
-#include "content/child/child_process.h"
-#include "content/gpu/gpu_child_thread.h"
-#include "content/gpu/in_process_gpu_thread.h"
-#include "content/public/browser/browser_task_traits.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/renderer/in_process_renderer_thread.h"
-#include "content/utility/in_process_utility_thread.h"
-#include "gpu/ipc/service/gpu_init.h"
-
-#include <memory>
-
-#include <QEventLoop>
-
-namespace QtWebEngineCore {
-
-struct GpuThreadControllerQt : content::GpuThreadController
-{
- GpuThreadControllerQt(const content::InProcessChildThreadParams &params, const gpu::GpuPreferences &gpuPreferences)
- {
- content::GetUIThreadTaskRunner({})->PostTask(
- FROM_HERE,
- base::BindOnce(&GpuThreadControllerQt::createGpuProcess, params, gpuPreferences));
- }
- ~GpuThreadControllerQt() override
- {
- content::GetUIThreadTaskRunner({})->PostTask(
- FROM_HERE,
- base::BindOnce(&GpuThreadControllerQt::destroyGpuProcess));
- }
-
- static void createGpuProcess(
- const content::InProcessChildThreadParams &params,
- const gpu::GpuPreferences &gpuPreferences)
- {
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- if (s_gpuProcessDestroyed)
- return;
-
- s_gpuProcess = std::make_unique<content::ChildProcess>(base::ThreadType::kDefault);
- auto gpuInit = std::make_unique<gpu::GpuInit>();
- gpuInit->InitializeInProcess(base::CommandLine::ForCurrentProcess(), gpuPreferences);
- auto childThread = new content::GpuChildThread(params, std::move(gpuInit));
- childThread->Init(base::TimeTicks::Now());
- s_gpuProcess->set_main_thread(childThread);
- }
-
- static void destroyGpuProcess()
- {
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- if (s_gpuProcessDestroyed)
- return;
-
- // viz::GpuServiceImpl::~GpuServiceImpl waits for io task.
- base::ScopedAllowBaseSyncPrimitivesForTesting allow;
- s_gpuProcess.reset();
- s_gpuProcessDestroyed = true;
- }
-
- static std::unique_ptr<content::ChildProcess> s_gpuProcess;
- static bool s_gpuProcessDestroyed;
-};
-
-std::unique_ptr<content::ChildProcess> GpuThreadControllerQt::s_gpuProcess;
-bool GpuThreadControllerQt::s_gpuProcessDestroyed = false;
-
-static std::unique_ptr<content::GpuThreadController> createGpuThreadController(
- const content::InProcessChildThreadParams &params,
- const gpu::GpuPreferences &gpuPreferences)
-{
- return std::make_unique<GpuThreadControllerQt>(params, gpuPreferences);
-}
-
-// static
-void WebEngineContext::destroyGpuProcess()
-{
- GpuThreadControllerQt::destroyGpuProcess();
-}
-
-// static
-void WebEngineContext::registerMainThreadFactories()
-{
- content::UtilityProcessHost::RegisterUtilityMainThreadFactory(content::CreateInProcessUtilityThread);
- content::RenderProcessHostImpl::RegisterRendererMainThreadFactory(content::CreateInProcessRendererThread);
- if (!isGpuServiceOnUIThread())
- content::RegisterGpuMainThreadFactory(content::CreateInProcessGpuThread);
- else
- content::RegisterGpuMainThreadFactory(createGpuThreadController);
-}
-
-} // namespace QtWebEngineCore