Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. QWebPage/QWebFrame Slowing Down GUI
QtWS25 Last Chance

QWebPage/QWebFrame Slowing Down GUI

Scheduled Pinned Locked Moved Qt WebKit
9 Posts 3 Posters 3.2k Views
  • 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.
  • K Offline
    K Offline
    kbarresi
    wrote on last edited by
    #1

    Hi

    I'm trying to do some preloading of web pages behind the scenes, and then cache everything to display later.

    I tried directly creating a QWebPage without displaying it, but that caused some pretty bad GUI slowdowns. I did some investigations, and I heard problems where people were having blocking issues with the QNetworkAccessManager inside the QWebFrame. To take care of this, I put the network stuff inside a thread.

    However, the blocking continues. I've narrowed it down to this line, where pReply is the QNetworkReply from the networking thread:
    @this->page->mainFrame()->setHtml(pReply->readAll());@

    I do not believe setHtml is blocking, but it definitely seems to be messing with the GUI's responsiveness for a solid 1-1.5 seconds. I would move the page into another thread, but we all know that wouldn't work.

    Any ideas? I'm thoroughly stumped

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kbarresi
      wrote on last edited by
      #2

      Any suggestions? Still stuck on this and haven't made any new progress :(

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kbarresi
        wrote on last edited by
        #3

        I've narrowed down the issue to the actual painting of the frame.

        What I think is happening is that any form of setContent() is blocking the event loop from processing anything quickly enough, until setContent is finished and the frame has been painted.

        Can I somehow increase the priority of one widget over another?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AcerExtensa
          wrote on last edited by
          #4

          How do you use your threads? Take a look here: http://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/

          Can you show your code where the thread is created and how do you get reply back into main thread. I have done this time ago and haven't saw any kind of slow down.

          Have you looked at QNetworkDiskCache?

          God is Real unless explicitly declared as Integer.

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kbarresi
            wrote on last edited by
            #5

            Hi Acerextensa,

            I have all my network stuff inside the run() function of a QThread, and then when it finishes, emits a signal to let me know. I made sure to call exec() at the end of run(), and call exit() when I finish.

            Unfortunately, I don't think the network activity is the bottleneck here.

            Here's my QThread class anyway:

            @void NetworkWorker::run() {
            this->NAM = new QNetworkAccessManager();
            QObject::connect(NAM, SIGNAL(finished(QNetworkReply*)), this, SLOT(requestComplete(QNetworkReply*)));

            QNetworkRequest *request = new QNetworkRequest(this->url);
            request->setRawHeader("charset", "utf-8");
            request->setRawHeader("Connection", "keep-alive");
            this->NAM->get(*request);
            
            exec();
            

            }

            void NetworkWorker::requestComplete(QNetworkReply *pReply) {
            emit finishedLoading(pReply);
            exit();
            }@

            1 Reply Last reply
            0
            • A Offline
              A Offline
              AcerExtensa
              wrote on last edited by
              #6

              Follow the link I have posted for you. And why do you create QNetworkRequest dynamically and didn't delete it at all... Like I've said no slow down detected by testing... Post your entire project if you can... maybe the problem is somewhere else...

              God is Real unless explicitly declared as Integer.

              1 Reply Last reply
              0
              • K Offline
                K Offline
                kbarresi
                wrote on last edited by
                #7

                That link was a good read, thanks. I'll try subclassing as a QObject instead of QThread from now on. And good catch, I completely overlooked that.

                On another note, I profiled the application to solidify what exactly is causing the issue. Here's a picture showing what's happening. The red circle is the part that's causing the issue, and the green circle is my NetworkWorker in its own thread. !http://i.imgur.com/iC4FlUw.png(Diagram)!

                In the the trouble area, QWebSettings::handle is eating up most of the resources. From what I see, it keeps calling QRectF::width a bunch of times. Part of rendering the webpage maybe?

                1 Reply Last reply
                0
                • W Offline
                  W Offline
                  wpurvis
                  wrote on last edited by
                  #8

                  Did you make any progress on this or find a solution?

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    kbarresi
                    wrote on last edited by
                    #9

                    Unfortunately, I haven't. Any QWebView seems to really mess with the gui thread.

                    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