Android: runAction can now be run past queue

On vulkan implementation it was possible that when going background
destroySurface was queued and then run when coming back foreground
that caused vulkan not being able to draw.

Fixes: QTBUG-118985
Fixes: QTBUG-118840
Pick-to: 6.7
Change-Id: I5957b74b89384ea84fc09d9b55afcccf5c82e390
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
bb10
Lauri Pohjanheimo 2024-03-22 15:43:36 +02:00
parent a79ca35abe
commit b2c648c572
2 changed files with 18 additions and 8 deletions

View File

@ -268,16 +268,26 @@ class QtNative
// Post a runnable to Main (UI) Thread if the app is active,
// otherwise, queue it to be posted when the the app is active again
public static void runAction(Runnable action)
{
runAction(action, true);
}
public static void runAction(Runnable action, boolean queueWhenInactive)
{
synchronized (m_mainActivityMutex) {
final Looper mainLooper = Looper.getMainLooper();
final Handler handler = new Handler(mainLooper);
final boolean isStateVisible =
(m_stateDetails.state != ApplicationState.ApplicationSuspended)
&& (m_stateDetails.state != ApplicationState.ApplicationHidden);
final boolean active = (isActivityValid() && isStateVisible) || isServiceValid();
if (!active || !handler.post(action))
m_lostActions.add(action);
if (queueWhenInactive) {
final boolean isStateVisible =
(m_stateDetails.state != ApplicationState.ApplicationSuspended)
&& (m_stateDetails.state != ApplicationState.ApplicationHidden);
final boolean active = (isActivityValid() && isStateVisible) || isServiceValid();
if (!active || !handler.post(action))
m_lostActions.add(action);
} else {
handler.post(action);
}
}
}

View File

@ -122,8 +122,8 @@ class QtWindow extends QtLayout implements QtSurfaceInterface {
if (m_surfaceContainer != null) {
removeView(m_surfaceContainer);
m_surfaceContainer = null;
}
});
}
}, false);
}
public void setGeometry(final int x, final int y, final int w, final int h)