Commit f42fa3f3 authored by Brian Ho's avatar Brian Ho Committed by Chromium LUCI CQ

exo: Advertise bug fix IDs on binding zaura_shell

Currently, fixing exo bugs for Lacros is cumbersome due to version
skew between Lacros/ash. In a single CL, we ideally want to 1) land
an exo fix and 2) land a conditional workaround in Lacros until ash
is uprevved to actually include the exo fix (see the bug for a real
world example).

To remedy this, this CL introduces a new |bug_fix| event that sends
down IDs of bug fixes present in exo when the zaura_shell is bound.
Clients (notably |ui::WaylandZAuraShell|) can listen for this event
and gate features on the presence of certain bug fixes by calling
|WaylandZAuraShell::HasBugFix(bug_id)|.

Bug: 1151508
Change-Id: Iec39e32c4b507545aaf59c0a73f3fa61f9a7e3ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2568204
Commit-Queue: Brian Ho <hob@chromium.org>
Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837086}
parent 7553a2c4
...@@ -141,7 +141,7 @@ void RegistryHandler(void* data, ...@@ -141,7 +141,7 @@ void RegistryHandler(void* data,
wl_registry_bind(registry, id, &wp_presentation_interface, 1))); wl_registry_bind(registry, id, &wp_presentation_interface, 1)));
} else if (strcmp(interface, "zaura_shell") == 0) { } else if (strcmp(interface, "zaura_shell") == 0) {
globals->aura_shell.reset(static_cast<zaura_shell*>( globals->aura_shell.reset(static_cast<zaura_shell*>(
wl_registry_bind(registry, id, &zaura_shell_interface, 7))); wl_registry_bind(registry, id, &zaura_shell_interface, 14)));
} else if (strcmp(interface, "zwp_linux_dmabuf_v1") == 0) { } else if (strcmp(interface, "zwp_linux_dmabuf_v1") == 0) {
globals->linux_dmabuf.reset(static_cast<zwp_linux_dmabuf_v1*>( globals->linux_dmabuf.reset(static_cast<zwp_linux_dmabuf_v1*>(
wl_registry_bind(registry, id, &zwp_linux_dmabuf_v1_interface, 2))); wl_registry_bind(registry, id, &zwp_linux_dmabuf_v1_interface, 2)));
...@@ -626,6 +626,15 @@ bool ClientBase::Init(const InitParams& params) { ...@@ -626,6 +626,15 @@ bool ClientBase::Init(const InitParams& params) {
LOG(ERROR) << "Can't find aura shell interface"; LOG(ERROR) << "Can't find aura shell interface";
return false; return false;
} }
static zaura_shell_listener kAuraShellListener = {
[](void* data, struct zaura_shell* zaura_shell, uint32_t layout_mode) {
},
[](void* data, struct zaura_shell* zaura_shell, uint32_t id) {
CastToClientBase(data)->bug_fix_ids_.insert(id);
}};
zaura_shell_add_listener(globals_.aura_shell.get(), &kAuraShellListener,
this);
std::unique_ptr<wl_shell_surface> shell_surface( std::unique_ptr<wl_shell_surface> shell_surface(
static_cast<wl_shell_surface*>( static_cast<wl_shell_surface*>(
wl_shell_get_shell_surface(globals_.shell.get(), surface_.get()))); wl_shell_get_shell_surface(globals_.shell.get(), surface_.get())));
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "base/containers/flat_set.h"
#include "base/memory/shared_memory_mapping.h" #include "base/memory/shared_memory_mapping.h"
#include "components/exo/wayland/clients/client_helper.h" #include "components/exo/wayland/clients/client_helper.h"
#include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkCanvas.h"
...@@ -215,6 +216,7 @@ class ClientBase { ...@@ -215,6 +216,7 @@ class ClientBase {
unsigned egl_sync_type_ = 0; unsigned egl_sync_type_ = 0;
std::vector<std::unique_ptr<Buffer>> buffers_; std::vector<std::unique_ptr<Buffer>> buffers_;
sk_sp<GrDirectContext> gr_context_; sk_sp<GrDirectContext> gr_context_;
base::flat_set<uint32_t> bug_fix_ids_;
private: private:
DISALLOW_COPY_AND_ASSIGN(ClientBase); DISALLOW_COPY_AND_ASSIGN(ClientBase);
......
...@@ -97,6 +97,10 @@ Simple::Simple() = default; ...@@ -97,6 +97,10 @@ Simple::Simple() = default;
void Simple::Run(int frames, void Simple::Run(int frames,
const bool log_vsync_timing_updates, const bool log_vsync_timing_updates,
PresentationFeedback* feedback) { PresentationFeedback* feedback) {
wl_display_roundtrip(display_.get());
// We always send this bug fix ID as a sanity check.
DCHECK(bug_fix_ids_.find(1151508) != bug_fix_ids_.end());
wl_callback_listener frame_listener = {FrameCallback}; wl_callback_listener frame_listener = {FrameCallback};
wp_presentation_feedback_listener feedback_listener = { wp_presentation_feedback_listener feedback_listener = {
FeedbackSyncOutput, FeedbackPresented, FeedbackDiscarded}; FeedbackSyncOutput, FeedbackPresented, FeedbackDiscarded};
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
</copyright> </copyright>
<interface name="zaura_shell" version="12"> <interface name="zaura_shell" version="14">
<description summary="aura_shell"> <description summary="aura_shell">
The global interface exposing aura shell capabilities is used to The global interface exposing aura shell capabilities is used to
instantiate an interface extension for a wl_surface object. instantiate an interface extension for a wl_surface object.
...@@ -83,6 +83,16 @@ ...@@ -83,6 +83,16 @@
</description> </description>
<arg name="layout_mode" type="uint" summary="layout_mode enum"/> <arg name="layout_mode" type="uint" summary="layout_mode enum"/>
</event> </event>
<!-- Version 14 additions -->
<event name="bug_fix" since="14">
<description summary="sends a bug fix ID">
Sends a monorail ID of a bug fixed on the exo server that clients can
use to gate functionality.
</description>
<arg name="id" type="uint" summary="ID of a single bug fix"/>
</event>
</interface> </interface>
<interface name="zaura_surface" version="12"> <interface name="zaura_surface" version="12">
......
...@@ -471,6 +471,14 @@ class AuraOutput : public WaylandDisplayObserver { ...@@ -471,6 +471,14 @@ class AuraOutput : public WaylandDisplayObserver {
// aura_shell_interface: // aura_shell_interface:
#if BUILDFLAG(IS_CHROMEOS_ASH) #if BUILDFLAG(IS_CHROMEOS_ASH)
// IDs of bugs that have been fixed in the exo implementation. These are
// propagated to clients on aura_shell bind and can be used to gate client
// logic on the presence of certain fixes.
const uint32_t kFixedBugIds[] = {
1151508, // Do not remove, used for sanity checks by |wayland_simple_client|
};
// Implements aura shell interface and monitors workspace state needed // Implements aura shell interface and monitors workspace state needed
// for the aura shell interface. // for the aura shell interface.
class WaylandAuraShell : public ash::TabletModeObserver { class WaylandAuraShell : public ash::TabletModeObserver {
...@@ -486,6 +494,12 @@ class WaylandAuraShell : public ash::TabletModeObserver { ...@@ -486,6 +494,12 @@ class WaylandAuraShell : public ash::TabletModeObserver {
: ZAURA_SHELL_LAYOUT_MODE_WINDOWED; : ZAURA_SHELL_LAYOUT_MODE_WINDOWED;
zaura_shell_send_layout_mode(aura_shell_resource_, layout_mode); zaura_shell_send_layout_mode(aura_shell_resource_, layout_mode);
} }
if (wl_resource_get_version(aura_shell_resource_) >=
ZAURA_SHELL_BUG_FIX_SINCE_VERSION) {
for (uint32_t bug_id : kFixedBugIds) {
zaura_shell_send_bug_fix(aura_shell_resource_, bug_id);
}
}
} }
WaylandAuraShell(const WaylandAuraShell&) = delete; WaylandAuraShell(const WaylandAuraShell&) = delete;
WaylandAuraShell& operator=(const WaylandAuraShell&) = delete; WaylandAuraShell& operator=(const WaylandAuraShell&) = delete;
......
...@@ -17,7 +17,7 @@ struct wl_resource; ...@@ -17,7 +17,7 @@ struct wl_resource;
namespace exo { namespace exo {
namespace wayland { namespace wayland {
constexpr uint32_t kZAuraShellVersion = 12; constexpr uint32_t kZAuraShellVersion = 14;
// Adds bindings to the Aura Shell. Normally this implies Ash on ChromeOS // Adds bindings to the Aura Shell. Normally this implies Ash on ChromeOS
// builds. On non-ChromeOS builds the protocol provides access to Aura windowing // builds. On non-ChromeOS builds the protocol provides access to Aura windowing
......
...@@ -372,11 +372,13 @@ source_set("wayland_unittests") { ...@@ -372,11 +372,13 @@ source_set("wayland_unittests") {
"host/wayland_window_unittest.cc", "host/wayland_window_unittest.cc",
"test/wayland_test.cc", "test/wayland_test.cc",
"test/wayland_test.h", "test/wayland_test.h",
"host/wayland_zaura_shell_unittest.cc",
] ]
deps = [ deps = [
":test_support", ":test_support",
":wayland", ":wayland",
"//components/exo/wayland/protocol:aura_shell_protocol",
"//testing/gmock", "//testing/gmock",
"//testing/gtest", "//testing/gtest",
"//third_party/wayland:wayland_server", "//third_party/wayland:wayland_server",
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
namespace ui { namespace ui {
namespace { namespace {
constexpr uint32_t kMaxAuraShellVersion = 11; constexpr uint32_t kMaxAuraShellVersion = 14;
constexpr uint32_t kMaxCompositorVersion = 4; constexpr uint32_t kMaxCompositorVersion = 4;
constexpr uint32_t kMaxCursorShapesVersion = 1; constexpr uint32_t kMaxCursorShapesVersion = 1;
constexpr uint32_t kMaxGtkPrimarySelectionDeviceManagerVersion = 1; constexpr uint32_t kMaxGtkPrimarySelectionDeviceManagerVersion = 1;
......
...@@ -21,12 +21,17 @@ WaylandZAuraShell::WaylandZAuraShell(zaura_shell* aura_shell, ...@@ -21,12 +21,17 @@ WaylandZAuraShell::WaylandZAuraShell(zaura_shell* aura_shell,
static const zaura_shell_listener zaura_shell_listener = { static const zaura_shell_listener zaura_shell_listener = {
&WaylandZAuraShell::OnLayoutMode, &WaylandZAuraShell::OnLayoutMode,
&WaylandZAuraShell::OnBugFix,
}; };
zaura_shell_add_listener(obj_.get(), &zaura_shell_listener, this); zaura_shell_add_listener(obj_.get(), &zaura_shell_listener, this);
} }
WaylandZAuraShell::~WaylandZAuraShell() = default; WaylandZAuraShell::~WaylandZAuraShell() = default;
bool WaylandZAuraShell::HasBugFix(uint32_t id) {
return bug_fix_ids_.find(id) != bug_fix_ids_.end();
}
// static // static
void WaylandZAuraShell::OnLayoutMode(void* data, void WaylandZAuraShell::OnLayoutMode(void* data,
struct zaura_shell* zaura_shell, struct zaura_shell* zaura_shell,
...@@ -47,4 +52,12 @@ void WaylandZAuraShell::OnLayoutMode(void* data, ...@@ -47,4 +52,12 @@ void WaylandZAuraShell::OnLayoutMode(void* data,
} }
} }
// static
void WaylandZAuraShell::OnBugFix(void* data,
struct zaura_shell* zaura_shell,
uint32_t id) {
auto* self = static_cast<WaylandZAuraShell*>(data);
self->bug_fix_ids_.insert(id);
}
} // namespace ui } // namespace ui
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_ZAURA_SHELL_H_ #ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_ZAURA_SHELL_H_
#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_ZAURA_SHELL_H_ #define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_ZAURA_SHELL_H_
#include <string>
#include "base/containers/flat_set.h"
#include "ui/ozone/platform/wayland/common/wayland_object.h" #include "ui/ozone/platform/wayland/common/wayland_object.h"
namespace ui { namespace ui {
...@@ -20,15 +23,24 @@ class WaylandZAuraShell { ...@@ -20,15 +23,24 @@ class WaylandZAuraShell {
~WaylandZAuraShell(); ~WaylandZAuraShell();
zaura_shell* wl_object() const { return obj_.get(); } zaura_shell* wl_object() const { return obj_.get(); }
// Due to version skew between Lacros and Ash, there may be certain bug
// fixes in one but not in the other (crbug.com/1151508). Lacros can use
// |HasBugFix| to provide a temporary workaround to an exo bug until Ash
// uprevs and starts reporting that a given bug ID has been fixed.
bool HasBugFix(uint32_t id);
private: private:
// zaura_shell_listener // zaura_shell_listeners
static void OnLayoutMode(void* data, static void OnLayoutMode(void* data,
struct zaura_shell* zaura_shell, struct zaura_shell* zaura_shell,
uint32_t layout_mode); uint32_t layout_mode);
static void OnBugFix(void* data,
struct zaura_shell* zaura_shell,
uint32_t id);
wl::Object<zaura_shell> obj_; wl::Object<zaura_shell> obj_;
WaylandConnection* const connection_; WaylandConnection* const connection_;
base::flat_set<uint32_t> bug_fix_ids_;
}; };
} // namespace ui } // namespace ui
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <aura-shell-server-protocol.h>
#include "base/run_loop.h"
#include "base/test/task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
#include "ui/ozone/platform/wayland/host/wayland_event_source.h"
#include "ui/ozone/platform/wayland/host/wayland_zaura_shell.h"
#include "ui/ozone/platform/wayland/test/global_object.h"
#include "ui/ozone/platform/wayland/test/test_wayland_server_thread.h"
namespace ui {
namespace {
constexpr uint32_t kXdgVersionStable = 7;
constexpr uint32_t kZAuraShellVersion = 14;
} // namespace
TEST(WaylandZauraShellTest, Foo) {
base::test::SingleThreadTaskEnvironment task_environment(
base::test::SingleThreadTaskEnvironment::MainThreadType::UI);
wl::TestWaylandServerThread server;
ASSERT_TRUE(server.Start(kXdgVersionStable));
wl::GlobalObject zaura_shell_obj(
&zaura_shell_interface, nullptr /* implementation */, kZAuraShellVersion);
zaura_shell_obj.Initialize(server.display());
WaylandConnection connection;
ASSERT_TRUE(connection.Initialize());
connection.event_source()->StartProcessingEvents();
base::RunLoop().RunUntilIdle();
server.Pause();
zaura_shell_send_bug_fix(zaura_shell_obj.resource(), 1);
zaura_shell_send_bug_fix(zaura_shell_obj.resource(), 3);
server.Resume();
base::RunLoop().RunUntilIdle();
server.Pause();
ASSERT_TRUE(connection.zaura_shell()->HasBugFix(1));
ASSERT_TRUE(connection.zaura_shell()->HasBugFix(3));
ASSERT_FALSE(connection.zaura_shell()->HasBugFix(2));
}
} // namespace ui
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