Merge lp:~dandrader/qtubuntu/resizeCatchUp into lp:qtubuntu

Proposed by Daniel d'Andrada on 2015-08-26
Status: Merged
Approved by: Gerry Boland on 2015-08-27
Approved revision: 275
Merged at revision: 276
Proposed branch: lp:~dandrader/qtubuntu/resizeCatchUp
Merge into: lp:qtubuntu
Diff against target: 89 lines (+35/-3)
1 file modified
src/ubuntumirclient/window.cpp (+35/-3)
To merge this branch: bzr merge lp:~dandrader/qtubuntu/resizeCatchUp
Reviewer Review Type Date Requested Status
Gerry Boland 2015-08-26 Approve on 2015-08-27
PS Jenkins bot continuous-integration Approve on 2015-08-26
Review via email: mp+269195@code.launchpad.net

Commit Message

UbuntuWindow - keep redrawing a bit until you get the promised resized buffer

Usually you get a resized buffer on the next buffer swap, but it's not uncommon
that it shows up only after the second one.

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Gerry Boland (gerboland) wrote :

Put the logging change in a different MR, not this one. I'm not convinced by it, we've used the logging.h macros for some time. If it is faulty, we should either fix it, or replace it everywhere, not just a solution in this file.

Please put in a note saying that the resizeCatchup stuff is working around a bug in Mir. It should not be necessary

review: Needs Fixing
Daniel d'Andrada (dandrader) wrote :

On 27/08/2015 15:06, Gerry Boland wrote:
> I'm not convinced by it, we've used the logging.h macros for some time.

No, they've been silent for some time. At for the apps that come with
the phone And I've been replacing them with printf()s for some time already.

Gerry Boland (gerboland) wrote :

> On 27/08/2015 15:06, Gerry Boland wrote:
> > I'm not convinced by it, we've used the logging.h macros for some time.
>
> No, they've been silent for some time. At for the apps that come with
> the phone And I've been replacing them with printf()s for some time already.

That doesn't negate my initial complaint. Please remove those log changes from this MR, they don't belong.

Daniel d'Andrada (dandrader) wrote :

> Put the logging change in a different MR, not this one. I'm not convinced by
> it, we've used the logging.h macros for some time. If it is faulty, we should
> either fix it, or replace it everywhere, not just a solution in this file.
>
> Please put in a note saying that the resizeCatchup stuff is working around a
> bug in Mir. It should not be necessary

Done.

lp:~dandrader/qtubuntu/resizeCatchUp updated on 2015-08-27
275. By Daniel d'Andrada on 2015-08-27

UbuntuWindow - keep redrawing a bit until you get the promised resized buffer

Usually you get a resized buffer on the next buffer swap, but it's not uncommon
that it shows up only after the second one.

Gerry Boland (gerboland) wrote :

LGTM, thank you

review: Approve
lp:~dandrader/qtubuntu/resizeCatchUp updated on 2015-08-28
276. By Daniel d'Andrada on 2015-08-28

Fix build

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ubuntumirclient/window.cpp'
2--- src/ubuntumirclient/window.cpp 2015-07-15 12:43:21 +0000
3+++ src/ubuntumirclient/window.cpp 2015-08-28 08:12:52 +0000
4@@ -100,6 +100,10 @@
5 QSize bufferSize;
6 QMutex mutex;
7 QSharedPointer<UbuntuClipboard> clipboard;
8+ int resizeCatchUpAttempts;
9+#if !defined(QT_NO_DEBUG)
10+ int frameNumber;
11+#endif
12 };
13
14 static void eventCallback(MirSurface* surface, const MirEvent *event, void* context)
15@@ -132,10 +136,15 @@
16 d->state = window()->windowState();
17 d->connection = connection;
18 d->clipboard = clipboard;
19+ d->resizeCatchUpAttempts = 0;
20
21 static int id = 1;
22 d->id = id++;
23
24+#if !defined(QT_NO_DEBUG)
25+ d->frameNumber = 0;
26+#endif
27+
28 // Use client geometry if set explicitly, use available screen geometry otherwise.
29 QPlatformWindow::setGeometry(window()->geometry() != screen->geometry() ?
30 window()->geometry() : screen->availableGeometry());
31@@ -314,7 +323,8 @@
32 void UbuntuWindow::handleSurfaceResize(int width, int height)
33 {
34 QMutexLocker(&d->mutex);
35- LOG("UbuntuWindow::handleSurfaceResize(width=%d, height=%d)", width, height);
36+ DLOG("UbuntuWindow::handleSurfaceResize(width=%d, height=%d) [%d]", width, height,
37+ d->frameNumber);
38
39 // The current buffer size hasn't actually changed. so just render on it and swap
40 // buffers in the hope that the next buffer will match the surface size advertised
41@@ -324,6 +334,12 @@
42 // no synchronicity whatsoever between the processing of resize events and the
43 // consumption of buffers.
44 if (d->bufferSize.width() != width || d->bufferSize.height() != height) {
45+ // if the next buffer doesn't have a different size, try some
46+ // more
47+ // FIXME: This is working around a mir bug! We really shound't have to
48+ // swap more than once to get a buffer with the new size!
49+ d->resizeCatchUpAttempts = 2;
50+
51 QWindowSystemInterface::handleExposeEvent(window(), geometry());
52 QWindowSystemInterface::flushWindowSystemEvents();
53 }
54@@ -410,11 +426,18 @@
55
56 bool sizeKnown = newBufferWidth > 0 && newBufferHeight > 0;
57
58+#if !defined(QT_NO_DEBUG)
59+ ++d->frameNumber;
60+#endif
61+
62 if (sizeKnown && (d->bufferSize.width() != newBufferWidth ||
63 d->bufferSize.height() != newBufferHeight)) {
64+ d->resizeCatchUpAttempts = 0;
65
66- DLOG("UbuntuWindow::onBuffersSwapped_threadSafe - buffer size changed from (%d,%d) to (%d,%d)",
67- d->bufferSize.width(), d->bufferSize.height(), newBufferWidth, newBufferHeight);
68+ DLOG("UbuntuWindow::onBuffersSwapped_threadSafe [%d] - buffer size changed from (%d,%d) to (%d,%d)"
69+ " resizeCatchUpAttempts=%d",
70+ d->frameNumber, d->bufferSize.width(), d->bufferSize.height(), newBufferWidth, newBufferHeight,
71+ d->resizeCatchUpAttempts);
72
73 d->bufferSize.rwidth() = newBufferWidth;
74 d->bufferSize.rheight() = newBufferHeight;
75@@ -427,5 +450,14 @@
76
77 QPlatformWindow::setGeometry(newGeometry);
78 QWindowSystemInterface::handleGeometryChange(window(), newGeometry, QRect());
79+ } else if (d->resizeCatchUpAttempts > 0) {
80+ --d->resizeCatchUpAttempts;
81+ DLOG("UbuntuWindow::onBuffersSwapped_threadSafe [%d] - buffer size (%d,%d). Redrawing to catch up a resized buffer."
82+ " resizeCatchUpAttempts=%d",
83+ d->frameNumber, d->bufferSize.width(), d->bufferSize.height(), d->resizeCatchUpAttempts);
84+ QWindowSystemInterface::handleExposeEvent(window(), geometry());
85+ } else {
86+ DLOG("UbuntuWindow::onBuffersSwapped_threadSafe [%d] - buffer size (%d,%d). resizeCatchUpAttempts=%d",
87+ d->frameNumber, d->bufferSize.width(), d->bufferSize.height(), d->resizeCatchUpAttempts);
88 }
89 }

Subscribers

People subscribed via source and target branches