From 2de07250dc6c25ccb5484f25002450afb164782b Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 29 Apr 2021 17:07:36 -0400 Subject: [PATCH] Restore async CreateBrowser behavior (fixes issue #3116, fixes issue #3118) Restore the async CreateBrowser behavior that existed prior to commit 691c9c2 because executing synchronously (for example, from inside OnContextInitialized) causes issues on MacOS and possibly other platforms. --- libcef/browser/browser_host_create.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libcef/browser/browser_host_create.cc b/libcef/browser/browser_host_create.cc index a6db29f72..f9aa59076 100644 --- a/libcef/browser/browser_host_create.cc +++ b/libcef/browser/browser_host_create.cc @@ -88,7 +88,12 @@ bool CefBrowserHost::CreateBrowser( // Wait for the browser context to be initialized before creating the browser. request_context_impl->ExecuteWhenBrowserContextInitialized(base::BindOnce( - [](std::unique_ptr helper) { helper->Run(); }, + [](std::unique_ptr helper) { + // Always execute asynchronously to avoid potential issues if we're + // being called synchronously during app initialization. + CEF_POST_TASK(CEF_UIT, base::BindOnce(&CreateBrowserHelper::Run, + std::move(helper))); + }, std::move(helper))); return true;