June 18, 2012

arvind2111 arvind2111
Lab Rat
4 posts

QPainter hanging when taking webpage snapshot

 

Hi All,

We’re using the following code to take a screenshot of a webpage:

  1.     QWebPage * page = mBrowser.page();
  2.     QImage screenshot(page->viewportSize(), QImage::Format_ARGB32);
  3.     QPainter paint(&screenshot);
  4.     page->currentFrame()->render(&paint);
  5.     paint.end();
  6.     screenshot.save("screenshot.png");

However, quite frequently, this block of code hangs. Using gdb, I’ve done a backtrace as follows. Does anyone have any clues as to why this may be occurring? Some sites this is occurring on include http://wordpress.tv/ and http://octodex.github.com

  1. Program received signal SIGINT, Interrupt.
  2. qt_memfill32_sse2 (dest=0x7fffffff9650, value=4294967295, count=1280) at painting/qdrawhelper_sse2.cpp:269
  3. 269      case 0: do { _mm_stream_si128(dst128++, value128);
  4. (gdb) up
  5. #1  0x00007ffff52b92d8 in blend_color_generic (count=206, spans=<value optimized out>, userData=0x112e6e0)
  6.     at painting/qdrawhelper.cpp:3446
  7. 3446              op.funcSolid(dest, l, data->solid.color, spans->coverage);
  8. (gdb) up
  9. #2  0x00007ffff525dff7 in flushSpans (this=0xa4f7e0, a=<value optimized out>, b=<value optimized out>,
  10.     width=<value optimized out>, squareCap=<value optimized out>) at painting/qrasterizer.cpp:111
  11. 111          m_blend(m_spanCount, m_spans, m_data);
  12. (gdb) up
  13. #3  addSpan (this=0xa4f7e0, a=<value optimized out>, b=<value optimized out>, width=<value optimized out>,
  14.     squareCap=<value optimized out>) at painting/qrasterizer.cpp:105
  15. 105              flushSpans();
  16. (gdb) up
  17. #4  QRasterizer::rasterizeLine (this=0xa4f7e0, a=<value optimized out>, b=<value optimized out>,
  18.     width=<value optimized out>, squareCap=<value optimized out>) at painting/qrasterizer.cpp:882
  19. 882                                     Q16Dot16ToInt(Q16Dot16Multiply(rowHeight, coverage[i])));
  20. (gdb) down
  21. #3  addSpan (this=0xa4f7e0, a=<value optimized out>, b=<value optimized out>, width=<value optimized out>,
  22.     squareCap=<value optimized out>) at painting/qrasterizer.cpp:105
  23. 105              flushSpans();
  24. (gdb) up
  25. #4  QRasterizer::rasterizeLine (this=0xa4f7e0, a=<value optimized out>, b=<value optimized out>,
  26.     width=<value optimized out>, squareCap=<value optimized out>) at painting/qrasterizer.cpp:882
  27. 882                                     Q16Dot16ToInt(Q16Dot16Multiply(rowHeight, coverage[i])));
  28. (gdb) up
  29. #5  0x00007ffff529877e in QRasterPaintEngine::fillRect (this=0x139c6f0, r=..., data=0x112e6e0)
  30.     at painting/qpaintengine_raster.cpp:1899
  31. 1899              d->rasterizer->rasterizeLine(a, b, nr.height() / nr.width());
  32. (gdb) up
  33. #6  0x00007ffff5221037 in QPainter::fillRect (this=0x7fffffffcb50, r=..., brush=...)
  34.     at painting/qpainter.cpp:6961
  35. 6961              d->extended->fillRect(r, brush);
  36. (gdb) up
  37. #7  0x00007ffff67c6aab in ?? () from /usr/lib64/libQtWebKit.so.4
  38. (gdb) up
  39. #8  0x00007ffff678b7cc in ?? () from /usr/lib64/libQtWebKit.so.4
  40. (gdb) up
  41. #9  0x00007ffff66f3b11 in ?? () from /usr/lib64/libQtWebKit.so.4
  42. (gdb) up
  43. #10 0x00007ffff6746880 in ?? () from /usr/lib64/libQtWebKit.so.4
  44. (gdb) up
  45. #11 0x00007ffff6747414 in ?? () from /usr/lib64/libQtWebKit.so.4
  46. (gdb) up
  47. #12 0x00007ffff663c17e in ?? () from /usr/lib64/libQtWebKit.so.4
  48. (gdb) up
  49. #13 0x00007ffff6811c46 in ?? () from /usr/lib64/libQtWebKit.so.4
  50. (gdb) up
  51. #14 0x00007ffff6811e76 in QWebFrame::render(QPainter*) () from /usr/lib64/libQtWebKit.so.4
  52. (gdb) up
  53. #15 0x0000000000411c20 in bricolage::WebCrawler::takeScreenshot (this=0x7fffffffe0f0)
  54.     at /data/bricolage/Code/Applications/Database/WebCrawlerCPP/src/WebCrawler.cpp:231
  55. 231      page->currentFrame()->render(&paint);

1 reply

June 18, 2012

AcerExtensa AcerExtensa
Robot Herder
608 posts

Have tested http://wordpress.tv/ and http://octodex.github.com with my thumb-crawler on Linux x86_64 with Qt 4.7.1 & 4.8.2, no problem at all…

Are you using ubuntu? have you compiled Qt by yourself or is it default SDK installation?

 Signature 

God is Real unless explicitly declared as Integer.

 
  ‹‹ console.log      QWebView icon not working ››

You must log in to post a reply. Not a member yet? Register here!