UIKit: Detect swapBuffers on non-exposed windows and skip flush

When using threaded rendering the render-thread might be half-way into
rendering a frame when the application is backgrounded, resulting in
the following swap happening on a non-exposed window. This may result
in the system killing the application, as rendering is not supposed to
happen when an application is backgrounded, so we skip the flush.

Change-Id: I9ab8f2c4617391fd827558af9fb473f1734b3688
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Tor Arne Vestbø 2016-06-16 16:28:20 +02:00 committed by Tor Arne Vestbø
parent 3e4f885f0c
commit d2bffe0fc9

View File

@ -211,6 +211,11 @@ void QIOSContext::swapBuffers(QPlatformSurface *surface)
if (surface->surface()->surfaceClass() == QSurface::Offscreen) if (surface->surface()->surfaceClass() == QSurface::Offscreen)
return; // Nothing to do return; // Nothing to do
if (!static_cast<QIOSWindow *>(surface)->isExposed()) {
qCWarning(lcQpaGLContext, "Detected swapBuffers on a non-exposed window, skipping flush");
return;
}
FramebufferObject &framebufferObject = backingFramebufferObjectFor(surface); FramebufferObject &framebufferObject = backingFramebufferObjectFor(surface);
Q_ASSERT_X(framebufferObject.isComplete, "QIOSContext", "swapBuffers on incomplete FBO"); Q_ASSERT_X(framebufferObject.isComplete, "QIOSContext", "swapBuffers on incomplete FBO");