From 0fe9c7803463f12c6ceea74dec42fb66c27b838f Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 27 Feb 2020 13:09:46 +0100 Subject: Fix deadlocks on WebEngineContext destruction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch aims to handle 3 deadlocks on exit: (1) Do not attempt to restart Viz thread on shutdown, this will make deadlock with no separate gpu thread, since force shut down of FrameSinkManager requires interaction with gpu process. (2) QCoreApplication, QGuiApplication, QApplication behave differently when doing qt post routine, ~QGuiApplication calls the post routine handler after closing event dispatcher, which will on windows stop processing timer events, which we need to pump message loop when shuting down viz. Do not use QEventLoop and switch to active pulling. The proper solution is to fix QGuiApplication destructor to call post routine first, but this change might have side effects on already existing user code. (3) Since 7f1649b438329e we delete root frame sink asynchronously, which will in gpu thread running in separate thread create a deadlock. Viz requires gpu to destruct root frame sink, however if main process tries to close gpu process this will in turn try close viz, but viz calls back gpu now since the root frame sink is not destroyed. Use the same solution as in (1). Change-Id: Ic6bc904bdac90ee01a5c5b9398a2e2746be3bbd8 Reviewed-by: Jüri Valdmann --- src/core/web_engine_context_threads.cpp | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'src/core/web_engine_context_threads.cpp') diff --git a/src/core/web_engine_context_threads.cpp b/src/core/web_engine_context_threads.cpp index f0f055676..c7440dd3f 100644 --- a/src/core/web_engine_context_threads.cpp +++ b/src/core/web_engine_context_threads.cpp @@ -92,20 +92,6 @@ struct GpuThreadControllerQt : content::GpuThreadController s_gpuProcess->set_main_thread(childThread); } - static void cleanupVizProcess() - { - auto gpuChildThread = content::GpuChildThread::instance(); - if (!gpuChildThread) - return; - auto vizMain = gpuChildThread->viz_main(); - auto vizCompositorThreadRunner = vizMain->viz_compositor_thread_runner(); - if (!vizCompositorThreadRunner) - return; - QEventLoop loop; - vizCompositorThreadRunner->CleanupForShutdown(base::BindOnce(&QEventLoop::quit, base::Unretained(&loop))); - loop.exec(); - } - static void destroyGpuProcess() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); @@ -133,10 +119,8 @@ static std::unique_ptr createGpuThreadController( } // static -void WebEngineContext::destroyGpuProcess(bool threaded) +void WebEngineContext::destroyGpuProcess() { - if (!threaded) - GpuThreadControllerQt::cleanupVizProcess(); GpuThreadControllerQt::destroyGpuProcess(); } -- cgit v1.2.3