0

Temporarily disable non-YUV overlays from exo

We need a temporary fix to disable non-YUV overlays
from exo. We still want videos to be promoted to
overlays so no change for YUV overlays. This is a
temporary fix before we get our hatch devices shipped.
Currently, certain hatch devices (i.e. nightfury)
observes screen freezing issues while using low
latency canvas app (i.e. Squid app), we could
not repo the issue so this temp fix is needed to
prevent this.

Bug: 369003507
Change-Id: I2cb49bae91a8a066ffb3f83bbd90aabce8fd0941
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5925692
Commit-Queue: Kramer Ge <fangzhoug@chromium.org>
Reviewed-by: Kramer Ge <fangzhoug@chromium.org>
Reviewed-by: Peter McNeeley <petermcneeley@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1373355}
This commit is contained in:
harthuang
2024-10-24 16:04:13 +00:00
committed by Chromium LUCI CQ
parent b0ba791909
commit edab44a2eb
3 changed files with 64 additions and 0 deletions

@ -10,6 +10,7 @@
#include "ash/public/cpp/window_properties.h"
#include "ash/wm/desks/desks_util.h"
#include "base/containers/adapters.h"
#include "base/feature_list.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
@ -83,6 +84,10 @@ BASE_FEATURE(kExoPerSurfaceOcclusion,
"ExoPerSurfaceOcclusion",
base::FEATURE_ENABLED_BY_DEFAULT);
BASE_FEATURE(kDisableNonYUVOverlaysFromExo,
"DisableNonYUVOverlaysFromExo",
base::FEATURE_DISABLED_BY_DEFAULT);
namespace {
bool IsExoOcclusionEnabled() {
@ -116,6 +121,28 @@ bool FormatHasAlpha(gfx::BufferFormat format) {
return gfx::AlphaBitsForBufferFormat(format) != 0;
}
// TODO(crbug.com/369003507): Remove this check once we found the root
// cause of crash on specific hatch platform.
bool ShouldDisableOverlay(gfx::BufferFormat format) {
static bool is_enabled =
base::FeatureList::IsEnabled(kDisableNonYUVOverlaysFromExo);
if (!is_enabled) {
return false;
}
switch (format) {
case gfx::BufferFormat::YVU_420:
return false;
case gfx::BufferFormat::YUV_420_BIPLANAR:
return false;
case gfx::BufferFormat::YUVA_420_TRIPLANAR:
return false;
case gfx::BufferFormat::P010:
return false;
default:
return true;
}
}
Transform InvertY(Transform transform) {
switch (transform) {
case Transform::NORMAL:
@ -1863,6 +1890,11 @@ void Surface::AppendContentsToFrame(const gfx::PointF& parent_to_root_px,
break;
}
if (state_.buffer.has_value() && state_.buffer->buffer() &&
ShouldDisableOverlay(state_.buffer->buffer()->GetFormat())) {
texture_quad->overlay_priority_hint = viz::OverlayPriority::kLow;
}
#if BUILDFLAG(USE_ARC_PROTECTED_MEDIA)
if (state_.basic_state.only_visible_on_secure_output &&
state_.buffer.has_value() && state_.buffer->buffer() &&

@ -57,6 +57,9 @@ namespace exo {
// Occluded surfaces can be detected and not emitted as a quad in the
// corresponding compositor frame.
BASE_DECLARE_FEATURE(kExoPerSurfaceOcclusion);
// TODO(crbug.com/369003507): Remove this feature flag once we found the root
// cause of crash on specific hatch platform.
BASE_DECLARE_FEATURE(kDisableNonYUVOverlaysFromExo);
class Buffer;
class SecurityDelegate;

@ -1192,6 +1192,35 @@ TEST_P(SurfaceTest, SetAlpha) {
}
}
// TODO(crbug.com/369003507): This unit test is checking
// temporarily disable non YUV overlays on hatch devices
TEST_P(SurfaceTest, DisableNonYUVOverlays) {
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(kDisableNonYUVOverlaysFromExo);
gfx::Size buffer_size(2, 2);
auto buffer_non_yuv = test::ExoTestHelper::CreateBuffer(
buffer_size, gfx::BufferFormat::RGBA_8888, /*is_overlay_candidate=*/true);
auto surface = std::make_unique<Surface>();
auto shell_surface = std::make_unique<ShellSurface>(surface.get());
{
surface->Attach(buffer_non_yuv.get());
surface->Commit();
test::WaitForLastFrameAck(shell_surface.get());
const viz::CompositorFrame& frame =
GetFrameFromSurface(shell_surface.get());
EXPECT_EQ(1u, frame.render_pass_list.size());
EXPECT_EQ(1u, frame.render_pass_list.back()->quad_list.size());
viz::DrawQuad* draw_quad = frame.render_pass_list.back()->quad_list.back();
EXPECT_EQ(viz::DrawQuad::Material::kTextureContent, draw_quad->material);
EXPECT_EQ(
viz::OverlayPriority::kLow,
viz::TextureDrawQuad::MaterialCast(draw_quad)->overlay_priority_hint);
}
}
TEST_P(SurfaceTest, ForceRgbxTest) {
gfx::Size buffer_size(1, 1);
auto buffer = test::ExoTestHelper::CreateBuffer(