Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Serial communication stops when window is hidden or minimized on Mac

    General and Desktop
    macos macosx
    3
    4
    624
    Loading More Posts
    • 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.
    • T
      Tomassino last edited by

      I have a qt application using an instance of QSerialPort in a separate thread. The thread has its own event loop and I use QSerialPort asynchronously (i.e. no blocking calls, only signals and slots). The application works as expected on Windows and Linux, but serial communication stops after a while on Mac when the window is hidden or minimized. If I keep the application minimized it receives and sends few bytes from time to time. When the application has focus again, communication starts again as expected.

      I have almost no experience with Mac applications, but I've seen the same behavior in other applications using serial communication. I haven't found much on the web, so event tips on how to search documentation on this issue is highly appreciated :-)

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        That's likely because of macOS's App Nap facility.

        See this GitHub page about that subject and Qt.

        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 Reply Quote 4
        • K
          kuzulis Qt Champions 2020 last edited by

          QSerialPort relies on QSocketNotifier class. If a problem is in "App Nap" then all classes using QSocketNotifier (I guess) becomes unworked (as QAbstractSocket and so on).

          PS: If to be honet, I'm not faced with this issue before.

          1 Reply Last reply Reply Quote 0
          • T
            Tomassino last edited by Tomassino

            Thank you both very much for your help. I had a suspect that the problem was related to power saving because when on AC the problem was still present but intervals with no communication were shorter. Unfortunately I won't be able to test the solution in the linked page before a week or so. I will read something about App Nap in the meanwhile, now that I know what to look for :-)

            1 Reply Last reply Reply Quote 0
            • First post
              Last post