Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt application severe hangs on process->start()
Forum Updated to NodeBB v4.3 + New Features

Qt application severe hangs on process->start()

Scheduled Pinned Locked Moved Unsolved General and Desktop
26 Posts 5 Posters 3.9k Views 2 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.
  • S Offline
    S Offline
    sprkxr
    wrote on last edited by
    #17

    Haha, I googled the description of Instrument.
    Instrument in Xcode is a powerful tool for analyzing and optimizing iOS and macOS apps for performance issues. It provides multiple tools, including Time Profiler, Memory Graph, Energy Log, and Network Activity, to help developers understand performance bottlenecks and potential problems of applications.

    You can perform the following operations by using the Instrument:

    Performance analysis: Use the Time Profiler to trace and analyze the CPU usage of applications, helping identify performance bottlenecks and optimization opportunities.
    Memory analysis: Use the Memory Graph to examine the memory usage of your application and find memory problems such as memory leaks and circular references.
    Energy consumption analysis: Use the energy consumption analyzer (Energy Log) to monitor the energy consumption of applications and find out the codes and resources that consume much power.

    JonBJ 1 Reply Last reply
    0
    • S sprkxr

      Haha, I googled the description of Instrument.
      Instrument in Xcode is a powerful tool for analyzing and optimizing iOS and macOS apps for performance issues. It provides multiple tools, including Time Profiler, Memory Graph, Energy Log, and Network Activity, to help developers understand performance bottlenecks and potential problems of applications.

      You can perform the following operations by using the Instrument:

      Performance analysis: Use the Time Profiler to trace and analyze the CPU usage of applications, helping identify performance bottlenecks and optimization opportunities.
      Memory analysis: Use the Memory Graph to examine the memory usage of your application and find memory problems such as memory leaks and circular references.
      Energy consumption analysis: Use the energy consumption analyzer (Energy Log) to monitor the energy consumption of applications and find out the codes and resources that consume much power.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #18

      @sprkxr
      Yes, that is what "instrumentation" means. It can also cause "problems" in the execution of programs, sometimes. One issue it might have is that if you are instrumenting a program and that spawns a sub-process it might get "confused" about which one to follow.

      I asked/suggested you try your application outside of any instrumentation, and preferably/possibly outside of XCode too, and see whether issues persist?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sprkxr
        wrote on last edited by
        #19

        I restarted my mac and closed all other programs. Change QProcess to QProcess* process = new QProcess (); And tried system () and process->start then recompile my project, the problem persists, and system () for a short time before crashing 🙂 (I added the log to see the system executing my commands during this time) doesn't cause my project to freeze, QProcess doesn't cause a crash but every time it's called it causes the whole program to freeze.About every 5 seconds, it freezes for more than 1 second and closer to 2 seconds

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mliberato-pax
          wrote on last edited by
          #20

          Just found the solution to a similar problem I was having here, it was linked to macOS application hibernation called App Nap. Initial explanation of the problem was discovered here. In my python application I was able to utilize appnope to get around it.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sprkxr
            wrote on last edited by
            #21

            Bafflingly,I used this method

                [[NSProcessInfo processInfo]
                beginActivityWithOptions:NSActivityUserInitiated
            

            to close the App Nap still did not solve the problem, and finally had to use NSTask successfully solved the problem.

            SGaistS 1 Reply Last reply
            0
            • S sprkxr

              Bafflingly,I used this method

                  [[NSProcessInfo processInfo]
                  beginActivityWithOptions:NSActivityUserInitiated
              

              to close the App Nap still did not solve the problem, and finally had to use NSTask successfully solved the problem.

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #22

              @sprkxr how did you use it ? It might be useful for other people :-)

              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
              0
              • S Offline
                S Offline
                sprkxr
                wrote on last edited by
                #23

                I actually didn't find a solution to the problem I described above. I use NSTask instead of QProcess. I rewrote this part of the code and circumvented the problem. NSTask is a native Mac function similar to QProcess.

                1 Reply Last reply
                0
                • jeremy_kJ jeremy_k

                  @JonB said in Qt application severe hangs on process->start():

                  So your QProcess *process goes out of scope at the end of the function and is destroyed while the sub-process is still running. Which is bad.

                  ...for some definition of bad.

                  QProcess::~QProcess():

                  Destructs the QProcess object, i.e., killing the process.
                  
                  Note that this function will not return until the process is terminated.
                  
                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #24

                  @jeremy_k said in Qt application severe hangs on process->start():

                  ...for some definition of bad.

                  Hi Jeremy. Now that this issue is resolved for the OP. It was bothering me so I went back to check the behaviour of destructing a QProcess while a long-running start(...) process is still running, It is indeed true that destructor "kills" it, but per my vague recollection writes to the Application Output pane warning message QProcess: Destroyed while process ("find") is still running.. Which people have asked about in the past. So clearly Qt code thinks this is "bad", and expects you to e.g. terminate() it yourself before letting instance run out of scope. Just saying (for anyone reading this).

                  jeremy_kJ 1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    sprkxr
                    wrote on last edited by
                    #25

                    Very, very feeling to all who answered my question. Although my problem was solved using another method, I'm still trying to figure out the root cause of the problem, so if anyone has encountered the same problem and figured out what the problem is, I'd appreciate it if you could let me know.

                    1 Reply Last reply
                    0
                    • JonBJ JonB

                      @jeremy_k said in Qt application severe hangs on process->start():

                      ...for some definition of bad.

                      Hi Jeremy. Now that this issue is resolved for the OP. It was bothering me so I went back to check the behaviour of destructing a QProcess while a long-running start(...) process is still running, It is indeed true that destructor "kills" it, but per my vague recollection writes to the Application Output pane warning message QProcess: Destroyed while process ("find") is still running.. Which people have asked about in the past. So clearly Qt code thinks this is "bad", and expects you to e.g. terminate() it yourself before letting instance run out of scope. Just saying (for anyone reading this).

                      jeremy_kJ Offline
                      jeremy_kJ Offline
                      jeremy_k
                      wrote on last edited by
                      #26

                      Yup, there is a qWarning(). Its presence predates the modularization project, and the oldest repo clone I have at the moment. As such, I can't tell if the warning and the behavior in question were from the same author. There are other qWarnings() that don't appear to indicate a problematic condition.

                      Compare this to the documentation for QThread::~QThread() prior to 6.3, which clearly indicates a "bad" situation.

                      Note that deleting a QThread object will not stop the execution of the thread it manages. Deleting a running QThread (i.e. isFinished() returns false) will result in a program crash.
                      

                      Qt developers, or "the trolls", aren't a hive mind. The people who work on it have differing, and changing, and sometimes outright conflicting opinions. Sometimes they make mistakes.

                      Asking a question about code? http://eel.is/iso-c++/testcase/

                      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