Commit b33fd39c authored by kylechar's avatar kylechar Committed by Commit Bot

Revert Ozone initialization changes.

This reverts most of commit a51e3935.
The thread configuration for --enable-features=Mus doesn't exist anymore
and fixing mus introduced a different race for the non-mus configuration.
Since mus is no longer the plan of record, revert the initialization
order changes but keep logging and code cleanup.

Bug: 840474
Change-Id: Ifec0e3dd9601e3895d0549109be5d10387f3b8b4
Reviewed-on: https://chromium-review.googlesource.com/1101139Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Commit-Queue: kylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567794}
parent 5fe8d6b2
......@@ -115,8 +115,7 @@ void DrmGpuPlatformSupportHost::RemoveGpuThreadObserver(
}
bool DrmGpuPlatformSupportHost::IsConnected() {
base::AutoLock auto_lock(host_id_lock_);
return host_id_ >= 0;
return host_id_ >= 0 && channel_established_;
}
void DrmGpuPlatformSupportHost::OnGpuServiceLaunched(
......@@ -140,23 +139,27 @@ void DrmGpuPlatformSupportHost::OnGpuProcessLaunched(
DCHECK(!ui_runner_->BelongsToCurrentThread());
TRACE_EVENT1("drm", "DrmGpuPlatformSupportHost::OnGpuProcessLaunched",
"host_id", host_id);
host_id_ = host_id;
send_runner_ = std::move(send_runner);
send_callback_ = send_callback;
for (GpuThreadObserver& observer : gpu_thread_observers_)
observer.OnGpuProcessLaunched();
ui_runner_->PostTask(
FROM_HERE,
base::BindOnce(&DrmGpuPlatformSupportHost::OnChannelEstablished,
weak_ptr_, host_id, std::move(send_runner),
std::move(send_callback)));
weak_ptr_));
}
void DrmGpuPlatformSupportHost::OnChannelDestroyed(int host_id) {
TRACE_EVENT1("drm", "DrmGpuPlatformSupportHost::OnChannelDestroyed",
"host_id", host_id);
if (host_id_ == host_id) {
{
base::AutoLock auto_lock(host_id_lock_);
host_id_ = -1;
}
cursor_->ResetDrmCursorProxy();
host_id_ = -1;
channel_established_ = false;
send_runner_ = nullptr;
send_callback_.Reset();
for (GpuThreadObserver& observer : gpu_thread_observers_)
......@@ -197,22 +200,9 @@ void DrmGpuPlatformSupportHost::UnRegisterHandlerForDrmDisplayHostManager() {
display_manager_ = nullptr;
}
void DrmGpuPlatformSupportHost::OnChannelEstablished(
int host_id,
scoped_refptr<base::SingleThreadTaskRunner> send_runner,
const base::Callback<void(IPC::Message*)>& send_callback) {
DCHECK(ui_runner_->BelongsToCurrentThread());
void DrmGpuPlatformSupportHost::OnChannelEstablished() {
TRACE_EVENT0("drm", "DrmGpuPlatformSupportHost::OnChannelEstablished");
send_runner_ = std::move(send_runner);
send_callback_ = send_callback;
{
base::AutoLock auto_lock(host_id_lock_);
host_id_ = host_id;
}
for (GpuThreadObserver& observer : gpu_thread_observers_)
observer.OnGpuProcessLaunched();
channel_established_ = true;
for (GpuThreadObserver& observer : gpu_thread_observers_)
observer.OnGpuThreadReady();
......@@ -288,8 +278,22 @@ bool DrmGpuPlatformSupportHost::GpuRelinquishDisplayControl() {
bool DrmGpuPlatformSupportHost::GpuAddGraphicsDevice(const base::FilePath& path,
base::ScopedFD fd) {
return Send(new OzoneGpuMsg_AddGraphicsDevice(
path, base::FileDescriptor(std::move(fd))));
IPC::Message* message = new OzoneGpuMsg_AddGraphicsDevice(
path, base::FileDescriptor(std::move(fd)));
// This function may be called from two places:
// - DrmDisplayHostManager::OnGpuProcessLaunched() invoked synchronously
// by GpuProcessHost::Init() on IO thread, which is the same thread as
// |send_runner_|. In this case we can synchronously send the IPC;
// - DrmDisplayHostManager::OnAddGraphicsDevice() on UI thread. In this
// case we need to post the send task to IO thread.
if (send_runner_ && send_runner_->BelongsToCurrentThread()) {
DCHECK(!send_callback_.is_null());
send_callback_.Run(message);
return true;
}
return Send(message);
}
bool DrmGpuPlatformSupportHost::GpuRemoveGraphicsDevice(
......
......@@ -10,7 +10,6 @@
#include "base/callback.h"
#include "base/observer_list.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/lock.h"
#include "ui/display/types/display_constants.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
......@@ -101,10 +100,7 @@ class DrmGpuPlatformSupportHost : public GpuPlatformSupportHost,
const gfx::Rect& bounds) override;
private:
void OnChannelEstablished(
int host_id,
scoped_refptr<base::SingleThreadTaskRunner> send_runner,
const base::Callback<void(IPC::Message*)>& send_callback);
void OnChannelEstablished();
bool OnMessageReceivedForDrmDisplayHostManager(const IPC::Message& message);
void OnUpdateNativeDisplays(
const std::vector<DisplaySnapshot_Params>& displays);
......@@ -122,7 +118,7 @@ class DrmGpuPlatformSupportHost : public GpuPlatformSupportHost,
const std::vector<OverlayCheckReturn_Params>& returns);
int host_id_ = -1;
base::Lock host_id_lock_;
bool channel_established_ = false;
scoped_refptr<base::SingleThreadTaskRunner> ui_runner_;
scoped_refptr<base::SingleThreadTaskRunner> send_runner_;
......
......@@ -7,19 +7,20 @@
namespace ui {
// Observes the channel state. All calls should happen on the same thread that
// OzonePlatform::InitializeForUI() is called on. This can be the browser UI
// thread or the WS thread for mus/mash.
// Observes the channel state.
class GpuThreadObserver {
public:
virtual ~GpuThreadObserver() {}
// Called when the GPU process is launched.
// This is called from browser IO thread.
virtual void OnGpuProcessLaunched() = 0;
// Called when a GPU thread implementation has become available.
// This is called from browser UI thread.
virtual void OnGpuThreadReady() = 0;
// Called when the GPU thread implementation has ceased to be
// available.
// This is called from browser UI thread.
virtual void OnGpuThreadRetired() = 0;
};
......
......@@ -42,11 +42,8 @@ void OzonePlatform::InitializeForUI(const InitParams& args) {
EnsureInstance();
if (g_platform_initialized_ui)
return;
g_platform_initialized_ui = true;
instance_->InitializeUI(args);
{
base::AutoLock lock(GetOzoneInstanceLock());
g_platform_initialized_ui = true;
}
// This is deliberately created after initializing so that the platform can
// create its own version of DDM.
DeviceDataManager::CreateInstance();
......@@ -59,11 +56,8 @@ void OzonePlatform::InitializeForGPU(const InitParams& args) {
EnsureInstance();
if (g_platform_initialized_gpu)
return;
g_platform_initialized_gpu = true;
instance_->InitializeGPU(args);
{
base::AutoLock lock(GetOzoneInstanceLock());
g_platform_initialized_gpu = true;
}
if (!args.single_process && !instance_callback.Get().is_null())
std::move(instance_callback.Get()).Run(instance_);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment