Results 1 to 4 of 4

Thread: Techniques to determine what is blocking the gui thread

  1. #1
    Join Date
    Mar 2011
    Location
    Denmark
    Posts
    74
    Thanks
    7
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Techniques to determine what is blocking the gui thread

    Does anybody have some advice on the easiest way to determine what function call is blocking the gui thread?

    We have recently added a new loading spinner (QMovie) in our app - the animation is choppy for the first few seconds (if I run the spinner when the app is idle it works perfect) so it's obvious that something is blocking/taking to much time in the gui thread when the spinner is running.... my question is how to find it?

    Is there a general debugging technique I can use? Right now I am just commenting out functionality hoping to hit the right chunk - but it's a big app and there must be a better way!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Techniques to determine what is blocking the gui thread

    Quote Originally Posted by Berryblue031 View Post
    Does anybody have some advice on the easiest way to determine what function call is blocking the gui thread?
    Run your program under the debugger, when the GUI is blocked, interrupt the application (e.g. Ctrl+C when using gdb) and see what the top frame of the main thread is. That's your blocking call. You can trace it down to your code by checking lower frames (printing a backtrace is the simplest way to do this).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    Berryblue031 (11th April 2012)

  4. #3
    Join Date
    Sep 2011
    Posts
    21
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: Techniques to determine what is blocking the gui thread

    If you are using any loops try adding YourAppName.processEvents() inside the loop

    This is similar to DoEvents in VB.

    It allows the System/GUI to process any "Events" aka "Signals" that may be blocked during the loop.

    Hope this helps.

  5. #4
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Techniques to determine what is blocking the gui thread

    Or use some profiler that will show you where your app spends the time.

Similar Threads

  1. PyQT, QThread, thread blocking
    By Cirno in forum Newbie
    Replies: 0
    Last Post: 26th December 2011, 01:57
  2. QtConcurrent::blocking* thread count
    By ibex in forum Qt Programming
    Replies: 6
    Last Post: 26th January 2011, 12:48
  3. Non-Gui thread blocking gui
    By Valheru in forum Qt Programming
    Replies: 17
    Last Post: 12th February 2010, 11:11
  4. Best thread non-blocking technics
    By Tanuki-no Torigava in forum Qt Programming
    Replies: 0
    Last Post: 8th December 2009, 15:53
  5. How to determine if current thread is the UI thread
    By huangwf in forum Qt Programming
    Replies: 2
    Last Post: 21st September 2007, 08:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.