Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: crash using powerMonitor before ready event #40888

Merged
merged 2 commits into from Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions shell/browser/electron_browser_main_parts.cc
Expand Up @@ -81,7 +81,8 @@
#include "base/environment.h"
#include "chrome/browser/ui/views/dark_mode_manager_linux.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
#include "device/bluetooth/dbus/dbus_bluez_manager_wrapper_linux.h"
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
#include "device/bluetooth/dbus/bluez_dbus_thread_manager.h"
#include "electron/electron_gtk_stubs.h"
#include "ui/base/cursor/cursor_factory.h"
#include "ui/base/ime/linux/linux_input_method_context_factory.h"
Expand Down Expand Up @@ -386,7 +387,8 @@ void ElectronBrowserMainParts::PostDestroyThreads() {
#endif
#if BUILDFLAG(IS_LINUX)
device::BluetoothAdapterFactory::Shutdown();
bluez::DBusBluezManagerWrapperLinux::Shutdown();
bluez::BluezDBusManager::Shutdown();
bluez::BluezDBusThreadManager::Shutdown();
#endif
fake_browser_process_->PostDestroyThreads();
}
Expand Down Expand Up @@ -508,7 +510,8 @@ void ElectronBrowserMainParts::PostCreateMainMessageLoop() {
ui::OzonePlatform::GetInstance()->PostCreateMainMessageLoop(
std::move(shutdown_cb),
content::GetUIThreadTaskRunner({content::BrowserTaskType::kUserInput}));
bluez::DBusBluezManagerWrapperLinux::Initialize();
if (!bluez::BluezDBusManager::IsInitialized())
bluez::BluezDBusManager::Initialize(nullptr /* system_bus */);

// Set up crypt config. This needs to be done before anything starts the
// network service, as the raw encryption key needs to be shared with the
Expand Down
4 changes: 4 additions & 0 deletions shell/browser/lib/power_observer_linux.cc
Expand Up @@ -11,6 +11,7 @@
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
#include "device/bluetooth/dbus/bluez_dbus_thread_manager.h"

namespace {
Expand All @@ -34,6 +35,9 @@ PowerObserverLinux::PowerObserverLinux(
base::PowerSuspendObserver* suspend_observer)
: suspend_observer_(suspend_observer),
lock_owner_name_(GetExecutableBaseName()) {
if (!bluez::BluezDBusManager::IsInitialized())
bluez::BluezDBusManager::Initialize(nullptr /* system bus */);

auto* bus = bluez::BluezDBusThreadManager::Get()->GetSystemBus();
if (!bus) {
LOG(WARNING) << "Failed to get system bus connection";
Expand Down