Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-44069

Slowdown on Mac

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 5.4.0
    • None
    • OS X Yosemite 10.10.1
    • macOS

    Description

      I see significant QOpenGLWidget slowdown when manipulating with a Qt controls (for example sliders).
      Note that it occurs on Mac (OS-X Yosemite 10.10.1) and runs correctly on PC (Win 7 x64).
      Both my machines (PC,Mac) have GeForce 760 (latest NVidia drivers) and Qt 5.4.0 x64 (OpenGL desktop version).

      See the attached example. There are QOpenGLWidget, QLabel and QHorizontalSlider nested in QMainWindow.

      Here is a MainWindow setup:

      MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)

      { ui.setupUi(this); // main animation timer 1000/20 = 50 fps timer.setTimerType(Qt::PreciseTimer); connect(&timer, SIGNAL(timeout()), ui.glWidget, SLOT(update())); // timer simulating a user interaction 1000/50 = 20 fps sliderTimer.setTimerType(Qt::PreciseTimer); connect(&sliderTimer, SIGNAL(timeout()), SLOT(updateSlider())); // updateSlider set a random value of a slider connect(ui.glWidget, SIGNAL(fps(QString)), ui.label, SLOT(setText(QString))); timer.start(20); sliderTimer.start(50); // enable/disable sliderTimer here }

      Here is a GLWidget paint function:

      virtual void paintGL()
      {
      glClearColor( (frames & 0xFF) / 255.0f, 0, 0, 0); // simple animation
      glClear(GL_COLOR_BUFFER_BIT);

      // compute fps
      ++frames;
      if(timer.elapsed() >= 1000)

      { emit fps(QString::number(1000*frames / (float)timer.elapsed())); frames = 0; timer.restart(); }

      QThread::msleep(15); // emulate some expensive work (15 ms)
      }

      It should run at least 50 fps (I think that vsync is on by default).
      But on Mac it runs only at 40 fps.
      When you disable the sliderTimer - it runs at 50 fps, but when you are now dragging the slider with mouse, the fps drops to 30-40!

      This is really a problem, because in a complex app (multiple sliders, labels and other controls) it degrades the performance from 50 fps to 5-10 fps!

      My app (not the included simple example) runs at these frame rates:

      • 20 fps (GUI shown - a label is showing fps like in this example)
      • 5-10 fps (GUI shown and user is dragging a slider, which is not connected to a slot, so it does nothing!)
      • 30 fps (GUI hidden, only QOpenGLWidget shown)
      • 50 fps (GUI hidden, fullscreen mode)

      Strange is also a relative big different between a fullscreen and windowed mode.
      Note that there is no such problem on Windows platform (or it is not so significant).

      It seems that every Qt widget update (= changing slider value or label text) triggers QOpenGLWidget::update. I don't know if this is a correct behaviour. Why is QOpenGLWidget::update necessary, when only updating a QLabel text (without position/size change)? But the paint events should be serialized, so I really wonder what drops the fps down?

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              lagocs Laszlo Agocs
              rivierakid Martin Dusek
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes