Benjamin
WebKit
Performance
Posted by Benjamin
 in WebKit, Performance
 on Tuesday, February 02, 2010 @ 11:13

Like for the other parts of Qt, having great performance is important for QtWebKit.

Traditionally, QtWebKit has been mostly used on desktop computers for advanced layouting, hybrid applications or simply to browse the web. On a modern computer, the speed of WebKit is not a problem.

The world has changed, and QtWebKit is now used on mobile phones running Maemo, Symbian or Windows CE, and it is more and more used in embedded application on various devices.

Working on what matters

To improve the performance of WebKit, we works with benchmarks. Those benchmarks are used as use cases when profiling WebKit and to evaluate the gain of our patches.

Those benchmarks and the tools are available on Gitorious, in the QtWebkit performance repository.

WebKit gives a lot of possibilities, and we try to focus our work on what matters. For the performance work, we use real webpages, and look for ways to improve WebKit in the way it is used on the Web.

How we benchmark WebKit

The performance suite has three kinds of tools:

  • host tools: to manage the data used by the benchmarks
  • tests: the benchmarks
  • reductions: some benchmarks for specific components of WebKit

Let’s have a look at the tools and the tests. The full documentation of the performance suite is on the WebKit’s wiki.

Mirroring the web

For the benchmark, we do not want to access Internet directly. We want to compare the results from one run to the other, so we don’t want the pages to change arbitrarily. Using the Web for benchmarking would also create an important load on the servers.

To use real pages without going online, we create databases of web pages with the mirror application:

Process of webpage mirroring

Those databases are snapshots of webpages at a given point in time, and they are used as input of the benchmarks.

The mirror application uses WebKit to load the pages and intercept all network requests. This means the database also includes resources that are loaded lazily via Javascript.

Using the benchmarks

There are two ways to exploit the databases with the benchmark: the online and offline modes. The difference lies in the way we provide the database’s content to the benchmarks:

Modes of benchmarking

In the “online mode“, we use a basic web server to serve the database over HTTP. The benchmarks use the complete stack to load pages, as they would if we were loading the page from Internet.

In the “offline mode“, the database is loaded directly by the benchmarks and is used as the source of data. In that case, the network is not involved. This mode is mostly useful for the benchmarks that do not involve the network (like measuring the rendering speed).

What is measured

The benchmark suite is still a work in progress. Currently, there are benchmarks for:

  • the page loading performance (with or without rendering)
  • the rendering performance
  • the scrolling performance

How you can use that?

If you use WebKit, and are interested in great performance, you can use the performance suite to profile the use case you are interested in, and optimize those cases.

If you evaluate the use of WebKit for embedded, you can use the benchmark to evaluate how good WebKit performs on the hardware.

If you make patches for WebKit’s performance, have a look on how to contribute. You can also join us on IRC in #qtwebkit on freenode.

Simon
WebKit
Posted by Simon
 in WebKit
 on Monday, February 01, 2010 @ 12:56

Hi!

Here’s the weekly summary of Qt related changes to WebKit trunk. Big changes include Yael’s patch for WebSockets support, the beginnings of QtScript on top of JavaScriptCore’s C API, Maemo 5 tweaks and layout test fixes:

  • Janne added the necessary meta-data to make QtWebKit play nicely with Symbian backups (34077).
  • I did some code cleanups in RenderThemeQt and fixed a bug with combo boxes not showing up in Maemo5 (34088).
  • Holger fixed a regression in the JavaScript prompt handling (30914).
  • Jedrzej landed the first files for building QtScript on top of JavaScriptCore’s C API (32565).
  • Diego added history support to the Qt DRT, we now pass the http/tests/history layout tests! (34167)
  • Daniel fixed a bug with the height of button elements (29564).
  • Kent fixed support for ES5 style introspection with QMetaObject methods (34087).
  • Yael implemented the Qt part of WebSocket support, we now pass websocket/tests in the layout tests (34180).
  • Diego fixed more worker layout tests by adding support for counting worker threads in the Qt DRT (34221).
  • Holger found a neat way to speed up the conversion from KURL to QUrl (33873).
  • Trond fixed an endless loop in QWebPage printing (r53997).
  • Kenneth fixed incorrect fonts on comboboxes on Maemo5 and Symbian (r53999).
  • Andreas upstreamed Ralf and Robert’s kinetic scrolling support for QWebView using QAbstractKineticScroller (34267).
  • Benjamin implemented support for the display() method in the Qt DRT (34258).
  • Oswald speed up the conversion between WebCore::String and QString by avoiding QString::fromUtf16() (r54060).
  • Kenneth landed a patch to disable auto-uppercasing and text prediction for password input fields (r54064).
  • Kenneth also continued to clean up the QtLauncher for a future merge with QGVLauncher
  • Andreas and Kenneth submitted tweaks to the look’n'feel of QtLauncher on Maemo5.
Simon
WebKit
Posted by Simon
 in WebKit
 on Sunday, January 24, 2010 @ 09:38

This week has been a very busy week! Here’s a list of the landed changes that affect the Qt port, in chronological order:

  • Tor Arne has ported the Qt build of DumpRenderTree to run on Windows. (r53526, r53543).
  • Luiz continued with cleaning up the combobox popup handling.(33418).
  • Ben from the Google Team fixed a bug where touch events weren’t sent to iframes (33894).
  • No’am landed support in the Qt bindings that allows passing pixmaps and images as arguments in signals/slots/properties, which can then easily be turned into image elements or data urls. (32461).
  • Benjamin cleaned up the QWebPage autotest (32216).
  • On Thursday we landed No’am’s implementation of GraphicsLayer. This accelerates the composition of layers with animated opacity or transform attributes, through content caching in pixmaps. Layers are mapped to QGraphicsItems with enabled CacheMode and the animation is driven by the Qt Animation Framework.The feature is disabled by default currently as it’s not stable yet, but it’s a fantastic start! (33514).
  • Diego continued implementing missing functions in the Qt DRT (33945).
  • Jakub fixed a crash with video elements and phonon (33842).
  • Girish fixed a bug with combobox popups in transformed QGraphicsWebViews (r53703, 33887).
  • Robert fixed 5 layout tests by fixing support for window.close() and window.closed() in the Qt DRT (32953).
  • Kent fixed bugs with Object.getOwnPropertyDescriptor (33948, 33946).
Simon
WebKit
Posted by Simon
 in WebKit
 on Friday, January 15, 2010 @ 17:49

Here’s the weekly summary of the Qt related changes that landed in WebKit trunk this week:

  • Daniel and Robert added support for the XSS auditor to the Qt DRT (33419).
  • Simon removed unnecessary memory allocations of QPainterPath from WebCore::Path (33466).
  • Zoltan continued to make the world a subclass of FastMallocBase.
  • Diego fixed support for user stylesheet locations in the Qt DRT (33617).
  • Andreas fixed the scrolling performance on pages with embedded widgets (33373).
  • Jocelyn reworked the qmake based build system to separate the generated files from the regular build, fixing longstanding dependency issues (33542).
  • Diego added a missing implementation of fileSystemPath() to the Qt build of KURL (33614).
  • Jakub fixed a bug with XSL stylesheet loading.
  • Ben fixed support for touch events in document.createEvent() (33605) as well as the detection of touch events as user gestures (33597).
  • Kim fixed support for touch event coordinates in zoomed and scrolled pages (32899).
  • Petri fixed an incorrect touch layout test (33465).
  • The Szeged hackers continue to rock our world by keeping the bot green green green!

That’s all for this week, folks :). If I have missed anything or you’d like to mention something in the next digest, please send me an email.

BTW, if you’d like to join the development, please subscribe to the webkit-dev and the webkit-qt mailing lists. You can also join our weekly meeting point on IRC in #qtwebkit on freenode every Monday at 15:00. There’s no fixed agenda, but instead there’s a good chance that most developers will be around, if you’re looking for code reviews, etc. in a particular area. See you there!

Kent
WebKit
Posted by Kent
 in WebKit
 on Friday, January 15, 2010 @ 13:06

Today it’s exactly one month since the press release stating that ECMA-262 5th edition (ES5) has been approved. (Yeah, that’s just a random coincidence.) What’s changed since the 3rd edition? Quoting the spec itself (actually, it’s only the “Final final final final draft” according to the PDF document title :) ):

The [fifth edition of ECMAScript] codifies de facto interpretations of the language specification that have become common among browser implementations and adds support for new features that have emerged since the publication of the third edition. Such features include accessor properties, reflective creation and inspection of objects, program control of property attributes, additional array manipulation functions, support for the JSON object encoding format, and a strict mode that provides enhanced error checking and program security.

Mark Caudill gives a good 10000-feet overview of the new features. John Resig goes into more detail about Objects and properties and strict mode and more.

Here’s my attempt at an overview of the ES5 implementation status in WebKit/JavaScriptCore (JSC).

Features implemented in JavaScriptCore

This is stuff that’s already in WebKit trunk. I’ve included links to relevant Bugzilla tasks in case you’d like more information (e.g. have a look at the patches).

  • Array extras”: Array.prototype.{indexOf,lastIndexOf,every,some,forEach,map,filter,reduce,reduceRight}:
    These have been in JSC for years. I’m not sure how conformant the implementations are, though.

Features not implemented in JavaScriptCore

  • Strict mode: I’m not aware of any work that’s been done to support strict mode yet. It involves making the parser/compiler recognize the “use strict” directive and adapting execution according to the rules given in annex C of the ES5 specification. (The annex lists 20 restrictions/exceptions that apply to strict mode.)

Want to get involved or track the status?

Have a look at the open ES5 tasks at bugs.webkit.org. For creating new tasks, use component “JavaScriptCore”, tag “ES5″ and (optionally) summary prefix “[ES5]”. In addition to implementing ES5 functionality or playing with it in your WebKit-based app, there are also opportunities to use that functionality within WebKit, such as in the test framework and the Web Inspector (whose front-end is written in JavaScript). For example, Object.getOwnPropertyNames() made it easy to resolve the long-standing issue of the Web Inspector console not auto-completing non-enumerable properties of built-in ECMA objects (https://bugs.webkit.org/show_bug.cgi?id=19119). And Object.getOwnPropertyDescriptor() could potentially be used to display detailed information about variables. I just love those new introspection capabilities! Finally it’s possible to do things directly in JavaScript that you could only do with native (engine-specific) APIs before.

Happy ES5 hacking!

No
WebKit
Graphics View
Graphics
Performance
Posted by No'am Rosenthal
 in WebKit, Graphics View, Graphics, Performance
 on Wednesday, January 13, 2010 @ 16:07

I’d like to share with the community a project I’m working on, while it’s still in its development phase (isn’t that what labs is for? :))
The goal of the project is to get CSS3 animations to a reasonable FPS performance, mainly on embedded hardware where it’s a pain.

See http://gitorious.org/~noamr/webkit/noamrs-webkit/commits/accel

The idea is to implement webkit’s GraphicsLayer concept, which allows platform-specific implementations of CSS transform and opacity animations, using the graphics-view and the Qt animation framework as a backend. This would only work for QGraphicsWebView and not for QWebView, as rendering a separate QGraphicsScene inside QWebView would probably not give us much performance benefit.

Preliminary results are very promising - The leaves demo, for example, runs 4 times faster on Maemo Fremantle than it does without the acceleration, and it looks graphically accurate.

The reason this gives us a performance benefit is mainly because of graphics-item caching: when a CSS animation occurs inside webkit, the item that’s being animated has to go through a re-layout and re-draw every so often, while with the accelerated approach we draw it once into a QPixmap (QGraphicsView takes care of that) and then it’s just a series of fast and furious pixmap blts. The hardware acceleration becomes relevant when the images are big and the blt itself becomes a bottleneck.

This project is not ready to go upstream, as it supports many delicate use-cases that need to be tested. But if you’re interested in participating (or to just comment!), this has so far been a fun project to hack on.

