From 87947c86dc9c163a3193bd2ecb638292b34f8063 Mon Sep 17 00:00:00 2001 From: Peter McNeeley Date: Mon, 16 May 2022 18:42:56 +0000 Subject: [PATCH] Limit minimum size of wayland viewport source rect This fix is intended to be a stopgap on the numerous issues we are seeing that have this exact error. Once we resolve the error this code should be removed. (cherry picked from commit 51954df7a8fe8fedcd303076c40eb864c34cac79) Bug: 1325344, 1324657,1300799 Change-Id: Iff32d60245d3c020a898eacf82e16d2e6e71d056 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3646046 Commit-Queue: Peter McNeeley Reviewed-by: Kramer Ge Cr-Original-Commit-Position: refs/heads/main@{#1003284} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3645335 Cr-Commit-Position: refs/branch-heads/5060@{#21} Cr-Branched-From: b83393d0f4038aeaf67f970a024d8101df7348d1-refs/heads/main@{#1002911} --- .../platform/wayland/host/wayland_surface.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ui/ozone/platform/wayland/host/wayland_surface.cc b/ui/ozone/platform/wayland/host/wayland_surface.cc index 22f53c19b5b921..92599bbfe359a7 100644 --- a/ui/ozone/platform/wayland/host/wayland_surface.cc +++ b/ui/ozone/platform/wayland/host/wayland_surface.cc @@ -557,6 +557,23 @@ void WaylandSurface::ApplyPendingState() { wl_fixed_from_double(viewport_src_dip.height()) == 0) { LOG(ERROR) << "Sending viewport src with width/height zero will result " "in wayland disconnection"; + // TODO(crbug.com/1325344): Resolve why this viewport size ends up being + // zero and remove the fix below. + LOG(ERROR) << "viewport_src_dip=" << viewport_src_dip.ToString() + << " pending_state_.crop=" << pending_state_.crop.ToString() + << " bounds=" << bounds.ToString() + << " pending_state_.buffer_size_px=" + << pending_state_.buffer_size_px.ToString(); + constexpr wl_fixed_t kViewportSizeMin = 1; + const float kViewPortSizeMinFloat = + static_cast(wl_fixed_to_double(kViewportSizeMin)); + LOG(ERROR) + << "Limiting viewport_src_dip size to be non zero with a minium of " + << kViewportSizeMin; + viewport_src_dip.set_width( + std::max(viewport_src_dip.width(), kViewPortSizeMinFloat)); + viewport_src_dip.set_height( + std::max(viewport_src_dip.height(), kViewPortSizeMinFloat)); } src_to_set[0] = wl_fixed_from_double(viewport_src_dip.x()), src_to_set[1] = wl_fixed_from_double(viewport_src_dip.y());