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. QFileSystemModel Causing main thread to hang with Qt5.12

QFileSystemModel Causing main thread to hang with Qt5.12

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 4 Posters 2.1k 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.
  • B Offline
    B Offline
    BrianN
    wrote on last edited by kshegunov
    #1

    My application worked normally under Qt 5.11 and MSVC2015. I moved to Qt5.12 and MSVC2017 and now my main thread hangs for 5 - 10s at start up. After this time delay it functions normally. Excluding the QFileSystemModel part of the code and there is no issue.

    I can replicate the effect with a minimalist application.

    dialog.h

    #ifndef DIALOG_H
    #define DIALOG_H
    
    #include <QDialog>
    #include <QFileSystemModel>
    
    namespace Ui {
    class Dialog;
    }
    
    class Dialog : public QDialog
    {
        Q_OBJECT
    
    public:
        explicit Dialog(QWidget *parent = nullptr);
        ~Dialog();
    
    private:
        Ui::Dialog *ui;
    
        QFileSystemModel *dirModel;
    
    };
    
    #endif // DIALOG_H
    

    dialog.cpp

    #include "dialog.h"
    #include "ui_dialog.h"
    
    Dialog::Dialog(QWidget *parent) :
        QDialog(parent),
        ui(new Ui::Dialog)
    {
        ui->setupUi(this);
    
        QString mPath = "C:/";
    
        dirModel = new QFileSystemModel(this);
    
        dirModel->setRootPath(mPath);
    
        ui->treeView->setModel(dirModel);
    
    }
    
    Dialog::~Dialog()
    {
        delete ui;
    }
    

    I do not know how to investigate the main thread hang further. Any suggestions would be helpful.

    Brian

    [Added code tags ~kshegunov]

    kshegunovK 1 Reply Last reply
    0
    • B BrianN

      My application worked normally under Qt 5.11 and MSVC2015. I moved to Qt5.12 and MSVC2017 and now my main thread hangs for 5 - 10s at start up. After this time delay it functions normally. Excluding the QFileSystemModel part of the code and there is no issue.

      I can replicate the effect with a minimalist application.

      dialog.h

      #ifndef DIALOG_H
      #define DIALOG_H
      
      #include <QDialog>
      #include <QFileSystemModel>
      
      namespace Ui {
      class Dialog;
      }
      
      class Dialog : public QDialog
      {
          Q_OBJECT
      
      public:
          explicit Dialog(QWidget *parent = nullptr);
          ~Dialog();
      
      private:
          Ui::Dialog *ui;
      
          QFileSystemModel *dirModel;
      
      };
      
      #endif // DIALOG_H
      

      dialog.cpp

      #include "dialog.h"
      #include "ui_dialog.h"
      
      Dialog::Dialog(QWidget *parent) :
          QDialog(parent),
          ui(new Ui::Dialog)
      {
          ui->setupUi(this);
      
          QString mPath = "C:/";
      
          dirModel = new QFileSystemModel(this);
      
          dirModel->setRootPath(mPath);
      
          ui->treeView->setModel(dirModel);
      
      }
      
      Dialog::~Dialog()
      {
          delete ui;
      }
      

      I do not know how to investigate the main thread hang further. Any suggestions would be helpful.

      Brian

      [Added code tags ~kshegunov]

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      Interrupt the debugger whenever that delay happens and extract a stack trace for the running threads (I recommend having a debug Qt build for this). From there you can try to trace back where the issue is. QFileSystemModel is supposed to query the filesystem in its own thread, so what you describe is rather odd.

      Read and abide by the Qt Code of Conduct

      B 1 Reply Last reply
      3
      • kshegunovK kshegunov

        Interrupt the debugger whenever that delay happens and extract a stack trace for the running threads (I recommend having a debug Qt build for this). From there you can try to trace back where the issue is. QFileSystemModel is supposed to query the filesystem in its own thread, so what you describe is rather odd.

        B Offline
        B Offline
        BrianN
        wrote on last edited by
        #3

        @kshegunov

        My knowledge is limited as far as debugging this further.

        If I interrupt the app during debugging I can see this but it does not mean much to me.

        0_1544641319427_65e631f6-03c0-4912-9171-161958bd4400-image.png

        Brian

        kshegunovK 1 Reply Last reply
        0
        • B BrianN

          @kshegunov

          My knowledge is limited as far as debugging this further.

          If I interrupt the app during debugging I can see this but it does not mean much to me.

          0_1544641319427_65e631f6-03c0-4912-9171-161958bd4400-image.png

          Brian

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by kshegunov
          #4

          GetVolumeInformationW shouldn't be there and I can't fathom how it got called ... Can you extract the whole stack trace as text (there should be a context menu entry, i.e. right click, in the shown view pane)? I can't see what's the root of the stack from the image.

          PS.
          That method is to get the device(s) information. It's called here, and as far as I can tell only there ... so this doesn't add up.

          Read and abide by the Qt Code of Conduct

          B 1 Reply Last reply
          1
          • kshegunovK kshegunov

            GetVolumeInformationW shouldn't be there and I can't fathom how it got called ... Can you extract the whole stack trace as text (there should be a context menu entry, i.e. right click, in the shown view pane)? I can't see what's the root of the stack from the image.

            PS.
            That method is to get the device(s) information. It's called here, and as far as I can tell only there ... so this doesn't add up.

            B Offline
            B Offline
            BrianN
            wrote on last edited by
            #5

            @kshegunov

            Sorry for the delay, I am on USA time.

            1 ZwOpenFile ntdll_77aa0000 0x77b0a56c
            2 GetVolumeInformationW KERNELBASE 0x7455d5b5
            3 QTreeViewPrivate::layout Qt5Widgetsd 0x6474aaae
            4 QTreeViewPrivate::layout Qt5Widgetsd 0x6474b7ab
            5 QTreeViewPrivate::layout Qt5Widgetsd 0x6474661c
            6 QTextCodec::codecForHtml Qt5Cored 0x6718737d
            7 QTextCodec::codecForHtml Qt5Cored 0x671818f6
            8 QTreeViewPrivate::layout Qt5Widgetsd 0x647492a0
            9 QTreeViewPrivate::layout Qt5Widgetsd 0x6447879b
            10 QTreeViewPrivate::layout Qt5Widgetsd 0x644747c5
            11 QTextCodec::codecForHtml Qt5Cored 0x671384fc
            12 QTextCodec::codecForHtml Qt5Cored 0x67136879
            13 QTextCodec::codecForHtml Qt5Cored 0x671398f9
            14 QTextCodec::codecForHtml Qt5Cored 0x671d8354
            15 qt_plugin_instance qwindowsd 0xf10c5e0
            16 QTextCodec::codecForHtml Qt5Cored 0x671d699b
            17 _InternalCallWinProc USER32 0x7505bf1b
            18 UserCallWinProcCheckWow USER32 0x750583ea
            19 DispatchMessageWorker USER32 0x75057c9e
            20 DispatchMessageW USER32 0x75057a80
            21 QTextCodec::codecForHtml Qt5Cored 0x671d70d9
            22 qt_plugin_instance qwindowsd 0xf10c5b8
            23 QTextCodec::codecForHtml Qt5Cored 0x6713371c
            24 QTextCodec::codecForHtml Qt5Cored 0x67133927
            25 QTextCodec::codecForHtml Qt5Cored 0x67136692
            26 QGuiApplication::keyboardModifiers Qt5Guid 0x14c06a8
            27 QTreeViewPrivate::layout Qt5Widgetsd 0x64474329
            28 main main.cpp 10 0xc2280f
            29 WinMain qtmain_win.cpp 104 0xc25f9d
            30 invoke_main exe_common.inl 107 0xc241ce
            31 __scrt_common_main_seh exe_common.inl 288 0xc24037
            32 __scrt_common_main exe_common.inl 331 0xc23ecd
            33 WinMainCRTStartup exe_winmain.cpp 17 0xc24248
            34 BaseThreadInitThunk KERNEL32 0x77728484
            35 __RtlUserThreadStart ntdll_77aa0000 0x77b0302c
            36 _RtlUserThreadStart ntdll_77aa0000 0x77b02ffa

            kshegunovK 1 Reply Last reply
            0
            • aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Probably this usage is more involved in the problem - even if I don't see it in the stack trace either.

              But I think more interesting would be, why it hangs there, of course. Probably asking for a non-existing, ejected or non-reachable network drive?

              Qt has to stay free or it will die.

              B 1 Reply Last reply
              2
              • aha_1980A aha_1980

                Probably this usage is more involved in the problem - even if I don't see it in the stack trace either.

                But I think more interesting would be, why it hangs there, of course. Probably asking for a non-existing, ejected or non-reachable network drive?

                B Offline
                B Offline
                BrianN
                wrote on last edited by
                #7

                @aha_1980

                I do have a 'Google Drive' showing up and perhaps it is taking time to read that.

                It seems to hang 90% of the time I try it but sometimes it is not hanging.

                Never had an issue with 5.11 and MSVC2015, only now with 5.12 and MSVC2017.

                Has anything changed in this area 5.11 to 5.12? Any reason why it is hanging the main thread as it should be in its own for just this reason?

                aha_1980A 1 Reply Last reply
                0
                • B BrianN

                  @aha_1980

                  I do have a 'Google Drive' showing up and perhaps it is taking time to read that.

                  It seems to hang 90% of the time I try it but sometimes it is not hanging.

                  Never had an issue with 5.11 and MSVC2015, only now with 5.12 and MSVC2017.

                  Has anything changed in this area 5.11 to 5.12? Any reason why it is hanging the main thread as it should be in its own for just this reason?

                  aha_1980A Offline
                  aha_1980A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on last edited by aha_1980
                  #8

                  Hi @BrianN,

                  can you try again with "unmounted" Google Drive? Just to be sure we're on the right track.

                  Any reason why it is hanging the main thread as it should be in its own for just this reason?

                  No idea. But there are two reports: QTBUG-69086 and QTBUG-65977 that seems related to your problem.

                  You should probably comment (and vote) at least at the first report to show the interest in the problem.

                  Regards

                  Qt has to stay free or it will die.

                  B 1 Reply Last reply
                  3
                  • mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Hi
                    Just as a note:
                    What windows version are you seeing this on ?
                    Windows 7 has very long timeout for shares where as much faster
                    in windows 10.

                    1 Reply Last reply
                    1
                    • aha_1980A aha_1980

                      Hi @BrianN,

                      can you try again with "unmounted" Google Drive? Just to be sure we're on the right track.

                      Any reason why it is hanging the main thread as it should be in its own for just this reason?

                      No idea. But there are two reports: QTBUG-69086 and QTBUG-65977 that seems related to your problem.

                      You should probably comment (and vote) at least at the first report to show the interest in the problem.

                      Regards

                      B Offline
                      B Offline
                      BrianN
                      wrote on last edited by
                      #10

                      @aha_1980

                      Disabling Google Drive File Stream made a 95% improvement. I still noticed one delay at start up.

                      I am using Windows 10.

                      I will check those bug reports now as suggested.

                      Thanks

                      1 Reply Last reply
                      1
                      • B BrianN

                        @kshegunov

                        Sorry for the delay, I am on USA time.

                        1 ZwOpenFile ntdll_77aa0000 0x77b0a56c
                        2 GetVolumeInformationW KERNELBASE 0x7455d5b5
                        3 QTreeViewPrivate::layout Qt5Widgetsd 0x6474aaae
                        4 QTreeViewPrivate::layout Qt5Widgetsd 0x6474b7ab
                        5 QTreeViewPrivate::layout Qt5Widgetsd 0x6474661c
                        6 QTextCodec::codecForHtml Qt5Cored 0x6718737d
                        7 QTextCodec::codecForHtml Qt5Cored 0x671818f6
                        8 QTreeViewPrivate::layout Qt5Widgetsd 0x647492a0
                        9 QTreeViewPrivate::layout Qt5Widgetsd 0x6447879b
                        10 QTreeViewPrivate::layout Qt5Widgetsd 0x644747c5
                        11 QTextCodec::codecForHtml Qt5Cored 0x671384fc
                        12 QTextCodec::codecForHtml Qt5Cored 0x67136879
                        13 QTextCodec::codecForHtml Qt5Cored 0x671398f9
                        14 QTextCodec::codecForHtml Qt5Cored 0x671d8354
                        15 qt_plugin_instance qwindowsd 0xf10c5e0
                        16 QTextCodec::codecForHtml Qt5Cored 0x671d699b
                        17 _InternalCallWinProc USER32 0x7505bf1b
                        18 UserCallWinProcCheckWow USER32 0x750583ea
                        19 DispatchMessageWorker USER32 0x75057c9e
                        20 DispatchMessageW USER32 0x75057a80
                        21 QTextCodec::codecForHtml Qt5Cored 0x671d70d9
                        22 qt_plugin_instance qwindowsd 0xf10c5b8
                        23 QTextCodec::codecForHtml Qt5Cored 0x6713371c
                        24 QTextCodec::codecForHtml Qt5Cored 0x67133927
                        25 QTextCodec::codecForHtml Qt5Cored 0x67136692
                        26 QGuiApplication::keyboardModifiers Qt5Guid 0x14c06a8
                        27 QTreeViewPrivate::layout Qt5Widgetsd 0x64474329
                        28 main main.cpp 10 0xc2280f
                        29 WinMain qtmain_win.cpp 104 0xc25f9d
                        30 invoke_main exe_common.inl 107 0xc241ce
                        31 __scrt_common_main_seh exe_common.inl 288 0xc24037
                        32 __scrt_common_main exe_common.inl 331 0xc23ecd
                        33 WinMainCRTStartup exe_winmain.cpp 17 0xc24248
                        34 BaseThreadInitThunk KERNEL32 0x77728484
                        35 __RtlUserThreadStart ntdll_77aa0000 0x77b0302c
                        36 _RtlUserThreadStart ntdll_77aa0000 0x77b02ffa

                        kshegunovK Offline
                        kshegunovK Offline
                        kshegunov
                        Moderators
                        wrote on last edited by
                        #11

                        My suspicion was a network share causing too long to respond. But I still don't understand this stack trace. There's system function calls that are mixed in the wrong places ...

                        Read and abide by the Qt Code of Conduct

                        B 1 Reply Last reply
                        1
                        • kshegunovK kshegunov

                          My suspicion was a network share causing too long to respond. But I still don't understand this stack trace. There's system function calls that are mixed in the wrong places ...

                          B Offline
                          B Offline
                          BrianN
                          wrote on last edited by
                          #12

                          @kshegunov

                          I am a novice when it comes to stack traces. Is anyone able to duplicate the small program I am using for testing or can anyone guide me with further tests to carry out?

                          Brian

                          kshegunovK 1 Reply Last reply
                          0
                          • B BrianN

                            @kshegunov

                            I am a novice when it comes to stack traces. Is anyone able to duplicate the small program I am using for testing or can anyone guide me with further tests to carry out?

                            Brian

                            kshegunovK Offline
                            kshegunovK Offline
                            kshegunov
                            Moderators
                            wrote on last edited by
                            #13

                            I don't have windows, but I could run it on Linux. However I really doubt it'd manifest the problem. As a side question, have you built Qt yourself, or did you install from a prebuilt package? If you got it ready-made it can be that some debug optimizations are in place, but still the stack trace seems very odd.

                            Read and abide by the Qt Code of Conduct

                            B 1 Reply Last reply
                            0
                            • kshegunovK kshegunov

                              I don't have windows, but I could run it on Linux. However I really doubt it'd manifest the problem. As a side question, have you built Qt yourself, or did you install from a prebuilt package? If you got it ready-made it can be that some debug optimizations are in place, but still the stack trace seems very odd.

                              B Offline
                              B Offline
                              BrianN
                              wrote on last edited by
                              #14

                              @kshegunov

                              Sorry for the delay, moved from USA to UK.

                              I took the standard prebuilt Qt package. Not sure what it has for debug in place?

                              Brian

                              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