Instructions:

  1. Get the Git repo from git://gitorious.org/~noamr/webkit/noamrs-webkit.git, branch accel
  2. Build or get a relatively new version of Qt, possibly without building QtWebkit
  3. Build Webkit from the downloaded Git repo:
    export QTDIR=[my-qt-4.6-root]
    export PATH=$QTDIR/bin:$PATH
    ./WebKitTools/Scripts/build-webkit --qt
  4. Run ./WebKitBuild/Release/bin/QGVLauncher --accel: This will enable the necessary web-setting for composite-layer acceleration. You can also create a small QGraphicsWebView example yourself, as long as you enable the new settings flag: QWebSettings::AcceleratedCompositingEnabled
  5. Load a website with CSS transform/opacity animations: like this one or this one.
  6. Hack. Most of the code is in WebCore/platform/graphics/qt/GraphicsLayerQt.cpp, or you could just search for the term USE(ACCELERATED_COMPOSITING)
  7. Send merge requests through Gitorious or comments on Bugzilla

No’am

Simon
Qt
WebKit
Posted by Simon
 in Qt, WebKit
 on Sunday, January 10, 2010 @ 10:03

I’d like to give you a brief summary of the commits that were landed in the Qt parts of WebKit in the first week this year:

  • Lots of improvements on the DRT testing tool: Enter key fixes (Jakub), Drag and Drop support (Yael) and Zoom support (Kim, Diego, Afonso). All of these changes improve the layout test coverage. :)
  • Jakub added support for sliders to RenderThemeQt.
  • Andreas fixed a crash with input methods on startup.
  • Kim fixed the semantics of touch events to match the iPhone and Android behaviour better.
  • Luiz and Kenneth landed more code that’ll make it possible in the future to handle list popups in the application.
  • Norbert landed a workaround for an RVCT bug that makes the trunk build again on Symbian.
  • Yael continued work on the network state notifier implementation (using Qt Bearer Management).
Thiago Macieira
Qt
WebKit
Performance
Posted by Thiago Macieira
 in Qt, WebKit, Performance
 on Wednesday, December 02, 2009 @ 14:55

You know, of all the demos we released and blogged about yesterday, turns out none were really a web app. “How could this be?! How could the Trolls forget about the web?” you may be asking. (or not, I mean, no one posted anything in the blogs as of the time of writing this blog)

Say no more, here’s your web demo:

This demo is called “webscraps” and was developed by formerforever Troll Girish and his friend and business partner Roopesh. The source code, of course, is available on Labs: http://qt.gitorious.org/qt-labs/webscraps.

So what does this demo do? It allows you to create a scrap collection of webpages and websites. Often you’re interested in just the “news” section of a website that may not provide an RSS feed for you to be up-to-date. For example, you could configure it to watch blue-grey central banner of the Qt Homepage.

But that’s not it. I mean, from what I’ve described so far, we could do since Qt 4.4, with QtWebKit. No… this is really a Qt 4.6 demo. For starters, it also makes use of our Animations Framework as well as the States and Transitions one. And in order to do that, it uses QGraphicsWebView, which is also a new feature in Qt 4.6. It’s a very complete demo for what Qt can do and how you can integrate Web content into a Qt application.

Now, I tried the demo on my N900, but with WebKit in debug mode it runs painfully slow. I couldn’t run it in release mode because then it crashes (I think it’s my toolchain, though, since most QtScript unit tests also crash).

Anyone wants to give a hand? We’d like to see this running fast, so it’s a great opportunity to flex your optimisation muscles and play with the new QGraphicsWebView, Animations, States and Transitions APIs. Contributions are welcome.

Good hacking!

PS: Why it fell to me to blog about Web and Graphics View, I am not sure. Maybe they couldn’t decide who should blog (similarly as they couldn’t decide for a time if it should be called QGraphicsWebView or QWebGraphicsView). Or they thought that as a Product Manager I would have time on my hands… :-)

No
WebKit
Internet
Graphics
SCXML
Posted by No'am Rosenthal
 in WebKit, Internet, Graphics, SCXML
 on Monday, November 09, 2009 @ 04:21

