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. High cpu usage

High cpu usage

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 2 Posters 5.7k 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.
  • MetalMajorM Offline
    MetalMajorM Offline
    MetalMajor
    wrote on last edited by MetalMajor
    #1

    Hello,

    I have a problem where my QML program starts to consume more and more cpu. I used the QML profiler, and found no problems. So I started to look into some of the QSG_ and QML_ environment variables and found an option that fixes the cpu usage:

    export QT_OPENGL_NO_SANITY_CHECK=1
    

    This is apparently almost the same as using this:

    export QSG_RENDER_LOOP=threaded
    

    and makes use of the "threaded" rendering loop. This fixes my case, however, after a short amount of time, like 5 minutes or so, my application totally hangs in the GUI thread, waiting for an event to happen it seems.

    If I use the other threading loop types, either the "basic" or "windows" ones, I don't have the lockup, but the CPU usage just keeps increasing slowly, without getting stable, so it becomes unuseable after a while of course.

    I am using the following system:

    • Linux kernel 4.2.8-ckt10 from ubuntu wily
    • xorg 1.18.2
    • Qt 5.6.0
    • Intel HD Graphics 5500
    • Mesa 11.2.1

    I also tried with Qt 5.7.0 and it has the same problem. Also I have tried setting the system to not use the sg animation driver:

    export QSG_FIXED_ANIMATION_STEP=yes
    

    but that did not help either.

    I also checked that "glxgears" ran at 60 FPS so that my vsync is working, and it was ok.

    The thing is that I use the QtQuick.Windows library and I have 2 extra windows besides my main window, all created from within QML with "Window" items. So maybe it has something to do with this I don't know.

    Does anyone have a clue what could be the main issue here?

    MetalMajorM 1 Reply Last reply
    0
    • MetalMajorM MetalMajor

      Hello,

      I have a problem where my QML program starts to consume more and more cpu. I used the QML profiler, and found no problems. So I started to look into some of the QSG_ and QML_ environment variables and found an option that fixes the cpu usage:

      export QT_OPENGL_NO_SANITY_CHECK=1
      

      This is apparently almost the same as using this:

      export QSG_RENDER_LOOP=threaded
      

      and makes use of the "threaded" rendering loop. This fixes my case, however, after a short amount of time, like 5 minutes or so, my application totally hangs in the GUI thread, waiting for an event to happen it seems.

      If I use the other threading loop types, either the "basic" or "windows" ones, I don't have the lockup, but the CPU usage just keeps increasing slowly, without getting stable, so it becomes unuseable after a while of course.

      I am using the following system:

      • Linux kernel 4.2.8-ckt10 from ubuntu wily
      • xorg 1.18.2
      • Qt 5.6.0
      • Intel HD Graphics 5500
      • Mesa 11.2.1

      I also tried with Qt 5.7.0 and it has the same problem. Also I have tried setting the system to not use the sg animation driver:

      export QSG_FIXED_ANIMATION_STEP=yes
      

      but that did not help either.

      I also checked that "glxgears" ran at 60 FPS so that my vsync is working, and it was ok.

      The thing is that I use the QtQuick.Windows library and I have 2 extra windows besides my main window, all created from within QML with "Window" items. So maybe it has something to do with this I don't know.

      Does anyone have a clue what could be the main issue here?

      MetalMajorM Offline
      MetalMajorM Offline
      MetalMajor
      wrote on last edited by
      #2

      I have found a simple QML file which illustrates the problem. The problem occurs with the intel driver, and when using animations in multiple windows. See this code below which you can run with "qmlscene".

      So when one of the 2 numberanimations is commented out, there is no increase in cpu usage. It doesn't matter which one! But when they both are active, you get high cpu usage. With proprietary nvidia drivers, it seems I don't get the problem.

      import QtQuick 2.2
      import QtQuick.Window 2.0
      
      Window {
          title: qsTr("Two Window Testcase - Window 1")
          width: 640
          height: 480
          visible: true
      
          Rectangle {
      	id: r1
      	x: 50
      	y: 50
      	width: 75
      	height: 75
      	color: "red"
          }
      
          NumberAnimation {
            loops: Animation.Infinite
            from: 100
            to: 400
            running: true
            target: r1
            property: "width"
          }
      
          Window {
      	title: qsTr("Two Window Testcase - Window 2")
      	
      	width: 640
      	height: 480
      	visible: true
      
      	Rectangle {
      	    id: r
      	    x: 100
      	    y: 100
      	    width: 200
      	    height: 200
      	    color: "green"
      	}
      	
      	NumberAnimation {
      	  loops: Animation.Infinite
      	  from: 100
      	  to: 400
      	  running: true
      	  target: r
      	  property: "width"
      	}
          }
      }
      
      1 Reply Last reply
      0
      • MetalMajorM Offline
        MetalMajorM Offline
        MetalMajor
        wrote on last edited by
        #3

        Is there someone who can give me a clue on how I can disable ALL animations in qml?

        1 Reply Last reply
        0
        • MetalMajorM Offline
          MetalMajorM Offline
          MetalMajor
          wrote on last edited by
          #4

          The solution is:
          export QSG_RENDER_LOOP=threaded

          and in your own Qt application, set the init threads attribute:

          QCoreApplication::setAttribute(Qt::AA_X11InitThreads);

          This was a really annoying bug. Apparently X11 is used in some way. I thought Qt was only using xcb nowadays?

          So with qmlscene it can not be solved I think, you need your own application so you can set the attribute, BEFORE creating the QGuiApplication object!

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MRD7
            wrote on last edited by
            #5
            This post is deleted!
            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