ActiveToolTipManager::doVisibility() spamming the X server

René J.V. Bertin rjvbertin at gmail.com
Sat Oct 19 18:23:25 BST 2019


Hi,

I've been seeing endless loops deep in libxcb (between _xcb_conn_wait() and wait_for_reply()) when using KDevelop on a remote X server, which always seemed to be related at tooltips. The lock is sufficiently "solid" that the application becomes insensitive to the normal quit signals (SIGHUP, SIGINT or SIGTERM). 

Looking at the backtrace I notice that the locking occurs under QCursor::pos() which is called multiple times by ActiveToolTipManager::doVisibility() . 

I don't understand fully why exactly that function needs the cursor position, but does it need to query the server every time the position is needed? Or would it indeed be good enough to query the position once per call to doVisiblity() ("indeed" = I tried and cannot induce any artefacts even when I move the cursor rapidly).

------------------
diff --git kdevplatform/util/activetooltip.cpp kdevplatform/util/activetooltip.cpp
index 65e9a6bc6ebc01e9f60d619d730296cd19c1cc73..a310a1073f542cd407f52a75be7393328918e6de 100644
--- kdevplatform/util/activetooltip.cpp
+++ kdevplatform/util/activetooltip.cpp
@@ -102,21 +102,23 @@ void ActiveToolTipManager::doVisibility()
         }
     }
 
+    // cache the cursor position (useful in case of a remote X11 connection)
+    const auto cursorPos = QCursor::pos();
     if (!fullGeometry.isEmpty()) {
         QRect oldFullGeometry = fullGeometry;
         QRect screenGeometry = QApplication::desktop()->screenGeometry(fullGeometry.topLeft());
         if (fullGeometry.bottom() > screenGeometry.bottom()) {
             //Move up, avoiding the mouse-cursor
             fullGeometry.moveBottom(fullGeometry.top() - 10);
-            if (fullGeometry.adjusted(-20, -20, 20, 20).contains(QCursor::pos())) {
-                fullGeometry.moveBottom(QCursor::pos().y() - 20);
+            if (fullGeometry.adjusted(-20, -20, 20, 20).contains(cursorPos)) {
+                fullGeometry.moveBottom(cursorPos.y() - 20);
             }
         }
         if (fullGeometry.right() > screenGeometry.right()) {
             //Move to left, avoiding the mouse-cursor
             fullGeometry.moveRight(fullGeometry.left() - 10);
-            if (fullGeometry.adjusted(-20, -20, 20, 20).contains(QCursor::pos())) {
-                fullGeometry.moveRight(QCursor::pos().x() - 20);
+            if (fullGeometry.adjusted(-20, -20, 20, 20).contains(cursorPos)) {
+                fullGeometry.moveRight(cursorPos.x() - 20);
             }
         }
         // Now fit this to screen
@@ -138,7 +140,7 @@ void ActiveToolTipManager::doVisibility()
 
     //Always include the mouse cursor in the full geometry, to avoid
     //closing the tooltip unexpectedly
-    fullGeometry = fullGeometry.united(QRect(QCursor::pos(), QCursor::pos()));
+    fullGeometry = fullGeometry.united(QRect(cursorPos, cursorPos));
 
     //Set bounding geometry, and remove old tooltips
     for (auto it = registeredToolTips.begin(); it != registeredToolTips.end();) {

------------------ 

PS: the local libxcb is up-to-date (1.13.1) but I see that the remote system has 1.10 ... maybe I should look if I can upgrade it myself, or is it not implicated at all on the server side?


More information about the KDevelop-devel mailing list