Saturday, September 18, 2010

Comparing HTML rendering performance with QtWebkit and Qt native classes

The Texas Instruments AM35x/AM37x SDKs ship with a QtWebkit based application-launcher, called Matrix. The Matrix application launcher reads from a screen layout configuration file that indicates the details of each screen, and renders the icons using a QWebView. Since the Web view loads the QtWebkit library and all its necessary DOM code, it appears from the outset that the speed of the Matrix application launch can be improved by moving to a simpler HTML parser and a screen renderer. In order to check this assumption, a simple code was written as part of Xgxperf toolkit, to read the same screen layout configuration HTML file, and render to the screen. [renderer source in applicationmanager/xgxperf_launcher -] . Tests were conducted in Qt/embedded environment, as well as in Qt/X11 desktop environment, with the same HTML configuration layout input files.

The renderer uses QXmlStreamReader to read the formated HTML, QPixmap to render the icons, and QTextItem for displaying Title and Status of benchmarking as a item in the bottom layer of the view. Gradients are used to give the background a polished look. Item Scaling is enabled to fit various screens automatically.

It is observed that this native HTML renderer built with Qt native classes, is slower than the QtWebkit based renderer. Removing the gradient brush background gives it a slight boost, but still falls short of passing the QtWebkit renderer. Further profiling indicates the below deficiencies in Qt based rendering:

- Text rendering and laying out the text item in a Graphics View in Qt take significant cycles compared to QtWebkit. Using QStaticText (needs Qt 4.7) gives performance increase.

- Brush with textures/ gradients takes up cycles for calculation of the gradient

- QXmlStreamReader is considerably faster than expected and can be used as a very good low footprint (compared to QtWebkit) HTML/XML parser

From this example, it can be seen that, unless the extra memory requirements are an issue (size of the QtWebkit library is around 17 MBytes in Qt4.6), QtWebkit should be preferred over other native Qt renderers, both for image/text rendering, and HTML parsing. For lightweight XML/HTML parsers (like configuration utilities), QXMLStreamReader is suitable.


Matrix GUI -
XgxPerf Toolkit -

No comments:

Post a Comment