Lately I’ve been working on a couple of exciting customer projects, involving HTML5-based UIs on embedded (TV) platforms. Due to the fabulous work some of my colleagues put into QtWebkit and QtDirectFB, and the ongoing work from MIPS Technologies on their Webkit JIT, the paint performance is very good, and Javascript is getting faster and faster.
However, while working on these projects, I’ve ran into a few issues that were not solvable by JIT-accelerated JavaScript or by hardware accelerated painting.

The main problem was that when you write a dynamic UI for a full application, the complexity starts to be difficult to manage. I started by dividing the app to a few HTML pages, but that of course created unacceptable delays when switching between the pages. So I looked online for dynamic web-app solutions. Those include the amazing Javascript libraries Dojo and JQuery. The problem with those is that they manage the complexity by selecting elements with custom-built CSS-like selectors (which are slow) and by modifying the HTML DOM tree in runtime (which is slower).

An alternate way to handle HTML performance is with the HTML5 canvas element (which is nicely accelerated) - the problem is that canvas API is currently too low level, and the widget libraries on top of it are not mature yet, definitely not in time for my customer projects.

So I asked myself: what components are really needed in order to make a dynamic UI?
Looking at the Qt Kinetic project, I need 4 main elements:

  • Animations
  • State Machine
  • Graphic effects
  • Declarative Syntax

Now HTML and CSS are already a declarative syntax, and CSS3 (supported in webkit) contains all the animations and graphic effects I currently need. The missing element, which is also my personal favorite, is the State Machine.

Why do I keep going on and on about state-machines?
If you think about it, both CSS, HTML, and Qt widgets are optimized to handle complexity in space. State machines, however, are optimized to handle complexity in time. An application can be dynamic only if it’s rich both in space and in time. That’s why to me state-machines are of outmost importance for dynamic UIs.

Enough philosophy, what’s this about?
Now I’ve had the pleasure to work with the SCXML standard in the last year, both by prototyping the Qt-SCXML library (which later helped with the evolution of the Qt State Machine Framework), and by joining the w3c group that defines the SCXML standard.
While working on my latest HTML-based project, I was thinking - what if I could define the flow of my web-app with an SCXML statechart? Wouldn’t that allow for managing the complexity of my web app, without incurring the performance overhead of modifying and re-modifying the DOM?

Introducing Statechartz
So I took the time to write an SCXML library for Javascript. I basically had to copy the SCXML algorithm to Javascript syntax, which took a while, but has already saved me hours of work by having the code of my web-apps cleaner and smaller.
The result can be found at the statechartz branch on the SCXML lab GIT repo., and the demo can be viewed online. Note that the library is currently only tested on webkit-based browsers (QtWebkit/Arora, Safari, Chrome), but porting it to other browsers shouldn’t be too difficult.

Looking a bit at the HTML code of the demo, you’ll notice the following:

<link rel="statechart" href="flow.scxml" />

This is the line that connects an HTML page with an SCXML statechart, defining the page’s flow. The state-machine would start running as soon as the page is loaded.
But hey! rel=”statechart” isn’t standard!

Well, I was surprised to learn that HTML5 allows you to add your own link types, which become legal if you register them in the WHATWG Wiki, which I did; so now <link rel=”statechart” href=”somefile.scxml” /> is completely standard :)
Though using the link tag would cover most cases, it’s completely optional and the Statechartz library can be used more dynamically, either by loading an SCXML file whenever wanted:

var myStateMachine = Statechartz.loadScxml(someURL);

or by using a dynamic javascript syntax that looks like this:

var myStateMachine;
with (Statechartz) {
  myStateMachine = build(
    State("root",
        Entry(function() { doSomething(); }),
        Parallel("s1",Initial,
             Exit(function()(doSomethingElse(); }),
             Transition(Event("EVENT.QUIT"), Target("exit"))
        ),
        Final("exit")
    )
  );
}

Another thing to look at, is the DOM:

<div id="screen_weather" class="screen">
      <script type="text/javascript" src="..."></script>
</div>
<div id="screen_shopping" class="screen">
    <iframe src="..." height="240" width="320" scrolling="no" style="overflow:hidden" frameborderwidth="0"></iframe>
