Mir

Merge lp:~vanvugt/mir/fix-1506331 into lp:mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 3035
Proposed branch: lp:~vanvugt/mir/fix-1506331
Merge into: lp:mir
Diff against target: 96 lines (+5/-51)
2 files modified
3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp (+1/-5)
tests/unit-tests/client/input/test_android_input_receiver.cpp (+4/-46)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1506331
Reviewer Review Type Date Requested Status
Alan Griffiths Approve
PS Jenkins bot (community) continuous-integration Approve
Alexandros Frantzis (community) Approve
Review via email: mp+274512@code.launchpad.net

Commit message

Revert optimization r2782. Although it gave us a nice 5ms reduction in
touch latency, it also reduced Android-input's ability to smooth the curve
of the resulting event stream. And that reduction in smoothness is going
to be visible in some touch scrolling scenarios, just as it is visible in
mir_demo_client_fingerpaint / mir_demo_client_target. (LP: #1506331)

Description of the change

Screenshots of before and after are in bug 1506331.

To post a comment you must log in.
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Hmm failures appear to be unrelated...
[ FAILED ] NestedServer.display_configuration_changes_are_visible_to_client
[ FAILED ] FD leak was detected
[ FAILED ] ThreadedDispatcherSignalTest.keeps_dispatching_after_signal_interruption

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

OK

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp'
2--- 3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp 2015-08-17 18:33:38 +0000
3+++ 3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp 2015-10-19 02:38:04 +0000
4@@ -43,11 +43,7 @@
5
6 // Latency added during resampling. A few milliseconds doesn't hurt much but
7 // reduces the impact of mispredicted touch positions.
8-//static constexpr const std::chrono::nanoseconds RESAMPLE_LATENCY = std::chrono::nanoseconds(5 * NANOS_PER_MS);
9-
10-// Mir modification: No artificial latency please. This seems to provide
11-// visibly and measurably lower input latency, with no noticeable down side...
12-static constexpr const std::chrono::nanoseconds RESAMPLE_LATENCY(0);
13+static constexpr const std::chrono::nanoseconds RESAMPLE_LATENCY = std::chrono::nanoseconds(5 * NANOS_PER_MS);
14
15 // Minimum time difference between consecutive samples before attempting to resample.
16 static constexpr const std::chrono::nanoseconds RESAMPLE_MIN_DELTA = std::chrono::nanoseconds(2 * NANOS_PER_MS);
17
18=== modified file 'tests/unit-tests/client/input/test_android_input_receiver.cpp'
19--- tests/unit-tests/client/input/test_android_input_receiver.cpp 2015-08-17 18:33:38 +0000
20+++ tests/unit-tests/client/input/test_android_input_receiver.cpp 2015-10-19 02:38:04 +0000
21@@ -222,51 +222,6 @@
22 EXPECT_FALSE(mt::fd_is_readable(receiver.watch_fd()));
23 }
24
25-TEST_F(AndroidInputReceiverSetup, no_artificial_latency_in_resampling)
26-{
27- using namespace testing;
28- using namespace std::chrono;
29- using namespace std::literals::chrono_literals;
30-
31- auto t = 0ns;
32- MirEvent ev;
33- bool handler_called{false};
34-
35- mircva::InputReceiver receiver{
36- client_fd,
37- std::make_shared<mircv::XKBMapper>(),
38- [&ev, &handler_called](MirEvent* event)
39- {
40- ev = *event;
41- handler_called = true;
42- },
43- std::make_shared<mircv::NullInputReceiverReport>(),
44- [&t](int)
45- {
46- return t;
47- }
48- };
49- TestingInputProducer producer(server_fd);
50-
51- producer.produce_a_pointer_event(123, 456, t);
52- flush_channels();
53-
54- while (!mt::fd_becomes_readable(receiver.watch_fd(), 1ms) && t < 100ms)
55- t += 1ms;
56-
57- receiver.dispatch(md::FdEvent::readable);
58- EXPECT_TRUE(handler_called);
59- ASSERT_EQ(mir_event_type_motion, ev.type);
60-
61- auto const resample_latency_ms =
62- duration_cast<std::chrono::milliseconds>(t);
63-
64- // Check that we're not using the Android-default RESAMPLE_LATENCY of 5ms
65- // which is too high...
66- // Use plain integers so any failures are readable:
67- EXPECT_THAT(resample_latency_ms.count(), Lt(1));
68-}
69-
70 TEST_F(AndroidInputReceiverSetup, slow_raw_input_doesnt_cause_frameskipping)
71 { // Regression test for LP: #1372300
72 using namespace testing;
73@@ -304,11 +259,14 @@
74 EXPECT_TRUE(handler_called);
75 ASSERT_EQ(mir_event_type_key, ev.type);
76
77+ // The motion is still too new. Won't be reported yet, but is batched.
78 auto start = high_resolution_clock::now();
79
80 EXPECT_TRUE(mt::fd_becomes_readable(receiver.watch_fd(), 1ms));
81 handler_called = false;
82 receiver.dispatch(md::FdEvent::readable);
83+ // We've processed the data, but no new event has been generated.
84+ EXPECT_FALSE(handler_called);
85
86 auto end = high_resolution_clock::now();
87 auto duration = end - start;
88@@ -322,7 +280,7 @@
89
90 // But later in a frame or so, the motion will be reported:
91 t += 2 * one_frame; // Account for the slower 59Hz event rate
92- EXPECT_TRUE(handler_called || mt::fd_becomes_readable(receiver.watch_fd(), next_event_timeout));
93+ EXPECT_TRUE(mt::fd_becomes_readable(receiver.watch_fd(), next_event_timeout));
94 receiver.dispatch(md::FdEvent::readable);
95
96 EXPECT_TRUE(handler_called);

Subscribers

People subscribed via source and target branches