Skip to content

Commit d1c48a0

Browse files
author
Jeff Brown
committed
Dispatch multiple touch events in parallel.
This change enables the input dispatcher to send multiple touch events to an application without waiting for them to be acknowledged. Essentially this is a variation on the old streaming optimization but it is much more comprehensive. Event dispatch will stall as soon as 0.5sec of unacknowledged events are accumulated or a focused event (such as a key event) needs to be delivered. Streaming input events makes a tremendous difference in application performance. The next step will be to enable batching of input events on the client side once again. This is part of a series of changes to improve input system pipelining. Bug: 5963420 Change-Id: I025df90c06165d719fcca7f63eed322a5cce4a78
1 parent 8b4be56 commit d1c48a0

File tree

3 files changed

+197
-156
lines changed

3 files changed

+197
-156
lines changed

libs/ui/InputTransport.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828

2929
namespace android {
3030

31+
// Socket buffer size. The default is typically about 128KB, which is much larger than
32+
// we really need. So we make it smaller. It just needs to be big enough to hold
33+
// a few dozen large multi-finger motion events in the case where an application gets
34+
// behind processing touches.
35+
static const size_t SOCKET_BUFFER_SIZE = 32 * 1024;
36+
37+
3138
// --- InputMessage ---
3239

3340
bool InputMessage::isValid(size_t actualSize) const {
@@ -93,6 +100,12 @@ status_t InputChannel::openInputChannelPair(const String8& name,
93100
return result;
94101
}
95102

103+
int bufferSize = SOCKET_BUFFER_SIZE;
104+
setsockopt(sockets[0], SOL_SOCKET, SO_SNDBUF, &bufferSize, sizeof(bufferSize));
105+
setsockopt(sockets[0], SOL_SOCKET, SO_RCVBUF, &bufferSize, sizeof(bufferSize));
106+
setsockopt(sockets[1], SOL_SOCKET, SO_SNDBUF, &bufferSize, sizeof(bufferSize));
107+
setsockopt(sockets[1], SOL_SOCKET, SO_RCVBUF, &bufferSize, sizeof(bufferSize));
108+
96109
String8 serverChannelName = name;
97110
serverChannelName.append(" (server)");
98111
outServerChannel = new InputChannel(serverChannelName, sockets[0]);

0 commit comments

Comments
 (0)