summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2018-12-13 15:05:55 +0100
committerMichal Klocek <michal.klocek@qt.io>2019-01-23 08:54:32 +0000
commit46a14a39dc74d8e5b4efe1b5ceeb0c09d6436885 (patch)
treeb6d882bc20b3b1d93b3b3fb6803f45115f81f412
parent0deb1ffda77f0410b3d13419856c757cdd422d2b (diff)
Fix crash on exit with single process
Shutting down the browser runner in single process mode requires the browser context to be present. Moreover single mode does not support multi browser context. For single mode move profile destruction to PostMainMessageLoopRun. Fixes: QTBUG-45722 Change-Id: I15b5aa17061b4dd7898d0ff9427fada44d2eff74 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Kirill Burtsev <kirill.burtsev@qt.io>
-rw-r--r--src/core/web_engine_context.cpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index aee5be42f..ca52a5e67 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -63,6 +63,7 @@
#include "content/public/browser/browser_main_runner.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.h"
@@ -185,8 +186,12 @@ bool WebEngineContext::m_destroyed = false;
void WebEngineContext::destroyProfileAdapter()
{
- if (m_defaultProfileAdapter)
- qWarning("PostMainMessageLoopRun is done, but global profile still exists !");
+ if (content::RenderProcessHost::run_renderer_in_process()) {
+ Q_ASSERT(m_profileAdapters.count() == 1);
+ // this might be default profile
+ m_defaultProfileAdapter.release();
+ delete m_profileAdapters.first();
+ }
}
void WebEngineContext::addProfileAdapter(ProfileAdapter *profileAdapter)
@@ -202,6 +207,11 @@ void WebEngineContext::addProfileAdapter(ProfileAdapter *profileAdapter)
}
}
}
+
+ if (content::RenderProcessHost::run_renderer_in_process() &&
+ !m_profileAdapters.isEmpty()) {
+ qFatal("Single mode supports only single profile.");
+ }
m_profileAdapters.append(profileAdapter);
}
@@ -225,21 +235,27 @@ void WebEngineContext::destroy()
#endif
// Delete the global object and thus custom profiles
- m_defaultProfileAdapter.reset();
- m_globalQObject.reset();
- while (m_profileAdapters.count())
- delete m_profileAdapters.first();
+ // In case of single process ~RenderProcessHostImpl (there is only one instance)
+ // is called expliclty by BrowserMainLoop::ShutdownThreadsAndCleanUp and requires browser context.
+ // therefore delete browser context on PostMainMessageLoopRun.
+ if (!content::RenderProcessHost::run_renderer_in_process()) {
+ m_defaultProfileAdapter.reset();
+ m_globalQObject.reset();
+ while (m_profileAdapters.count())
+ delete m_profileAdapters.first();
+ } else {
+ m_globalQObject.reset();
+ }
// Handle any events posted by browser-context shutdown.
+ // This should deliver all nessesery calls of DeleteSoon from PostTask
while (delegate->DoWork()) { }
GLContextHelper::destroy();
m_devtoolsServer.reset();
m_runLoop->AfterRun();
- // Fixme: Force to destroy RenderProcessHostImpl by destroying BrowserMainRunner.
- // RenderProcessHostImpl should be destroyed before WebEngineContext since
- // default BrowserContext might be used by the RenderprocessHostImpl's destructor.
+ // Destroy the main runner, this stops main message loop
m_browserRunner.reset();
// Destroying content-runner will force Chromium at_exit calls to run, and