</div>
<div id="screen_calc" class="screen">...</div>

Even though screen_weather, screen_shopping and screen_calc exist in the DOM to begin with, only one of them is shown at a time. Also, there’s no particular Javascript code that shows and hides them. That’s done by a trick I added to the Statechartz library: the CSS class of the document BODY element changes when the state changes. So, if I’m in a state with ID “calc”, the body would have a CSS class “state_calc”, and now all it takes is adding this to the CSS (it’s a little different in the actual CSS, but I’m trying to make a point):

#screen_calc {
  left: -350px;
  -webkit-transition-duration: 600ms;
  opacity: 0.5;
}
.state_calc #screen_calc {
  left: 0px;
  -webkit-transform: rotate(360deg) scale(1);
  opacity: 1;
}

This code, like states and transitions in Qt 4.6, would animate the opacity and geometry of my calculator screen, and would create an animated transition when the calculator is entered to / exited from.

The Demo, and performance
The
demo that comes with the statechartz library demonstrates 3 uses of the Statechartz library:

  • Dynamic UIs with states and transitions (switching between the 3 widgets)
  • Managing UI complexity (e.g. the instructions popup)
  • Business logic (the calculator ‘engine’)

Note that the demo specifically is too animation-heavy to run well on embedded platforms, and of course webkit could use some more optimizations. but the concepts (don’t mess with the DOM, use Statecharts to manage time) are the same, and are working on other webkit-based projects with a cvery nice performance gain.

The next step on the SCXML path
After this project, SCXML is now supported in 3 implementations: Qt C++ (with scc), QtScript (with QScxml), and web (with Statechartz). The next natural step is a statechart graphical tool (Creator plugin) that can help author SCXML files for all of those 3 implementations. Though it’s not on our roadmap, some of us (including the undersigned) were working on prototypes, and any help from the community would be appreciated!

Links
The code: http://qt.gitorious.org/qt-labs/scxml/trees/statechartz
The live demo (webkit browsers only): http://labs.trolltech.com/blogs/wp-content/uploads/2009/11/demo.html
Video capture of the live demo: http://labs.trolltech.com/blogs/wp-content/uploads/2009/11/statechartz-capture_0001.wmv

Simon
Qt
WebKit
Posted by Simon
 in Qt, WebKit
 on Sunday, October 11, 2009 @ 15:18

I don’t mean “on the road” too literal, but I think we’re on track for a good release, as the following summary of recent changes shows:

  • Kenneth and Antonio fixed the inconsistent behaviour of setHtml() to sometimes change the history and sometimes not. Simply put, setHtml() should not have any side-effects to the back-forward history.
  • Joe, Kristian and Janne fixed support for input methods on S60, so for example logging into facebook from Anomaly on a 5800 Xpressmusic works.
  • Alexis renamed QWebGraphicsItem to QGraphicsWebView, and Raider is now called Twix ;-)
  • J-P Nurmi fixed support for plugins returned by QWebPluginFactory when used with QGraphicsWebView in a canvas: QGraphicsWidget to the rescue.
  • Girish joined the jungle of WebKit hacking and landed initial support for windowless plugins on X11!
  • Jocelyn found out why nspluginwrapper wasn’t working properly on Linux and fixed it.
  • After a long period of review (sorry buddy) we finally landed Jakubs split of the XSLT processor in WebCore to support libxslt as well as QXmlPatterns.
  • Carol fixed various bugs in GraphicsContextQt for better CSS shadow support.
  • Holger landed his rewrite of ImageDecoderQt that significantly improves the memory footprint. You can find some background for his work at http://trac.webkit.org/wiki/QtWebKitPerformanceWork

Not all of the above changes are in Qt’s 4.6 branch yet, as we’re trying to reduce the number of changes for the upcoming beta. But rest assured they’ll be in the final release. In the meantime you can always check out from WebKit’s trunk :-)

I for one am now looking forward to meet many of you readers at the upcoming Developer Days in Munich and San Francisco.



© 2008 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners.