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

QTimeLine's update interval is not accurate on macOS

    XMLWordPrintable

    Details

    • Platform/s:
      macOS

      Description

      Testcase:

      #include <QTimeLine>
      #include <QTest>
      #include <QSignalSpy>
      
      class Test : public QObject
      {
          Q_OBJECT
      private slots:
          void signalEmission()
          {
              QTimeLine timeLine(1000);
              timeLine.setUpdateInterval(1); // ms
              timeLine.setFrameRange(0, 12);
              QSignalSpy spy(&timeLine, &QTimeLine::frameChanged);
              QVERIFY(spy.isValid());
              timeLine.start();
              QTRY_COMPARE( spy.count(), 12 );
              for ( int i = 0; i < 12; ++i ) {
                  QCOMPARE( spy[i][0].toInt(), i + 1 );
              }
          }
      };
      
      QTEST_MAIN(Test)
      #include "main.moc"
      

      Please ignore the compare with i+1, which stems from QTBUG-41610.

      On macOS, and only on macOS, this test fails on the QTRY_COMPARE as only 9-10 signal emissions are recorded, not 12. This seems to be incompatible with the chosen update interval. Even the default (40ms = 25Hz) should suffice to get 12 activations in 1 second.

      Raising the overall duration of the QTimeline to 3+ seconds fixes this.

      Are timers in Qt 5 on macOS so inaccurate / so always massively "rounded up" that even the above cannot be guaranteed to work?

        Attachments

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

          Activity

            People

            Assignee:
            thiago Thiago Macieira
            Reporter:
            peppe Giuseppe D'Angelo
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes