summaryrefslogtreecommitdiffstats
path: root/src/android
diff options
context:
space:
mode:
authorJens Trillmann <jens.trillmann@governikus.de>2022-09-01 09:42:47 +0200
committerJens Trillmann <jens.trillmann@governikus.de>2022-09-02 17:00:23 +0200
commitb8a95275440b8a143ee648466fd8b5401ee1e839 (patch)
treed82d27744b3ad0f4a5e767659755a59df5dceb39 /src/android
parent216fe24ca1d7a6e8de307e33c826e598d248fabd (diff)
Android A11Y: Check for active surface before calling into native code
This fixes a deadlock. The deadlock occurs on an application state change. During this state change the QML plugin requests Android to create a new surface for drawing and waits on the Android thread to complete the request (QAndroidPlatformOpenGLWindow::eglSurface()). In the meantime the android a11y delegate gets requests from the android a11y interface. The delegate tries to access the a11y information through the native interface, where it has to wait for the main loop thread to get the a11y information from the QtQuick objects. This leads to a deadlock in which the main loop thread waits on the quick rendering thread, the rendering thread waits on the android thread and the android thread waits on the main loop thread. This workaround avoids this issue by not calling into native code until a rendering surface has been created. Task-number: QTBUG-105958 Pick-to: 6.4 6.3 6.2 5.15 Change-Id: Ib99145aa689d1d62e25d25e1f4f8598d53eee3a9 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/android')
-rw-r--r--src/android/jar/src/org/qtproject/qt/android/accessibility/QtAccessibilityDelegate.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/android/jar/src/org/qtproject/qt/android/accessibility/QtAccessibilityDelegate.java b/src/android/jar/src/org/qtproject/qt/android/accessibility/QtAccessibilityDelegate.java
index 23d021b785..dc821968a9 100644
--- a/src/android/jar/src/org/qtproject/qt/android/accessibility/QtAccessibilityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt/android/accessibility/QtAccessibilityDelegate.java
@@ -282,6 +282,9 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate
return null;
}
+ if (m_activityDelegate.getSurfaceCount() == 0)
+ return null;
+
final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
event.setEnabled(true);
@@ -344,9 +347,11 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate
// Spit out the entire hierarchy for debugging purposes
// dumpNodes(-1);
- int[] ids = QtNativeAccessibility.childIdListForAccessibleObject(-1);
- for (int i = 0; i < ids.length; ++i)
- result.addChild(m_view, ids[i]);
+ if (m_activityDelegate.getSurfaceCount() != 0) {
+ int[] ids = QtNativeAccessibility.childIdListForAccessibleObject(-1);
+ for (int i = 0; i < ids.length; ++i)
+ result.addChild(m_view, ids[i]);
+ }
// The offset values have changed, so we need to re-focus the
// currently focused item, otherwise it will have an incorrect
@@ -374,8 +379,9 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate
node.setClassName(m_view.getClass().getName() + DEFAULT_CLASS_NAME);
node.setPackageName(m_view.getContext().getPackageName());
- if (!QtNativeAccessibility.populateNode(virtualViewId, node))
+ if (m_activityDelegate.getSurfaceCount() == 0 || !QtNativeAccessibility.populateNode(virtualViewId, node)) {
return node;
+ }
// set only if valid, otherwise we return a node that is invalid and will crash when accessed
node.setSource(m_view, virtualViewId);
@@ -425,7 +431,7 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate
@Override
public AccessibilityNodeInfo createAccessibilityNodeInfo(int virtualViewId)
{
- if (virtualViewId == View.NO_ID) {
+ if (virtualViewId == View.NO_ID || m_activityDelegate.getSurfaceCount() == 0) {
return getNodeForView();
}
return getNodeForVirtualViewId(virtualViewId);