client: Use separate queue for SHM buffers
With the current setup, clients can try and submit buffers without
waiting for frame callbacks. This can lead to buffers being exhausted.
When this happens we go into a blocking path waiting for buffers to be
freed. The current implementation dispatches all events on the main
queue, which means we can be processing input events in the middle of
our drawing code, leading to obscure crashes.
This code uses a separate queue for shm buffers. This queue is processed
on the main thread manually before trying to re-use an old buffer this
queue is dispatched. If we need to block, we poll, but only dispatch the
one queue.
In addition explicitly dispatching solves a separate race condition.
Frame callbacks are always handled in the frame event thread. Depending
on how threads are woken this can be processed before main event thread
notifies of new events. This can lead the Qt main thread to be
processing drawing before we process the buffer release and consider the
buffer still busy. The end result is clients using one more buffer than
necessary. The explicit dispatching of shm events solves that problem.
Co-authored-by: Vlad Zahorodnii<vlad.zahorodnii@kde.org>
Pick-to: 6.9
Task-number: QTBUG-134234
Change-Id: Id8a84c72f669f187e368fd5ef32e8e4c150f8849
Reviewed-by: David Edmundson <davidedmundson@kde.org>