Commit 2e064349 authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

[ozone/wayland] Use PlatformProperties to know if mojo is required.

Relying on OzoneDrmMojo feature is not a very good idea, because
it is mostly intended to be used with the Ozone/Drm platform, which can use both
the legacy IPC and mojo for communication. It happened once that the
Ozone/Wayland platform regressed due to misunderstandings why that
feature flag was used with ifdefs.

In Ozone/Wayland, the mojo IPC is a requirement to be able to run
the browser in a multi-process mode(there is a separate GPU process).
Thus, use PlatformProperties to know if the platform requires mojo communication
before the gpu is started. At the moment, only Ozone/Wayland
platform requires mojo communication in addition to the Ozone/Drm
platform, which can use both legacy IPC and mojo and uses OzoneDrmMojo
feature instead.

Bug: 578890
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I1f0fccb19ec2fc69a50320b55014979556739c2c
Reviewed-on: https://chromium-review.googlesource.com/c/1254209
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Reviewed-by: default avatarEric Karl <ericrk@chromium.org>
Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596174}
parent 1bda9733
......@@ -293,7 +293,13 @@ 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::EnsureInstance()
->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,
......
......@@ -204,7 +204,10 @@ 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::EnsureInstance()
->GetPlatformProperties()
.requires_mojo;
ui::OzonePlatform::InitializeForGPU(params);
#endif
......@@ -365,7 +368,10 @@ 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::EnsureInstance()
->GetPlatformProperties()
.requires_mojo;
ui::OzonePlatform::InitializeForGPU(params);
ui::OzonePlatform::GetInstance()->AfterSandboxEntry();
#endif
......
......@@ -33,6 +33,7 @@ const OzonePlatform::PlatformProperties kScenicPlatformProperties(
/*needs_view_owner_request=*/true,
/*custom_frame_pref_default=*/false,
/*use_system_title_bar=*/false,
/*requires_mojo=*/false,
std::vector<gfx::BufferFormat>());
class ScenicPlatformEventSource : public ui::PlatformEventSource {
......
......@@ -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();
}
......
......@@ -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<gfx::BufferFormat> 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;
......
......@@ -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<gfx::BufferFormat> 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<gfx::BufferFormat> supported_buffer_formats;
};
......
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