Commit 822d339a authored by dmazzoni's avatar dmazzoni Committed by Commit bot

Fix system freeze in accessibility focus ring code.

The change to accessibility_focus_ring_layer.cc prevents an endless loop if
the input ring is all the same point.

The change to accessibility_focus_ring_controller.cc addresses the underlying
cause - the timestamp we get from CompositorAnimationObserver::OnAnimationStep
is not guaranteed to be later than the most recent focus time (in practice,
it's up to 0.002 s earlier on an ARM Chromebook). A negative delta time
turned into NaN when we computed pow(fraction, 0.3) and that led to the
input ring being all zeros, triggering the issue above.

BUG=427649

Review URL: https://codereview.chromium.org/693623003

Cr-Commit-Position: refs/heads/master@{#302178}
parent aa054b91
......@@ -297,6 +297,12 @@ void AccessibilityFocusRingController::OnAnimationStep(
CHECK(!layers_.empty());
CHECK(layers_[0]);
// It's quite possible for the first 1 or 2 animation frames to be
// for a timestamp that's earlier than the time we received the
// focus change, so we just treat those as a delta of zero.
if (timestamp < focus_change_time_)
timestamp = focus_change_time_;
base::TimeDelta delta = timestamp - focus_change_time_;
base::TimeDelta transition_time =
base::TimeDelta::FromMilliseconds(kTransitionTimeMilliseconds);
......
......@@ -41,13 +41,13 @@ SkPath MakePath(const AccessibilityFocusRing& input_ring,
do {
prev_index = (prev_index + 35) % 36;
prev = input_ring.points[prev_index];
} while (prev.x() == p.x() && prev.y() == p.y());
} while (prev.x() == p.x() && prev.y() == p.y() && prev_index != i);
int next_index = i;
do {
next_index = (next_index + 1) % 36;
next = input_ring.points[next_index];
} while (next.x() == p.x() && next.y() == p.y());
} while (next.x() == p.x() && next.y() == p.y() && next_index != i);
gfx::Point delta0 = gfx::Point(sign(p.x() - prev.x()),
sign(p.y() - prev.y()));
......
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