chrome: Fix shutdown crashes with multi-threaded-message-loop (fixes issue #3403)

This commit is contained in:
Marshall Greenblatt
2022-09-29 12:37:59 -04:00
parent 4d1fd05740
commit 4e43f90244
3 changed files with 58 additions and 8 deletions

View File

@@ -15,8 +15,10 @@
#include "libcef/common/resource_util.h"
#include "libcef/renderer/chrome/chrome_content_renderer_client_cef.h"
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/lazy_instance.h"
#include "base/threading/threading_features.h"
#include "chrome/common/chrome_switches.h"
#include "components/embedder_support/switches.h"
#include "content/public/common/content_switches.h"
@@ -124,6 +126,29 @@ absl::optional<int> ChromeMainDelegateCef::BasicStartupComplete() {
switches::kUncaughtExceptionStackSize,
base::NumberToString(settings_->uncaught_exception_stack_size));
}
std::vector<std::string> disable_features;
if (!!settings_->multi_threaded_message_loop &&
base::kEnableHangWatcher.default_state ==
base::FEATURE_ENABLED_BY_DEFAULT) {
// Disable EnableHangWatcher when running with multi-threaded-message-loop
// to avoid shutdown crashes (see issue #3403).
disable_features.push_back(base::kEnableHangWatcher.name);
}
if (!disable_features.empty()) {
DCHECK(!base::FeatureList::GetInstance());
std::string disable_features_str =
command_line->GetSwitchValueASCII(switches::kDisableFeatures);
for (auto feature_str : disable_features) {
if (!disable_features_str.empty())
disable_features_str += ",";
disable_features_str += feature_str;
}
command_line->AppendSwitchASCII(switches::kDisableFeatures,
disable_features_str);
}
}
if (application_) {

View File

@@ -74,6 +74,7 @@ void ChromeMainRunnerDelegate::AfterUIThreadShutdown() {
static_cast<ChromeContentBrowserClient*>(
CefAppManager::Get()->GetContentClient()->browser())
->CleanupOnUIThread();
main_delegate_->CleanupOnUIThread();
}
void ChromeMainRunnerDelegate::AfterMainThreadShutdown() {