Descriptionozone: evdev: Make cancellation of repeats on key up more robust
Key releases enqueue a task on KeyboardEvdev that dispatches the release
ui::Event as well as cancels any scheduled repeats for that key. The
release itself is enqueued from the dedicated evdev thread and so can be
expected to arrive in a timely manner.
Unfotunately, due to the way base::Timer works, this is not robust when
the UI thread is very busy. The base::Timer object posts a delayed task,
and upon running checks to see if enough real time has passed (see
Timer::RunScheduledTask). If so, it runs the timer callback immediately.
This is fine, except that base::Timer also reuses scheduled tasks from
previous calls to Start() if they are still in the future (see
Timer::Reset). This can mean the timeout callback runs from a task that
was scheduled before the current timer was started.
The net effect of this is that the timer task may run first even if
(initial timer start + delay) > (key release task timestamp). The message
loop queue itself would have run the tasks in the correct order.
So, if we simply use PostDelayedTask() ourselves, there's no cleverness
in base::Timer to worry about and the tasks run in the needed order.
BUG=473446
TEST=Press Ctrl-W to close a tab with lots of activity (multiple copies
of gmail loading, etc). Only one tab closes. Also tested with
simulated jank (1s delay in tab closure).
Committed: https://crrev.com/50e43d96539246fe55b282e5e161b12ed39c42eb
Cr-Commit-Position: refs/heads/master@{#324081}
Patch Set 1 #
Total comments: 2
Patch Set 2 : merge DispatchKeyRepeat #
Messages
Total messages: 12 (5 generated)
|