Merge lp:~mir-team/qtubuntu/busySwap-lp1473720 into lp:qtubuntu

Proposed by Michael Zanetti
Status: Merged
Approved by: Gerry Boland
Approved revision: 272
Merged at revision: 273
Proposed branch: lp:~mir-team/qtubuntu/busySwap-lp1473720
Merge into: lp:qtubuntu
Diff against target: 73 lines (+15/-26)
2 files modified
debian/changelog (+7/-0)
src/ubuntumirclient/window.cpp (+8/-26)
To merge this branch: bzr merge lp:~mir-team/qtubuntu/busySwap-lp1473720
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+268065@code.launchpad.net

This proposal supersedes a proposal from 2015-07-14.

Commit message

Fix surface resize

If you call QWindowSystemInterface::handleExposeEvent() from the render
thread you won't give the main thread a chance to process further
resize events. In a long resize animation (like dragging a window border
with mouse) the resize events will queue up like crazy, leaving
handleSurfaceResize() to deal with a ton of outdated resize events
once the resize animation is finally over.

Furthermore, as there's no synchronicity between the processing of resize
events and the consupmtion of buffers, there's no point in trying to tie
one to the other in any way. So better ignore the actual size information
from a resize event.

Description of the change

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

Testing with a simple qml file with mir_proving_server, when making the window larger, I see white borders while qt tries to catch up with the surface size.

This is a visual regression, there must be a better way.

review: Needs Fixing
Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

Fix is to add
        QWindowSystemInterface::flushWindowSystemEvents();
after the handleExposeEvent call, to force Qt to deal with the resize asap.

Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

Well not a perfect fix, but improves things a lot.

Revision history for this message
Daniel d'Andrada (dandrader) wrote : Posted in a previous version of this proposal

On 15/07/15 07:33, Gerry Boland wrote:
> Fix is to add
> QWindowSystemInterface::flushWindowSystemEvents();
> after the handleExposeEvent call, to force Qt to deal with the resize asap.
Done.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Gerry Boland (gerboland) :
review: Approve
273. By Michael Zanetti

bump

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-08-14 10:41:41 +0000
3+++ debian/changelog 2015-08-14 12:17:53 +0000
4@@ -1,3 +1,10 @@
5+qtubuntu (0.62) UNRELEASED; urgency=medium
6+
7+ [ Daniel D'Andrada ]
8+ * fix busy buffer swapping
9+
10+ -- Michael Zanetti <michael.zanetti@canonical.com> Fri, 14 Aug 2015 14:16:55 +0200
11+
12 qtubuntu (0.61+15.10.20150722-0ubuntu3) wily; urgency=medium
13
14 * No-change rebuild to pick up qtbase change.
15
16=== modified file 'src/ubuntumirclient/window.cpp'
17--- src/ubuntumirclient/window.cpp 2015-06-24 17:21:21 +0000
18+++ src/ubuntumirclient/window.cpp 2015-08-14 12:17:53 +0000
19@@ -98,7 +98,6 @@
20 MirConnection *connection;
21 MirSurface* surface;
22 QSize bufferSize;
23- QSize targetBufferSize;
24 QMutex mutex;
25 QSharedPointer<UbuntuClipboard> clipboard;
26 };
27@@ -318,17 +317,15 @@
28 LOG("UbuntuWindow::handleSurfaceResize(width=%d, height=%d)", width, height);
29
30 // The current buffer size hasn't actually changed. so just render on it and swap
31- // buffers until we render on a buffer with the target size.
32-
33- d->targetBufferSize.rwidth() = width;
34- d->targetBufferSize.rheight() = height;
35-
36- if (d->bufferSize != d->targetBufferSize) {
37+ // buffers in the hope that the next buffer will match the surface size advertised
38+ // in this event.
39+ // But since this event is processed by a thread different from the one that swaps
40+ // buffers, you can never know if this information is already outdated as there's
41+ // no synchronicity whatsoever between the processing of resize events and the
42+ // consumption of buffers.
43+ if (d->bufferSize.width() != width || d->bufferSize.height() != height) {
44 QWindowSystemInterface::handleExposeEvent(window(), geometry());
45- } else {
46- qWarning("[ubuntumirclient QPA] UbuntuWindow::handleSurfaceResize"
47- " current buffer already has the target size");
48- d->targetBufferSize = QSize();
49+ QWindowSystemInterface::flushWindowSystemEvents();
50 }
51 }
52
53@@ -430,20 +427,5 @@
54
55 QPlatformWindow::setGeometry(newGeometry);
56 QWindowSystemInterface::handleGeometryChange(window(), newGeometry, QRect());
57- QWindowSystemInterface::handleExposeEvent(window(), newGeometry);
58-
59- } else {
60- // buffer size hasn't changed
61- if (d->targetBufferSize.isValid()) {
62- if (d->bufferSize != d->targetBufferSize) {
63- // but we still didn't reach the promised buffer size from the mir resize event.
64- // thus keep swapping buffers
65- QWindowSystemInterface::handleExposeEvent(window(), geometry());
66- } else {
67- // target met. we have just provided a render with the target size and
68- // can therefore finally rest.
69- d->targetBufferSize = QSize();
70- }
71- }
72 }
73 }

Subscribers

People subscribed via source and target branches