mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Split UI thread shutdown into before and after stages (see #3609)
Existing UI thread shutdown tasks need to be executed before the UI thread RunLoop is terminated. Those tasks have now been moved to CefMainRunner::StartShutdownOnUIThread and FinishShutdownOnUIThread is now called after the RunLoop is terminated. This fixes a shutdown crash in ChromeProcessSingleton::DeleteInstance. DeleteInstance needs to be called on the UI thread near the end of the shutdown process (after ChromeProcessSingleton::Cleanup is called via PostMainMessageLoopRun).
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "base/run_loop.h"
|
||||
#include "chrome/browser/browser_process_impl.h"
|
||||
#include "chrome/browser/chrome_content_browser_client.h"
|
||||
#include "chrome/browser/chrome_process_singleton.h"
|
||||
#include "chrome/common/profiler/main_thread_stack_sampling_profiler.h"
|
||||
#include "components/keep_alive_registry/keep_alive_types.h"
|
||||
#include "components/keep_alive_registry/scoped_keep_alive.h"
|
||||
@@ -46,6 +47,8 @@ void ChromeMainRunnerDelegate::BeforeMainThreadInitialize(
|
||||
void ChromeMainRunnerDelegate::BeforeMainThreadRun(
|
||||
bool multi_threaded_message_loop) {
|
||||
if (multi_threaded_message_loop) {
|
||||
multi_threaded_message_loop_ = true;
|
||||
|
||||
// Detach from the main thread so that these objects can be attached and
|
||||
// modified from the UI thread going forward.
|
||||
metrics::GlobalPersistentSystemProfile::GetInstance()
|
||||
@@ -83,7 +86,7 @@ void ChromeMainRunnerDelegate::BeforeUIThreadInitialize() {
|
||||
sampling_profiler_ = std::make_unique<MainThreadStackSamplingProfiler>();
|
||||
}
|
||||
|
||||
void ChromeMainRunnerDelegate::AfterUIThreadShutdown() {
|
||||
void ChromeMainRunnerDelegate::BeforeUIThreadShutdown() {
|
||||
static_cast<ChromeContentBrowserClient*>(
|
||||
CefAppManager::Get()->GetContentClient()->browser())
|
||||
->CleanupOnUIThread();
|
||||
@@ -92,6 +95,14 @@ void ChromeMainRunnerDelegate::AfterUIThreadShutdown() {
|
||||
sampling_profiler_.reset();
|
||||
}
|
||||
|
||||
void ChromeMainRunnerDelegate::AfterUIThreadShutdown() {
|
||||
if (multi_threaded_message_loop_) {
|
||||
// Don't wait for this to be called in ChromeMainDelegate::ProcessExiting.
|
||||
// It is safe to call multiple times.
|
||||
ChromeProcessSingleton::DeleteInstance();
|
||||
}
|
||||
}
|
||||
|
||||
void ChromeMainRunnerDelegate::BeforeExecuteProcess(const CefMainArgs& args) {
|
||||
BeforeMainThreadInitialize(args);
|
||||
}
|
||||
|
Reference in New Issue
Block a user