Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Frequency of MouseMoveEvents lower with Qt 6
QtWS25 Last Chance

Frequency of MouseMoveEvents lower with Qt 6

Scheduled Pinned Locked Moved Unsolved General and Desktop
mousemoveeventqt6performance
5 Posts 3 Posters 271 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • letsfindawayL Offline
    letsfindawayL Offline
    letsfindaway
    wrote on last edited by
    #1

    I'm working on a larger Qt application (OpenBoard), basically for drawing on a QGraphicsView. Some time ago we switched from Qt5 to Qt6. Since then I observed a much lower frequency of MouseMoveEvents. I'm using Linux, but the same was also reported from Windows users. I already did some experiments:

    • With Qt5 (actually 5.15.2), the application gets a MouseMoveEvent about every 7ms.
    • With Qt6 (actually 6.6.2), the application gets a MouseMoveEvent about every 33ms.
    • I made a minimal PoC. Here I actually get the events every 7ms in Qt5 and Qt6.

    So it seems it has to do with some operations I have in the event handler. I also measured the time to complete the event processing in OpenBoard: it was between 20 and 60 µs, so much below the mouse event frequency.

    So my question is whether there are any known changes between Qt5 and Qt6 which could cause this. Is there any mouse event throttling based on whatever reasons? Any ideas what I could try or test next?

    jsulmJ 1 Reply Last reply
    0
    • letsfindawayL letsfindaway

      I'm working on a larger Qt application (OpenBoard), basically for drawing on a QGraphicsView. Some time ago we switched from Qt5 to Qt6. Since then I observed a much lower frequency of MouseMoveEvents. I'm using Linux, but the same was also reported from Windows users. I already did some experiments:

      • With Qt5 (actually 5.15.2), the application gets a MouseMoveEvent about every 7ms.
      • With Qt6 (actually 6.6.2), the application gets a MouseMoveEvent about every 33ms.
      • I made a minimal PoC. Here I actually get the events every 7ms in Qt5 and Qt6.

      So it seems it has to do with some operations I have in the event handler. I also measured the time to complete the event processing in OpenBoard: it was between 20 and 60 µs, so much below the mouse event frequency.

      So my question is whether there are any known changes between Qt5 and Qt6 which could cause this. Is there any mouse event throttling based on whatever reasons? Any ideas what I could try or test next?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @letsfindaway said in Frequency of MouseMoveEvents lower with Qt 6:

      Any ideas what I could try or test next?

      You coulod try to disable the operations in your event handler one after another until you reach 7ms then you know which part of the event handler code causes this behavior.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      letsfindawayL 1 Reply Last reply
      0
      • jsulmJ jsulm

        @letsfindaway said in Frequency of MouseMoveEvents lower with Qt 6:

        Any ideas what I could try or test next?

        You coulod try to disable the operations in your event handler one after another until you reach 7ms then you know which part of the event handler code causes this behavior.

        letsfindawayL Offline
        letsfindawayL Offline
        letsfindaway
        wrote on last edited by letsfindaway
        #3

        @jsulm Thanks for your reply and recommendation. Yes, I tried this. I currently have two views attached to a QGraphicsScene. I did the following:

        • Disabling the second view: repetition rate goes down to 16 ms.
        • Just hiding the second view is sufficient, also 16 ms.
        • Disabling the update of the scene (just an QGraphicsEclipseItem's position is moved): repetition rate goes down to 7 ms.

        So with just commenting the line

        mEraser->setPos(pPoint);
        

        the repetition rate goes to the value I want to have, no matter whether I have one or two views attached.

        I also tried to reproduce the issue with my minimal PoC and attached even four views to the scene. But here everything is ok, repetition rate stays at 7 ms.

        And I checked CPU usage. But this is low. The main thread never uses more than 25% of a core.

        Pl45m4P 1 Reply Last reply
        0
        • letsfindawayL letsfindaway

          @jsulm Thanks for your reply and recommendation. Yes, I tried this. I currently have two views attached to a QGraphicsScene. I did the following:

          • Disabling the second view: repetition rate goes down to 16 ms.
          • Just hiding the second view is sufficient, also 16 ms.
          • Disabling the update of the scene (just an QGraphicsEclipseItem's position is moved): repetition rate goes down to 7 ms.

          So with just commenting the line

          mEraser->setPos(pPoint);
          

          the repetition rate goes to the value I want to have, no matter whether I have one or two views attached.

          I also tried to reproduce the issue with my minimal PoC and attached even four views to the scene. But here everything is ok, repetition rate stays at 7 ms.

          And I checked CPU usage. But this is low. The main thread never uses more than 25% of a core.

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by
          #4

          Hi,

          @letsfindaway said in Frequency of MouseMoveEvents lower with Qt 6:

          just an QGraphicsEclipseItem's position is moved

          how complex is this item? Are any actions connected to the movement of the ellipse?


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          letsfindawayL 1 Reply Last reply
          1
          • Pl45m4P Pl45m4

            Hi,

            @letsfindaway said in Frequency of MouseMoveEvents lower with Qt 6:

            just an QGraphicsEclipseItem's position is moved

            how complex is this item? Are any actions connected to the movement of the ellipse?

            letsfindawayL Offline
            letsfindawayL Offline
            letsfindaway
            wrote on last edited by letsfindaway
            #5

            @Pl45m4 Here is a short video of the application showing the issue:
            https://github.com/letsfindaway/OpenBoard/issues/203#issuecomment-2595705681

            • The rubber is a pixmap cursor using QCursor.
            • The circle is repositioned at each mouseMoveEvent. You see that it is lagging behind the cursor.
            • The preview image to the left is the second view attached to the same scene.

            So you see, nothing complicated. And as I already said in the beginning: when I run the same program using Qt5, then the lag is much smaller, because the repetition rate of the mouseMoveEvents is higher.

            I have setMouseTracking(true), so that I get the events even when the mouse button is not pressed.

            And no, there are no further actions connected to the movement as long as the mouse button is not pressed.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved