Fix race with multi-threaded message loop (fixes issue #2668).

Remove the local thread object in favor of setting the ui_thread_ field
directly. This avoids the race between ui_thread_.swap(thread) and
CefUIThread::InitializeBrowserRunner.
This commit is contained in:
Isaac Devine 2019-07-16 21:42:35 +00:00 committed by Marshall Greenblatt
parent 17ec55a3b3
commit 1086495096
1 changed files with 3 additions and 5 deletions

View File

@ -723,11 +723,9 @@ int CefMainDelegate::RunProcess(
bool CefMainDelegate::CreateUIThread(base::OnceClosure setup_callback) {
DCHECK(!ui_thread_);
std::unique_ptr<CefUIThread> thread;
thread.reset(new CefUIThread(std::move(setup_callback)));
thread->Start();
thread->WaitUntilThreadStarted();
ui_thread_.swap(thread);
ui_thread_.reset(new CefUIThread(std::move(setup_callback)));
ui_thread_->Start();
ui_thread_->WaitUntilThreadStarted();
InitMessagePumpFactoryForUI();
return true;