From c226de32dc905fddbed248cc31e55f375115454a Mon Sep 17 00:00:00 2001 From: Maksim Sisov Date: Mon, 1 Oct 2018 10:38:57 +0300 Subject: [PATCH] [ozone/wayland] Use PlatformProperties to know if mojo is required Do not rely on the OzoneDrmMojo and avoid messing up with it as long as it usually brings problems rather than fixes. Thus, use PlatformProperties to know if Wayland requires mojo communication before the gpu is started. --- components/viz/host/gpu_host_impl.cc | 7 ++++++- gpu/ipc/service/gpu_init.cc | 8 ++++++-- .../platform/wayland/ozone_platform_wayland.cc | 18 ++++++------------ ui/ozone/public/ozone_platform.cc | 2 ++ ui/ozone/public/ozone_platform.h | 5 +++++ 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/components/viz/host/gpu_host_impl.cc b/components/viz/host/gpu_host_impl.cc index 4adb13f4a646e..41a863bea68c1 100644 --- a/components/viz/host/gpu_host_impl.cc +++ b/components/viz/host/gpu_host_impl.cc @@ -293,7 +293,12 @@ void GpuHostImpl::InitOzone() { // https://crbug.com/608839 // If the OzonePlatform is not created yet, defer the callback until // OzonePlatform instance is created. - if (features::IsOzoneDrmMojo()) { + // + // The Ozone/Wayland requires mojo communication to be established to be + // functional with a separate gpu process. Thus, using the PlatformProperties, + // check if there is such a requirement. + if (features::IsOzoneDrmMojo() || + ui::OzonePlatform::GetInstance()->GetPlatformProperties().requires_mojo) { // TODO(rjkroege): Remove the legacy IPC code paths when no longer // necessary. https://crbug.com/806092 auto interface_binder = base::BindRepeating(&GpuHostImpl::BindInterface, diff --git a/gpu/ipc/service/gpu_init.cc b/gpu/ipc/service/gpu_init.cc index 20c237fc35000..3d573e85dc63f 100644 --- a/gpu/ipc/service/gpu_init.cc +++ b/gpu/ipc/service/gpu_init.cc @@ -204,7 +204,9 @@ bool GpuInit::InitializeAndStartSandbox(base::CommandLine* command_line, // may also have started at this point. ui::OzonePlatform::InitParams params; params.single_process = false; - params.using_mojo = features::IsOzoneDrmMojo(); + params.using_mojo = + features::IsOzoneDrmMojo() | + ui::OzonePlatform::GetInstance()->GetPlatformProperties().requires_mojo; ui::OzonePlatform::InitializeForGPU(params); #endif @@ -365,7 +367,9 @@ void GpuInit::InitializeInProcess(base::CommandLine* command_line, #if defined(USE_OZONE) ui::OzonePlatform::InitParams params; params.single_process = true; - params.using_mojo = features::IsOzoneDrmMojo(); + params.using_mojo = + features::IsOzoneDrmMojo() || + ui::OzonePlatform::GetInstance()->GetPlatformProperties().requires_mojo; ui::OzonePlatform::InitializeForGPU(params); ui::OzonePlatform::GetInstance()->AfterSandboxEntry(); #endif diff --git a/ui/ozone/platform/wayland/ozone_platform_wayland.cc b/ui/ozone/platform/wayland/ozone_platform_wayland.cc index 8074471015882..ddddd8615275c 100644 --- a/ui/ozone/platform/wayland/ozone_platform_wayland.cc +++ b/ui/ozone/platform/wayland/ozone_platform_wayland.cc @@ -52,6 +52,10 @@ class OzonePlatformWayland : public OzonePlatform { // https://github.com/wayland-project/wayland-protocols/commit/76d1ae8c65739eff3434ef219c58a913ad34e988 properties_.custom_frame_pref_default = true; properties_.use_system_title_bar = false; + // Ozone/Wayland relies on the mojo communication when running in + // !single_process. + // TODO(msisov, rjkroege): Remove after http://crbug.com/806092. + properties_.requires_mojo = true; } ~OzonePlatformWayland() override {} @@ -124,17 +128,8 @@ class OzonePlatformWayland : public OzonePlatform { LOG(FATAL) << "Failed to initialize Wayland platform"; #if defined(WAYLAND_GBM) - if (!args.single_process) { - if (!features::IsOzoneDrmMojo()) { - // Override kEnableOzoneDrmMojo to the enabled state, because - // Ozone/Wayland relies on the mojo communication when running in - // !single_process. - // TODO(msisov, rjkroege): Remove after http://crbug.com/806092. - base::FeatureList::GetInstance()->InitializeFromCommandLine( - features::kEnableOzoneDrmMojo.name, std::string()); - } + if (!args.single_process) connector_.reset(new WaylandConnectionConnector(connection_.get())); - } #endif cursor_factory_.reset(new BitmapCursorFactoryOzone); @@ -169,8 +164,7 @@ class OzonePlatformWayland : public OzonePlatform { } const PlatformProperties& GetPlatformProperties() override { - DCHECK(connection_.get()); - if (properties_.supported_buffer_formats.empty()) { + if (connection_ && properties_.supported_buffer_formats.empty()) { properties_.supported_buffer_formats = connection_->GetSupportedBufferFormats(); } diff --git a/ui/ozone/public/ozone_platform.cc b/ui/ozone/public/ozone_platform.cc index aae41ff19efbd..ec543bc9c1088 100644 --- a/ui/ozone/public/ozone_platform.cc +++ b/ui/ozone/public/ozone_platform.cc @@ -41,10 +41,12 @@ OzonePlatform::PlatformProperties::PlatformProperties( bool needs_request, bool custom_frame_default, bool can_use_system_title_bar, + bool requires_mojo_for_ipc, std::vector buffer_formats) : needs_view_owner_request(needs_request), custom_frame_pref_default(custom_frame_default), use_system_title_bar(can_use_system_title_bar), + requires_mojo(requires_mojo_for_ipc), supported_buffer_formats(buffer_formats) {} OzonePlatform::PlatformProperties::~PlatformProperties() = default; diff --git a/ui/ozone/public/ozone_platform.h b/ui/ozone/public/ozone_platform.h index da9f46aa764e5..f1058530501d2 100644 --- a/ui/ozone/public/ozone_platform.h +++ b/ui/ozone/public/ozone_platform.h @@ -91,6 +91,7 @@ class OZONE_EXPORT OzonePlatform { PlatformProperties(bool needs_request, bool custom_frame_default, bool can_use_system_title_bar, + bool requires_mojo_for_ipc, std::vector buffer_formats); ~PlatformProperties(); PlatformProperties(const PlatformProperties& other); @@ -108,6 +109,10 @@ class OZONE_EXPORT OzonePlatform { // supported. bool use_system_title_bar = false; + // Determines if the platform requires mojo communication for the IPC. + // Currently used only by the Ozone/Wayland platform. + bool requires_mojo = false; + // Wayland only: carries buffer formats supported by a Wayland server. std::vector supported_buffer_formats; };