Fix race condition with libinput events on startup
ClosedPublic

Authored by fvogt on Nov 18 2017, 10:30 PM.

Details

Summary

In some cases, it's possible that libinput wrote device added events to
the file descriptor before the connection to handle those events was
in-place. This resulted in a compositor without any input devices.

Test Plan

Ran a wayland session. In about 60% of all cases, no input was
possible. kwin_libinput showed the enumeration of all devices correctly,
but KWin::LibInput::Context did not have any m_devices.
After this change, this did not appear anymore.

Diff Detail

Repository
R108 KWin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
fvogt created this revision.Nov 18 2017, 10:30 PM
Restricted Application added a project: KWin. · View Herald TranscriptNov 18 2017, 10:30 PM
Restricted Application added subscribers: KWin, kwin. · View Herald Transcript
davidedmundson accepted this revision.Nov 19 2017, 1:43 AM
This revision is now accepted and ready to land.Nov 19 2017, 1:43 AM
anthonyfieroni added inline comments.
input.cpp
1733–1737

Doesn't it to be in setup?

void Connection::setup(QObject *to)
{
    connect(this, &LibInput::Connection::eventsRead, to, [this]() { processEvents(); }, Qt::QueuedConnection);
    QMetaObject::invokeMethod(this, "doSetup", Qt::QueuedConnection);
}

Caller should be

conn->setup(this);

Otherwise it looks inconvenience, no?

graesslin accepted this revision.Nov 19 2017, 8:10 AM

Should this go into Plasma/5.11 as well?

input.cpp
1733–1737

IMO the connection should be made by the receiver, as it knows which threads are supposed to get which events.

In D8888#169518, @fvogt wrote:

Should this go into Plasma/5.11 as well?

Yes, please.

This revision was automatically updated to reflect the committed changes.