Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QTimer issue on iOS
Forum Updated to NodeBB v4.3 + New Features

QTimer issue on iOS

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
9 Posts 4 Posters 2.0k Views 3 Watching
  • 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.
  • X Offline
    X Offline
    xtingray
    wrote on last edited by xtingray
    #1

    Hi!

    As part of my iOS app, I am using a QTimer object to call a method every X milliseconds. Nothing out of this world:

       timer->start(milliseconds);
    

    I have been testing the same code either in Android and Windows and the performance of the timer is accurate. My problem occurs specifically in iOS, where the method called by the timer is executed with a constant interval of time, in despite of the value I set for the milliseconds variable.

    Is there any reference about considerations of using QTimer variables or real time resources in iOS?

    Thanks.


    Qt Developer

    ekkescornerE 1 Reply Last reply
    0
    • X xtingray

      Hi!

      As part of my iOS app, I am using a QTimer object to call a method every X milliseconds. Nothing out of this world:

         timer->start(milliseconds);
      

      I have been testing the same code either in Android and Windows and the performance of the timer is accurate. My problem occurs specifically in iOS, where the method called by the timer is executed with a constant interval of time, in despite of the value I set for the milliseconds variable.

      Is there any reference about considerations of using QTimer variables or real time resources in iOS?

      Thanks.

      ekkescornerE Offline
      ekkescornerE Offline
      ekkescorner
      Qt Champions 2016
      wrote on last edited by
      #2

      @xtingray how are you setting your milliseconds exactly ?

      ekke ... Qt Champion 2016 | 2024 ... mobile business apps
      5.15 --> 6.9 https://t1p.de/ekkeChecklist
      QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xtingray
        wrote on last edited by
        #3

        My implementation is about a player of a sequence of images simulating an animation reproducer.

        play(int fps) {
           int milliseconds = 1000/fps;
           timer->start(milliseconds);
        }
        

        fps is a value between 1 and 50. As I said before this works perfect in Android and Windows.


        Qt Developer

        ekkescornerE 1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          You can try to change the timer type for Qt::PreciseTimer check the implication for doing so.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • X Offline
            X Offline
            xtingray
            wrote on last edited by
            #5

            I tried your advice with no luck:

               timer = new QTimer(this);
               timer->setTimerType(Qt::PreciseTimer);
               connect(timer, &QTimer::timeout, this, &Reproducer::play);
            

            The difference is quite evident comparing Android performance vs iOS. Same code.


            Qt Developer

            1 Reply Last reply
            0
            • X xtingray

              My implementation is about a player of a sequence of images simulating an animation reproducer.

              play(int fps) {
                 int milliseconds = 1000/fps;
                 timer->start(milliseconds);
              }
              

              fps is a value between 1 and 50. As I said before this works perfect in Android and Windows.

              ekkescornerE Offline
              ekkescornerE Offline
              ekkescorner
              Qt Champions 2016
              wrote on last edited by
              #6

              @xtingray said in QTimer issue on iOS:

              My implementation is about a player of a sequence of images simulating an animation reproducer.

              play(int fps) {
                 int milliseconds = 1000/fps;
                 timer->start(milliseconds);
              }
              

              looks good. I remember problems where - in qml - setting the timeout as x*60 or so could cause problems
              have overlooked that you're doing it from c++

              will verify if my timers are working correct on iOS

              ekke ... Qt Champion 2016 | 2024 ... mobile business apps
              5.15 --> 6.9 https://t1p.de/ekkeChecklist
              QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Morfio
                wrote on last edited by
                #7

                Hi,

                I've got the same issue. Is there a solution?

                Best regards,

                Morfio

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  Morfio
                  wrote on last edited by
                  #8

                  Oh, I'm sorry. It's not a timer problem. It's a QPixmapItem::setPosition problem. If I set the the x position (maybe QPixmapItem::position()x() + 10) it slows down the framerate from ~77 to ~8. Does anyone know, why? On Windows, FreeBSD and Android it works great.

                  M 1 Reply Last reply
                  0
                  • M Morfio

                    Oh, I'm sorry. It's not a timer problem. It's a QPixmapItem::setPosition problem. If I set the the x position (maybe QPixmapItem::position()x() + 10) it slows down the framerate from ~77 to ~8. Does anyone know, why? On Windows, FreeBSD and Android it works great.

                    M Offline
                    M Offline
                    Morfio
                    wrote on last edited by
                    #9

                    @Morfio I didn't mean QPixmapItem: QGraphicsPixmapItem

                    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