0

I'm trying to preload a few webpages in a series of hidden QWebFrames before I show them. However, I've found that the setContent method for a QWebFrame causes the GUI to become unresponsive.

I've tried putting the actual network activity in a separate thread and giving it to the QWebFrame as a QByteArray, but that doesn't help, leading me to believe that it is the painting of the page that is causing the ~1.5 second, very noticeable slowdown.

QByteArray data = pReply->readAll();       //get the content from a QNetworkReply
this->page->mainFrame()->setContent(data); //this is the line that causes the problem

I'm completely stumped and I don't know what to try, since I can't put the entire web frame in its own thread.

Has anyone run into this before and have any suggestions?

Update I profiled the application and confirmed that setContent is the root of the problem.

Update 2 I profiled the application using Intel VTune. I found that QWebKit is indeed taking up over 100% of the CPU time. The QWebSettings::handle usage jumped out at me as what appears to be using the most resources, and I can confirm that it is hogging up the main thread.

enter image description here

K. Barresi
  • 1,275
  • 1
  • 21
  • 46
  • If you can run your program under a profiler, it can tell you what routines are taking up the bulk of the CPU cycles, which might give you a clue about what the problem is. Under recent versions of MacOS/X it's particularly easy, just open up Activity Monitor while your program is exhibiting the fault, select your program's process, and click the "Sample Process" icon at the upper left of the window. – Jeremy Friesner May 27 '13 at 20:39
  • Thanks, I'll post result as soon as I do that – K. Barresi May 27 '13 at 20:49
  • Just a standard webpage like Google. Nothing obnoxious – K. Barresi May 27 '13 at 21:14
  • Have you tried using setUrl() instead of setContent()? It's possible setUrl() may load the content more asynchronously, thus keeping your application responsive. Not sure, but worth a try. – WaltPurvis May 28 '13 at 04:21
  • I have tried that, thanks though auh – K. Barresi May 28 '13 at 04:33
  • 1
    Maybe ask the person who write that threading article you liked. She's written a complete Qt WebKit application and might have encountered/solved the problem: http://www.mayaposch.com/wildfox.php – WaltPurvis May 28 '13 at 20:52
  • Oooh it looks like she posted the source on GitHub...looking through it now – K. Barresi May 28 '13 at 21:20

1 Answers1

0

Unfortunately, I haven't found a workaround for this. I'm figuring out ways to mask the slowdown in the application itself as a way of coping. If anyone posts any better ideas, I'll accept their answer.

K. Barresi
  • 1,275
  • 1
  • 21
  • 46