Commit 6fd1b88c authored by Fady Samuel's avatar Fady Samuel Committed by Commit Bot

Surface synchronization: report crash key detailing invariants violation

In order to track bugs in the wild, this crash key reports the details
of the invariants violation.

Bug: 672962, 791154
TBR: danakj@chromium.org for trivial change to selection_bound.{h|cc}
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel
Change-Id: I344f91b92cf06f9eddebdc573df35a8de5b6920e
Reviewed-on: https://chromium-review.googlesource.com/826166
Commit-Queue: Fady Samuel <fsamuel@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Reviewed-by: default avatarSaman Sami <samans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524326}
parent 11a86d52
......@@ -5,6 +5,8 @@
#ifndef COMPONENTS_VIZ_COMMON_QUADS_SELECTION_H_
#define COMPONENTS_VIZ_COMMON_QUADS_SELECTION_H_
#include "base/strings/stringprintf.h"
namespace viz {
template <typename BoundType>
......@@ -13,6 +15,11 @@ struct Selection {
~Selection() = default;
BoundType start, end;
std::string ToString() const {
return base::StringPrintf("Selection(%s, %s)", start.ToString().c_str(),
end.ToString().c_str());
}
};
template <typename BoundType>
......
......@@ -2667,6 +2667,11 @@ void RenderWidgetHostImpl::SubmitCompositorFrame(
if (local_surface_id == last_local_surface_id_ &&
new_surface_properties != last_surface_properties_) {
static auto* crash_key = base::debug::AllocateCrashKeyString(
"surface-invariants-violation", base::debug::CrashKeySize::Size256);
base::debug::ScopedCrashKeyString key_value(
crash_key,
new_surface_properties.ToDiffString(last_surface_properties_));
bad_message::ReceivedBadMessage(
GetProcess(), bad_message::RWH_SURFACE_INVARIANTS_VIOLATION);
return;
......
......@@ -2937,4 +2937,24 @@ TEST_F(RenderWidgetHostTest, InflightEventCountResetsAfterRebind) {
EXPECT_EQ(0u, host_->in_flight_event_count());
}
TEST_F(RenderWidgetHostTest, RenderWidgetSurfaceProperties) {
RenderWidgetSurfaceProperties prop1;
prop1.size = gfx::Size(200, 200);
prop1.device_scale_factor = 1.f;
RenderWidgetSurfaceProperties prop2;
prop2.size = gfx::Size(300, 300);
prop2.device_scale_factor = 2.f;
EXPECT_EQ(
"RenderWidgetSurfaceProperties(size(this: 200x200, other: 300x300), "
"device_scale_factor(this: 1, other: 2))",
prop1.ToDiffString(prop2));
EXPECT_EQ(
"RenderWidgetSurfaceProperties(size(this: 300x300, other: 200x200), "
"device_scale_factor(this: 2, other: 1))",
prop2.ToDiffString(prop1));
EXPECT_EQ("", prop1.ToDiffString(prop1));
EXPECT_EQ("", prop2.ToDiffString(prop2));
}
} // namespace content
......@@ -55,4 +55,83 @@ bool RenderWidgetSurfaceProperties::operator!=(
return !(*this == other);
}
std::string RenderWidgetSurfaceProperties::ToDiffString(
const RenderWidgetSurfaceProperties& other) const {
if (*this == other)
return std::string();
std::ostringstream stream;
stream << "RenderWidgetSurfaceProperties(";
uint32_t changed_properties = 0;
if (size != other.size) {
stream << "size(this: " << size.ToString()
<< ", other: " << other.size.ToString() << ")";
++changed_properties;
}
if (device_scale_factor != other.device_scale_factor) {
if (changed_properties > 0)
stream << ", ";
stream << "device_scale_factor(this: " << device_scale_factor
<< ", other: " << other.device_scale_factor << ")";
++changed_properties;
}
#ifdef OS_ANDROID
if (top_controls_height != other.top_controls_height) {
if (changed_properties > 0)
stream << ", ";
stream << "top_controls_height(this: " << top_controls_height
<< ", other: " << other.top_controls_height << ")";
++changed_properties;
}
if (top_controls_shown_ratio != other.top_controls_shown_ratio) {
if (changed_properties > 0)
stream << ", ";
stream << "top_controls_shown_ratio(this: " << top_controls_shown_ratio
<< ", other: " << other.top_controls_shown_ratio << ")";
++changed_properties;
}
if (bottom_controls_height != other.bottom_controls_height) {
if (changed_properties > 0)
stream << ", ";
stream << "bottom_controls_height(this: " << bottom_controls_height
<< ", other: " << other.bottom_controls_height << ")";
++changed_properties;
}
if (bottom_controls_shown_ratio != other.bottom_controls_shown_ratio) {
if (changed_properties > 0)
stream << ", ";
stream << "bottom_controls_shown_ratio(this: "
<< bottom_controls_shown_ratio
<< ", other: " << other.bottom_controls_shown_ratio << ")";
++changed_properties;
}
if (selection != other.selection) {
if (changed_properties > 0)
stream << ", ";
stream << "selection(this: " << selection.ToString()
<< ", other: " << other.selection.ToString() << ")";
++changed_properties;
}
if (has_transparent_background != other.has_transparent_background) {
if (changed_properties > 0)
stream << ", ";
stream << "has_transparent_background(this: " << has_transparent_background
<< ", other: " << other.has_transparent_background << ")";
++changed_properties;
}
#endif
stream << ")";
return stream.str();
}
} // namespace content
......@@ -26,6 +26,8 @@ struct CONTENT_EXPORT RenderWidgetSurfaceProperties {
bool operator==(const RenderWidgetSurfaceProperties& other) const;
bool operator!=(const RenderWidgetSurfaceProperties& other) const;
std::string ToDiffString(const RenderWidgetSurfaceProperties& other) const;
gfx::Size size;
float device_scale_factor = 0;
#ifdef OS_ANDROID
......
......@@ -5,6 +5,7 @@
#include <algorithm>
#include "base/macros.h"
#include "base/strings/stringprintf.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h"
......@@ -38,6 +39,13 @@ int SelectionBound::GetHeight() const {
return edge_bottom_rounded_.y() - edge_top_rounded_.y();
}
std::string SelectionBound::ToString() const {
return base::StringPrintf(
"SelectionBound(%s, %s, %s, %s, %d)", edge_top_.ToString().c_str(),
edge_bottom_.ToString().c_str(), edge_top_rounded_.ToString().c_str(),
edge_bottom_rounded_.ToString().c_str(), visible_);
}
bool operator==(const SelectionBound& lhs, const SelectionBound& rhs) {
return lhs.type() == rhs.type() && lhs.visible() == rhs.visible() &&
lhs.edge_top() == rhs.edge_top() &&
......
......@@ -42,6 +42,8 @@ class GFX_EXPORT SelectionBound {
// Returns the vertical difference between rounded top and bottom.
int GetHeight() const;
std::string ToString() const;
private:
Type type_;
gfx::PointF edge_top_;
......
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