summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorspang <spang@chromium.org>2015-05-05 07:30:38 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-05 14:31:10 +0000
commit7d36a670f9b38d3fd9e81f1b83fab414bc22c696 (patch)
treeeb6f08ad8abb68879cab035ddbe938cd2a27579f /ui
parentc6cd3ba7199f03665ba4ba9748294734c351edb1 (diff)
downloadchromium_src-7d36a670f9b38d3fd9e81f1b83fab414bc22c696.zip
chromium_src-7d36a670f9b38d3fd9e81f1b83fab414bc22c696.tar.gz
chromium_src-7d36a670f9b38d3fd9e81f1b83fab414bc22c696.tar.bz2
Revert of Revert of ozone: evdev: Fix spurious key repeats during UI jank (patchset #1 id:1 of https://codereview.chromium.org/1121233008/)
Reason for revert: Can't be the cause of the test failure It is not even compiled for Linux ChromiumOS GN (dbg) Original issue's description: > Revert of ozone: evdev: Fix spurious key repeats during UI jank (patchset #1 id:1 of https://codereview.chromium.org/1121293002/) > > Reason for revert: > A couple of Linux ChromeOS interactive_ui_tests started failing here: > > http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Tests%20%281%29/builds/2341 > > They are timing out on a touch event, so this seemed like the most likely cause. I have been unable to reproduce locally and the failures are flaky/inconsistent (but pretty common). > > I apologize for reverting this if it is not the cause. > > Original issue's description: > > ozone: evdev: Fix spurious key repeats during UI jank > > > > There's no guarantee that a delayed task runs after other pending tasks > > with lower delayed_run_time, if those tasks were posted later. The > > reason for this is that there are two queues in the message loop: an > > incoming queue and a work queue. We drain the incoming queue as little > > as possible, to avoid synchronization overhead (see ReloadWorkQueue()). > > > > This breaks some assumptions in the key repeat code. Fix this by doing a > > second non-delayed post in OnRepeatTimeout(). Those are definitely > > guaranteed to run in FIFO order, so it should fix spurious repeats once > > and for all. > > > > BUG=481780 > > TEST=Use multi-profile switch hotkeys with repeat delay set to 200ms. > > Pressing the sequence once does not occasionally switch twice. > > > > Committed: https://crrev.com/67182c7958f5af3be5151e5efb4422240895f09b > > Cr-Commit-Position: refs/heads/master@{#328166} > > TBR=kpschoedel@chromium.org,spang@chromium.org > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=481780 > > Committed: https://crrev.com/6f3e50b69083c51c3d6eca4913cb164e390fded6 > Cr-Commit-Position: refs/heads/master@{#328266} TBR=kpschoedel@chromium.org,stevenjb@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=481780 Review URL: https://codereview.chromium.org/1128463005 Cr-Commit-Position: refs/heads/master@{#328323}
Diffstat (limited to 'ui')
-rw-r--r--ui/events/ozone/evdev/keyboard_evdev.cc12
-rw-r--r--ui/events/ozone/evdev/keyboard_evdev.h1
2 files changed, 13 insertions, 0 deletions
diff --git a/ui/events/ozone/evdev/keyboard_evdev.cc b/ui/events/ozone/evdev/keyboard_evdev.cc
index 2c14f600..bc33354 100644
--- a/ui/events/ozone/evdev/keyboard_evdev.cc
+++ b/ui/events/ozone/evdev/keyboard_evdev.cc
@@ -176,6 +176,18 @@ void KeyboardEvdev::OnRepeatTimeout(unsigned int sequence) {
if (repeat_sequence_ != sequence)
return;
+ // Post a task behind any pending key releases in the message loop
+ // FIFO. This ensures there's no spurious repeats during periods of UI
+ // thread jank.
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&KeyboardEvdev::OnRepeatCommit,
+ weak_ptr_factory_.GetWeakPtr(), repeat_sequence_));
+}
+
+void KeyboardEvdev::OnRepeatCommit(unsigned int sequence) {
+ if (repeat_sequence_ != sequence)
+ return;
+
DispatchKey(repeat_key_, true /* down */, true /* repeat */,
EventTimeForNow(), repeat_device_id_);
diff --git a/ui/events/ozone/evdev/keyboard_evdev.h b/ui/events/ozone/evdev/keyboard_evdev.h
index 2dd0792..8a5108e 100644
--- a/ui/events/ozone/evdev/keyboard_evdev.h
+++ b/ui/events/ozone/evdev/keyboard_evdev.h
@@ -58,6 +58,7 @@ class EVENTS_OZONE_EVDEV_EXPORT KeyboardEvdev {
void StopKeyRepeat();
void ScheduleKeyRepeat(const base::TimeDelta& delay);
void OnRepeatTimeout(unsigned int sequence);
+ void OnRepeatCommit(unsigned int sequence);
void DispatchKey(unsigned int key,
bool down,
bool repeat,