Results 1 to 2 of 2

Thread: QtWebKit + Flash performance, Qt4 vs. Qt5

  1. #1
    Join Date
    Sep 2013
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default QtWebKit + Flash performance, Qt4 vs. Qt5

    I'm currently evaluating and comparing performances of QWebView and QGraphicsWebView in Qt4 and Qt5 when playing flash content, like Youtube video. I'm using a naive/simple test browser as the following:

    Qt Code:
    1. #include <QApplication>
    2. #include <QGraphicsView>
    3. #include <QGraphicsWebView>
    4. #include <QMainWindow>
    5. #include <QWebSettings>
    6. #include <QWebView>
    7.  
    8. class GraphicsBrowser : public QGraphicsView
    9. {
    10. public:
    11. GraphicsBrowser (QWidget* parent)
    12. : QGraphicsView (parent)
    13. {
    14. qDebug ("creating GraphicsBrowser...");
    15.  
    16. setScene (new QGraphicsScene (this));
    17.  
    18. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    19. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    20.  
    21. m_webView = new QGraphicsWebView ();
    22. scene ()->addItem (m_webView);
    23. }
    24.  
    25. QGraphicsWebView* webView (void) { return m_webView; }
    26.  
    27. protected:
    28. void resizeEvent (QResizeEvent *evt)
    29. {
    30. QGraphicsView::resizeEvent (evt);
    31.  
    32. QRect r = contentsRect ();
    33.  
    34. setSceneRect (0, 0, r.width (), r.height ());
    35. m_webView->resize (r.width (), r.height ());
    36. }
    37.  
    38. private:
    39. QGraphicsWebView *m_webView;
    40. };
    41.  
    42. int main (int argc, char **argv)
    43. {
    44. QApplication app (argc, argv);
    45. QString url ("http://slashdot.org");
    46. bool useGraphicsView = false;
    47.  
    48. QWebSettings::globalSettings ()->setAttribute (QWebSettings::PluginsEnabled, true);
    49. QWebSettings::globalSettings ()->setAttribute (QWebSettings::DeveloperExtrasEnabled, true);
    50.  
    51. for (int i = 1; i < argc; i++)
    52. {
    53. if (strcmp (argv[i], "-g") == 0)
    54. useGraphicsView = true;
    55. else
    56. url = argv[i];
    57. }
    58.  
    59. qDebug ("use QGraphicsView: %s", useGraphicsView ? "yes" : "no");
    60. qDebug ("url: %s", url.toLatin1 ().data ());
    61.  
    62. if (useGraphicsView)
    63. {
    64. GraphicsBrowser *browser = new GraphicsBrowser (&win);
    65. win.setCentralWidget (browser);
    66. browser->webView ()->load (url);
    67. }
    68. else
    69. {
    70. QWebView *web = new QWebView (&win);
    71. win.setCentralWidget (web);
    72. web->load (url);
    73. }
    74.  
    75. win.resize (1200, 800);
    76. win.show ();
    77.  
    78. return app.exec ();
    79. }
    To copy to clipboard, switch view to plain text mode 

    The main problem I noticed is that performances of the above code under Qt5 are much lower than Qt4, when using a simple QWebView playing a Youtuve video. When compiling the above code and playing a Youtube video through the "QWebView" path, it runs at about 25% CPU usage. Compiling the same code with Qt5 and using the same video makes it run at about 50% CPU. Also when comparing the QWebView and the QGraphicsWebView paths, in Qt4 QGraphicsWebView is twice as slow as QWebView (when playing the same Youtube video), while there doesn't seem to be a difference under Qt5.

    From what I know, I believe Qt4+QWebView is faster because the flash plugin is painting directly on screen, while QGraphicsWebView uses an internal buffer and does kinda software compositing. From the performance numbers, I'm wondering whether Qt5+QWebView is also using an internal buffer.

    In any case, could anybody shed some light on why Qt5+QWebView shows such a performance degradation (I would have expected better performances actually). Am I doing something wrong and the naive implementation above is *not* the way to go?

    System details:
    • OS: Linux, Fedora 18, up to date

    • Qt4: 4.8.4

    • QtWebKit: 2.3.2

    • Qt5/QtWebKit: 5.1.1



    PS: for the record, I've also tried a QML-based simple implementation using QtQuick 2.0 and QtWebKit 3.0, and in that case, I have 2 processes, QtWebPluginProcess and QtWebProcess running at ~35% and ~25% respectively

  2. #2
    Join Date
    Sep 2013
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QtWebKit + Flash performance, Qt4 vs. Qt5

    After looking into webkit code, it appears wmode=opaque is enforced in all cases when using Qt5 (unlike Qt4, where it's only enforced for non QWebView). This explains the performance degradation of Qt5+QWebView compared to Qt4+QWebView.

Similar Threads

  1. BUG in QTWebkit 4.8 > Flash
    By janton in forum Qt Programming
    Replies: 7
    Last Post: 13th September 2012, 11:26
  2. How to play flash with Qtwebkit
    By devin in forum Qt Programming
    Replies: 1
    Last Post: 1st February 2012, 02:44
  3. Flash in QTWebkit 2.0 ?
    By maratoid in forum Qt Programming
    Replies: 1
    Last Post: 11th March 2011, 17:30
  4. Running flash in QtWebkit
    By jay in forum Qt Programming
    Replies: 2
    Last Post: 16th June 2010, 10:44
  5. QtWebKit and flash performance issues
    By caelestis in forum Qt Programming
    Replies: 0
    Last Post: 7th February 2010, 05:08

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.