Commit 781c2476 authored by Joshua Pawlicki's avatar Joshua Pawlicki Committed by Commit Bot

Revert "ozone/wayland: gracefully shutdown the browser on protocol error."

This reverts commit fa06bf45.

Reason for revert: Believe this introduces flakiness and failures on lacros. See https://bugs.chromium.org/p/chromium/issues/detail?id=1129425

Original change's description:
> ozone/wayland: gracefully shutdown the browser on protocol error.
> 
> Wayland may disconnect the client if it hits an unrecoverable
> error. That is, it prints an error message and client cannot
> do anything about that after that except shutting itself down.
> 
> Thus, while watching the display fd, always check for errors. If
> a protocol error is set, trigger |shutdown_cb| and also stop
> watching the fd.
> 
> Bug: 1127278
> Change-Id: Ie324af93d455c0c83f8e75cdecfafe2254da1972
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2404931
> Commit-Queue: Maksim Sisov (GMT+3) <msisov@igalia.com>
> Reviewed-by: Robert Kroeger <rjkroege@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#807775}

TBR=rjkroege@chromium.org,msisov@igalia.com

Change-Id: Ie1cfa657b34930ebc6e568c1d422dbfae910197a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1127278
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2416884Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Commit-Queue: Joshua Pawlicki <waffles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808009}
parent ed9306bf
......@@ -131,10 +131,6 @@ void WaylandConnection::ScheduleFlush() {
}
}
void WaylandConnection::SetShutdownCb(base::OnceCallback<void()> shutdown_cb) {
event_source()->SetShutdownCb(std::move(shutdown_cb));
}
void WaylandConnection::SetCursorBitmap(const std::vector<SkBitmap>& bitmaps,
const gfx::Point& location) {
if (!cursor_)
......
......@@ -56,10 +56,6 @@ class WaylandConnection {
// Schedules a flush of the Wayland connection.
void ScheduleFlush();
// Sets a callback that that shutdowns the browser in case of unrecoverable
// error. Called by WaylandEventWatcher.
void SetShutdownCb(base::OnceCallback<void()> shutdown_cb);
wl_display* display() const { return display_.get(); }
wl_compositor* compositor() const { return compositor_.get(); }
uint32_t compositor_version() const { return compositor_version_; }
......
......@@ -67,10 +67,6 @@ WaylandEventSource::WaylandEventSource(wl_display* display,
WaylandEventSource::~WaylandEventSource() = default;
void WaylandEventSource::SetShutdownCb(base::OnceCallback<void()> shutdown_cb) {
event_watcher_->SetShutdownCb(std::move(shutdown_cb));
}
bool WaylandEventSource::StartProcessingEvents() {
return event_watcher_->StartProcessingEvents();
}
......
......@@ -61,10 +61,6 @@ class WaylandEventSource : public PlatformEventSource,
int keyboard_modifiers() const { return keyboard_modifiers_; }
// Sets a callback that that shutdowns the browser in case of unrecoverable
// error. Called by WaylandEventWatcher.
void SetShutdownCb(base::OnceCallback<void()> shutdown_cb);
// Starts polling for events from the wayland connection file descriptor.
// This method assumes connection is already estabilished and input objects
// are already bound and properly initialized.
......
......@@ -21,12 +21,6 @@ WaylandEventWatcher::~WaylandEventWatcher() {
StopProcessingEvents();
}
void WaylandEventWatcher::SetShutdownCb(
base::OnceCallback<void()> shutdown_cb) {
DCHECK(shutdown_cb_.is_null());
shutdown_cb_ = std::move(shutdown_cb);
}
bool WaylandEventWatcher::StartProcessingEvents() {
DCHECK(display_);
if (watching_)
......@@ -48,11 +42,6 @@ bool WaylandEventWatcher::StopProcessingEvents() {
}
void WaylandEventWatcher::OnFileCanReadWithoutBlocking(int fd) {
if (!CheckForErrors()) {
StopProcessingEvents();
return;
}
if (prepared_) {
prepared_ = false;
if (wl_display_read_events(display_) == -1)
......@@ -113,15 +102,4 @@ void WaylandEventWatcher::MaybePrepareReadQueue() {
wl_display_dispatch_pending(display_);
}
bool WaylandEventWatcher::CheckForErrors() {
int err = wl_display_get_error(display_);
if (err == EPROTO) {
// This can be null in tests.
if (!shutdown_cb_.is_null())
std::move(shutdown_cb_).Run();
return false;
}
return true;
}
} // namespace ui
......@@ -5,7 +5,6 @@
#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_EVENT_WATCHER_H_
#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_EVENT_WATCHER_H_
#include "base/callback.h"
#include "base/message_loop/message_pump_for_ui.h"
#include "base/message_loop/watchable_io_message_pump_posix.h"
......@@ -24,10 +23,6 @@ class WaylandEventWatcher : public base::MessagePumpForUI::FdWatcher {
WaylandEventWatcher& operator=(const WaylandEventWatcher&) = delete;
~WaylandEventWatcher() override;
// Sets a callback that that shutdowns the browser in case of unrecoverable
// error. Can only be set once.
void SetShutdownCb(base::OnceCallback<void()> shutdown_cb);
// Starts polling for events from the wayland connection file descriptor.
// This method assumes connection is already estabilished and input objects
// are already bound and properly initialized.
......@@ -44,18 +39,12 @@ class WaylandEventWatcher : public base::MessagePumpForUI::FdWatcher {
bool StartWatchingFd(base::WatchableIOMessagePumpPosix::Mode mode);
void MaybePrepareReadQueue();
// Checks if |display_| has any error set. If so, |shutdown_cb_| is executed
// and false is returned.
bool CheckForErrors();
base::MessagePumpForUI::FdWatchController controller_;
wl_display* const display_; // Owned by WaylandConnection.
bool watching_ = false;
bool prepared_ = false;
base::OnceCallback<void()> shutdown_cb_;
};
} // namespace ui
......
......@@ -258,12 +258,6 @@ class OzonePlatformWayland : public OzonePlatform {
buffer_manager_->AddBindingWaylandBufferManagerGpu(std::move(receiver));
}
void PostMainMessageLoopStart(
base::OnceCallback<void()> shutdown_cb) override {
DCHECK(connection_);
connection_->SetShutdownCb(std::move(shutdown_cb));
}
private:
#if BUILDFLAG(USE_XKBCOMMON)
XkbEvdevCodes xkb_evdev_code_converter_;
......
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