Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Performance issue with mouse events QML/Widget on mac
Forum Updated to NodeBB v4.3 + New Features

Performance issue with mouse events QML/Widget on mac

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
12 Posts 2 Posters 949 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.
  • H Offline
    H Offline
    H.Mahmoodi
    wrote on last edited by H.Mahmoodi
    #1

    Recently, I found that my app, when compiling on Mac, has a problem that is not available on my old laptop (old hardware specifications) on the Windows platform.

    And when I deleted so many widgets and eliminated other parts of my big-scale app, I found that the problem was in using QQuickWidget (maybe I was mistaking; I'm not sure).

    Actually, I have an QML that is loading by QQuickWidget on my widget's layout.

    I have other sliders and dials in that layout.

    • When I change the value of the sliders and dials by mouse (pressing the mouse wheel), my QML rendering has a problem (lags in framerate rendering).
    • When I emit the changing values by timer or anything in code, my QML is working right without problem.

    So I don't know why mouse events like pressing or wheel changing cause some lag in my QML (quickwidget). What's the problem? I'm confused. Should I consider something in compiling on Mac or any attributes? (Im new in Mac OS) [Qt 5.15.2, clang]

    mini project to test: https://github.com/SC-One/PerformanceIssueQQuickWidgetOnMac.git

    Thanks for helping.

    johngodJ 1 Reply Last reply
    0
    • H H.Mahmoodi

      Recently, I found that my app, when compiling on Mac, has a problem that is not available on my old laptop (old hardware specifications) on the Windows platform.

      And when I deleted so many widgets and eliminated other parts of my big-scale app, I found that the problem was in using QQuickWidget (maybe I was mistaking; I'm not sure).

      Actually, I have an QML that is loading by QQuickWidget on my widget's layout.

      I have other sliders and dials in that layout.

      • When I change the value of the sliders and dials by mouse (pressing the mouse wheel), my QML rendering has a problem (lags in framerate rendering).
      • When I emit the changing values by timer or anything in code, my QML is working right without problem.

      So I don't know why mouse events like pressing or wheel changing cause some lag in my QML (quickwidget). What's the problem? I'm confused. Should I consider something in compiling on Mac or any attributes? (Im new in Mac OS) [Qt 5.15.2, clang]

      mini project to test: https://github.com/SC-One/PerformanceIssueQQuickWidgetOnMac.git

      Thanks for helping.

      johngodJ Offline
      johngodJ Offline
      johngod
      wrote on last edited by
      #2

      @H-Mahmoodi Hi
      I just tested your app in my macbook air intel 2017, I didnt have any performance issues. What mac did you use ? You can profile your app, in QtCreator go to menu Analyze -> qml profiler, and check what is taking most time.

      I can tell you I had some performance problems with a app of mine in Mac, but it was working fine in windows and linux.
      In may app, I was moving with the mouse some Quick3D dinamics objects, the mouse move was lagging, real slow.
      The problem was that I was rebuilding the objects geometry in each mouse move, I change that to only update the vertex data in the mouse move, that improved a the performance a bit , but it was still slow. Then I change it to only update the objects Nodes position in the mouse move, it got much better. It seems that vertex data updates are costly in mac graphics, compared with my nvidia linux and windows machine.

      H 1 Reply Last reply
      0
      • johngodJ johngod

        @H-Mahmoodi Hi
        I just tested your app in my macbook air intel 2017, I didnt have any performance issues. What mac did you use ? You can profile your app, in QtCreator go to menu Analyze -> qml profiler, and check what is taking most time.

        I can tell you I had some performance problems with a app of mine in Mac, but it was working fine in windows and linux.
        In may app, I was moving with the mouse some Quick3D dinamics objects, the mouse move was lagging, real slow.
        The problem was that I was rebuilding the objects geometry in each mouse move, I change that to only update the vertex data in the mouse move, that improved a the performance a bit , but it was still slow. Then I change it to only update the objects Nodes position in the mouse move, it got much better. It seems that vertex data updates are costly in mac graphics, compared with my nvidia linux and windows machine.

        H Offline
        H Offline
        H.Mahmoodi
        wrote on last edited by
        #3

        @johngod Thanks for testing and giving some feedback.
        I tested that on two real macs (mini mac with M1 processor, Macbook Intel-based) and so many VM's customization on 3 OS, and all of them I had the same result... Laggy on changing the dials.
        The problem is that it's really confusing me. For example, when I measure time on a simple knob (https://github.com/SC-One/PerformanceIssueQQuickWidgetOnMac/blob/SpecialDial/KnobWidget.cpp), it's not using more than 2 ms (2 ms is for the very worst case, and usually it's less than 1m for any event like release mouse, press , move , paint , ...), so I thought the problem may be in QML, and it had no problem either. IDK, what's blocking GUI when using mouse events on MAC, while on such an old CPU, this simple scenario is working very nicely on Windows.
        Please, can I ask you what's exactly in the specifications of your Mac?
        Thanks for helping.

        johngodJ 1 Reply Last reply
        0
        • H H.Mahmoodi

          @johngod Thanks for testing and giving some feedback.
          I tested that on two real macs (mini mac with M1 processor, Macbook Intel-based) and so many VM's customization on 3 OS, and all of them I had the same result... Laggy on changing the dials.
          The problem is that it's really confusing me. For example, when I measure time on a simple knob (https://github.com/SC-One/PerformanceIssueQQuickWidgetOnMac/blob/SpecialDial/KnobWidget.cpp), it's not using more than 2 ms (2 ms is for the very worst case, and usually it's less than 1m for any event like release mouse, press , move , paint , ...), so I thought the problem may be in QML, and it had no problem either. IDK, what's blocking GUI when using mouse events on MAC, while on such an old CPU, this simple scenario is working very nicely on Windows.
          Please, can I ask you what's exactly in the specifications of your Mac?
          Thanks for helping.

          johngodJ Offline
          johngodJ Offline
          johngod
          wrote on last edited by johngod
          #4

          @H-Mahmoodi Hi

          It's this one https://www.itechguides.com/product-specs/apple-macbook-air-13-inch-2017/

          Edit: It's the core I5 1.8GHz version

          H 1 Reply Last reply
          0
          • johngodJ johngod

            @H-Mahmoodi Hi

            It's this one https://www.itechguides.com/product-specs/apple-macbook-air-13-inch-2017/

            Edit: It's the core I5 1.8GHz version

            H Offline
            H Offline
            H.Mahmoodi
            wrote on last edited by
            #5

            @johngod Thanks for the information; it helped me a lot.
            Sorry, I still have the problem, and I also tested on another Mac again (a few friends), and all have the same problem. (I am giving them the deployed app for some of them, and some of them build it themselves.)
            So I think maybe I'm doing something bad by building with versions or anything.
            Can you tell me exactly how you build it and run it? (As I said, I'm new to Mac, so maybe something is common among Mac's users that I didn't know.) For example, your Qt/Clang/Mac/etc. version,
            It's so weird for me. In the simplest scenario, we have this lag on six different Mac systems.

            johngodJ 1 Reply Last reply
            0
            • H H.Mahmoodi

              @johngod Thanks for the information; it helped me a lot.
              Sorry, I still have the problem, and I also tested on another Mac again (a few friends), and all have the same problem. (I am giving them the deployed app for some of them, and some of them build it themselves.)
              So I think maybe I'm doing something bad by building with versions or anything.
              Can you tell me exactly how you build it and run it? (As I said, I'm new to Mac, so maybe something is common among Mac's users that I didn't know.) For example, your Qt/Clang/Mac/etc. version,
              It's so weird for me. In the simplest scenario, we have this lag on six different Mac systems.

              johngodJ Offline
              johngodJ Offline
              johngod
              wrote on last edited by
              #6

              @H-Mahmoodi Hi

              I have buil a dmg for you to test https://drive.google.com/file/d/1H9oSji2dAJFv0LwrA5StL6n3kbP4rvjW/view?usp=sharing

              I have create it in the command line, with the following commands:

              cd /Users/joao/qt5projects/build-PerformanceIssueQQuickWidgetOnMac-Desktop_Qt_5_15_2_clang_64bit-Release
              
              ../../Qt/5.15.2/clang_64/bin/macdeployqt TestSliderMac.app -dmg -qmldir=/Users/joao/qt5projects/PerformanceIssueQQuickWidgetOnMac
              

              I have buil your app with Qt 5.15.2, clang, I just loaded it QtCreator and build it from there. My clang version:

              clang -v
              Apple clang version 14.0.0 (clang-1400.0.29.202)
              Target: x86_64-apple-darwin21.6.0
              Thread model: posix
              InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
              

              I have installed XCode before installing Qt.
              I hope this helps, let me know I how it goes.

              H 1 Reply Last reply
              1
              • johngodJ johngod

                @H-Mahmoodi Hi

                I have buil a dmg for you to test https://drive.google.com/file/d/1H9oSji2dAJFv0LwrA5StL6n3kbP4rvjW/view?usp=sharing

                I have create it in the command line, with the following commands:

                cd /Users/joao/qt5projects/build-PerformanceIssueQQuickWidgetOnMac-Desktop_Qt_5_15_2_clang_64bit-Release
                
                ../../Qt/5.15.2/clang_64/bin/macdeployqt TestSliderMac.app -dmg -qmldir=/Users/joao/qt5projects/PerformanceIssueQQuickWidgetOnMac
                

                I have buil your app with Qt 5.15.2, clang, I just loaded it QtCreator and build it from there. My clang version:

                clang -v
                Apple clang version 14.0.0 (clang-1400.0.29.202)
                Target: x86_64-apple-darwin21.6.0
                Thread model: posix
                InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
                

                I have installed XCode before installing Qt.
                I hope this helps, let me know I how it goes.

                H Offline
                H Offline
                H.Mahmoodi
                wrote on last edited by
                #7

                @johngod thanks a lot for guiding me,
                So I was building exactly like this, but there is still a performance issue.
                I think you forgot to enable moving images (I think you disabled moving images), and because of that, we cannot test it correctly.

                However, I build the app with so many versions of QT and clang, and also MacOS! but nothing was smooth in all of them. I build the same versions too, and again it's not smooth.

                I added a QML dial, a CustomDial (made simple by a widget), and a QDial widget, all of which block the GUI when pressed and change the dial values.
                You can download the DMG from here:
                https://github.com/SC-One/PerformanceIssueQQuickWidgetOnMac/releases/tag/EasyTestIssue

                johngodJ 1 Reply Last reply
                0
                • H H.Mahmoodi

                  @johngod thanks a lot for guiding me,
                  So I was building exactly like this, but there is still a performance issue.
                  I think you forgot to enable moving images (I think you disabled moving images), and because of that, we cannot test it correctly.

                  However, I build the app with so many versions of QT and clang, and also MacOS! but nothing was smooth in all of them. I build the same versions too, and again it's not smooth.

                  I added a QML dial, a CustomDial (made simple by a widget), and a QDial widget, all of which block the GUI when pressed and change the dial values.
                  You can download the DMG from here:
                  https://github.com/SC-One/PerformanceIssueQQuickWidgetOnMac/releases/tag/EasyTestIssue

                  johngodJ Offline
                  johngodJ Offline
                  johngod
                  wrote on last edited by
                  #8

                  @H-Mahmoodi HI

                  I forgot I had disabled the banner animation, sorry for that.
                  I think I totally misunderstood your post, when you talk about lag, you are refereing to the animation banner with the wolf, right ? I tought you were talking about the dials hanging and lagging when using the mouse wheel (I was focused on the buttons and did not nottice the banner lag).
                  I think you need to replace the Timer with FrameAnimation, check if this post it is of any help for you https://www.qt.io/blog/new-in-qt-6.4-frameanimation-element

                  H 1 Reply Last reply
                  1
                  • johngodJ johngod

                    @H-Mahmoodi HI

                    I forgot I had disabled the banner animation, sorry for that.
                    I think I totally misunderstood your post, when you talk about lag, you are refereing to the animation banner with the wolf, right ? I tought you were talking about the dials hanging and lagging when using the mouse wheel (I was focused on the buttons and did not nottice the banner lag).
                    I think you need to replace the Timer with FrameAnimation, check if this post it is of any help for you https://www.qt.io/blog/new-in-qt-6.4-frameanimation-element

                    H Offline
                    H Offline
                    H.Mahmoodi
                    wrote on last edited by
                    #9

                    @johngod Oh, sorry, I think I didn't explain well that...
                    but the whole scenario can't be changed (this example is a mini-example to show the problem; my app is large-scale, and the scenario is that).
                    But the problem is that,  when using the mouse on the dial, QTimer should not making this problem :/ because when I track the signals and connections , it is normal.! (and huge faltering on the image moving.)
                    Also, the other note is that my app on my old laptop (low-spec) that has Windows is working perfectly.

                    1 Reply Last reply
                    0
                    • H Offline
                      H Offline
                      H.Mahmoodi
                      wrote on last edited by H.Mahmoodi
                      #10

                      Edit(new info):
                      I tested the app, and it's working smoothly and well on Ubuntu 22 (like on Windows), but it's not smooth on the Mac when using Dials.

                      johngodJ 1 Reply Last reply
                      0
                      • H H.Mahmoodi

                        Edit(new info):
                        I tested the app, and it's working smoothly and well on Ubuntu 22 (like on Windows), but it's not smooth on the Mac when using Dials.

                        johngodJ Offline
                        johngodJ Offline
                        johngod
                        wrote on last edited by
                        #11

                        @H-Mahmoodi Hi

                        Try removing the flickable and timer and use only the image and a numberanimation

                        Image {
                                id: img
                                source: "qrc:/img.jpg"
                            }
                        
                            NumberAnimation {
                                id: anim
                                target: img
                                property: "x"
                                duration: 15000
                                from: -img.width
                                to: 0
                                loops: Animation.Infinite
                                running: true
                            }
                        
                        H 1 Reply Last reply
                        0
                        • johngodJ johngod

                          @H-Mahmoodi Hi

                          Try removing the flickable and timer and use only the image and a numberanimation

                          Image {
                                  id: img
                                  source: "qrc:/img.jpg"
                              }
                          
                              NumberAnimation {
                                  id: anim
                                  target: img
                                  property: "x"
                                  duration: 15000
                                  from: -img.width
                                  to: 0
                                  loops: Animation.Infinite
                                  running: true
                              }
                          
                          H Offline
                          H Offline
                          H.Mahmoodi
                          wrote on last edited by
                          #12

                          @johngod It's not possible because the timer is just simulating my problem; actually, I have a signal from C++ (in the backend) that updates the image's position in the flickable. and on average, it's updating at 60 fps.
                          I mean, I have a signal from outside to update the image's position.

                          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