Going to the Qt Contributors’ Summit

Going to the Qt Contributors’ Summit

I will leave Reykjavik around midnight, arrive in the early morning in Berlin and then try to get to the venue. This means I will most likely miss the keynotes but should be there by lunch time.

Besides being interested in technical topics like the networking stack, signals for Qt5, I think I will try to focus on the license part of the contribution model. With recent events like Lodys going after individual developers I wonder if there is something Nokia can do to protect individual developers that acted in good faith.

In the name of performance

In the name of performance

I tend to see people doing weird things and then claim that the change is improving performance. This can be re-ordering instructions to help the compiler, attempting to use multiple cores of your system, writing a memfill in assembly. On the one hand people can be right and the change is making things faster, on the other hand they could use assembly to make things look very complicated, justify their pay, and you might feel awkward to question if it is making any sense.

In the last couple of weeks I have stumbled on some of those things. For some reason I found this bug report about GLIBC changing the memcpy routine for SSE and breaking the flash plugin (because it uses memcpy in the wrong way). The breakage is justified that the new memcpy was optimized and is faster. As Linus points out with his benchmark the performance improvement is mostly just wishful thinking.

Another case was someone providing MIPS optimized pixman code to speed-up all drawing which turned out to be wishful thinking as well…

The conclusion is. If someone claims that things are faster with his patch. Do not simply trust him, make sure he refers to his benchmark, is providing numbers of before and after and maybe even try to run it yourself. If he can not provide this, you should wonder how he measured the speed-up! There should be no place for wishful thinking in benchmarking. This is one of the areas where Apple’s WebKit team is constantly impressing me.

Back from the DevDays

Back from the DevDays

Like many others I was at the DevDays. I happened to be in Munich for GSM related things but managed to attend half a day on Monday and half on Tuesday. I was very happy to reconnect with friends from Australia, Oslo, Brazil and the US and I am always impressed by the team that the Qt unit has recruited and still manages to recruit. Creating awesome technology is just the consequence of that and as written in earlier posts, Qt Quick is great and the Qt Creator integration is getting good as well.

While still having your attention. Is there any interest in low-level GSM stuff in the KDE Community? The OsmocomBB project is close to make phone calls in a commercial GSM network and we could use a simple GUI running on a Linux host OpenBSC on the other hand is the swiss-army-knife of a GSM network and ideal for tests. E.g. testing emergency calls, security research, generating stuff that is difficult on a commercial network, do prototypes…
And on a private note… I am back to Berlin…
Deploying WebKit, common issues

Deploying WebKit, common issues

From my exposure to people deploying QtWebKit or WebKit/GTK+ there are some things that re-appear and I would like to discuss these here.
  • Weird compile error in JavaScript?
  • It is failing in JavaScriptCore as it is the first that is built. It is most likely that the person that provided you with the toolchain has placed a config.h into it. There are some resolutions to it. One would be to remove the config.h from the toolchain (many things will break), or use -isystem instead of -I for system includes.
    The best way to find out if you suffer from this problem is to use -E instead of -c to only pre-process the code and see where the various includes are coming from. It is a strategy that is known to work very well.
  • No pages are loaded.
  • Most likely you do not have a DNS Server set, or no networking, or the system your board is connected to is not forwarding the data. Make sure you can ping a website that is supposed to work, e.g. ping www.yahoo.com, the next thing would be to use nc to execute a simple HTTP 1.1 get on the site and see if it is working. In most cases you simply lack networking connectivity.
  • HTTPS does not work
  • It might be either an issue with Qt or an issue with your system time. SSL Certificates at least have two dates (Expiration and Creation) and if your system time is after the Expiration or before the Creation you will have issues. The easiest thing is to add ntpd to your root filesystem to make sure to have the right time.
    The possible issue with Qt is a bit more complex. You can build Qt without OpenSSL support, you can make it link to OpenSSL or you can make it to dlopen OpenSSL at runtime. If SSL does not work it is most likely that you have either build it without SSL support, or with runtime support but have failed to install the OpenSSL library.
    Depending on your skills it might be best to go back to ./configure and make Qt link to OpenSSL to avoid the runtime issue. strings is a very good tool to find out if your libQtNetwork.so contains SSL support, together with using objdump -x and search for _NEEDED you will find out which config you have.
  • Local pages are not loaded
  • This is a pretty common issue for WebKit/GTK+. In WebKit/GTK+ we are using GIO for local files and to determine the filetype it is using the freedesktop.org shared-mime-info. Make sure you have that installed.
  • The page only displays blank
  • This is another issue that comes back from time to time. It only appears on WebKit/GTK+ with the DirectFB backend but sadly people never report back if and how they have solved it. You could make a difference and contribute back to the WebKit project.
    In general most of these issues can be avoided by using a pre-packaged Embedded Linux Distribution like Ångström (or even Debian). The biggest benefit of that approach is that someone else made sure that when you install WebKit, all dependencies will be installed as well and it will just work for your ARM/MIPS/PPC system. It will save you a lot of time.
    Using Video in QML – the hacky way

    Using Video in QML – the hacky way

    For my current QML project I am required to embed video “into” the QDeclarativeView. I think the proper way will be to use the Qt Multimedia package that comes with a QML VideoView but for this project the customer wanted to use a specific proprietary media player (I wish I could call names).

    I started with creating a QWidget called VideoWidget and added three Q_INVOKABLE methods, one is setPos(x, y, w, h), setUrl(url) and play(), and bind one instance of that widget to the QML runtime. In the QML code I have one Rectangle {} where the video should be and us onWidthChanged, onHeightChanged, onXChanged, onYChanged to call the setPos on the QWidget. This mostly works but on start the x,y is not set properly but I am lucky as my video is not shown on start.
    The next part is to actually host the video. In the first incarnation I was using the QAxContainer to host activeX content. Normally I use the testcon.exe, load the control, figure out which methods to invoke and then convert it to dynamicCalls. The only issue I faced was that ActiveX control just locked up on my copy of Windows7 but thanks to wine I could figure out what to do.
    The only thing that was missing is to position the video on top of the QML content that appeared to be more difficult. The natural choice is to have the QDeclarativeView as parent to the VideoWidget, but that didn’t work, having a common QWidget as parent to the VideoWidget and QDeclarativeView also didn’t work. I had to resort to have two top level windows and trying to make them appear as one, so I had to handle QWidget::event(), use QWidget::setAttribute to have no taskbar for the video, etc.
    Now this award winning closed source media player has quality and performance issues and I needed to try something else, sadly loading VLC in testcon.exe does not work properly, as it refuses any dynamic call to it, so in the end I am using Phonon for the video playback. The great thing about that solution is I can remove the hack with two top level windows and have a common QWidget as parent, and in the future I might be able to embed the videowidget into the QGraphicsScene of QML.
    The bad part is DirectShow which doesn’t handle rtsp/mms and I am failing to find a ASX stream which works over HTTP. The best I can find is the flumotion demo site but that doesn’t offer a standalone URL I can throw to my player.
    Going from dummy to real data

    Going from dummy to real data

    I was writing about my current QML project earlier and now was the time to go from dummy data to real ones. For the prototyping phase we were using models created with ListModel and the attributes we need in the UI. For some JavaScript code that is called to execute actions we were using ListModel.get(index) to get the item and then execute code.

    The QML Documentation was bringing me very far. I was using the rootContext of the QDeclarativeView to add a controler object and the models to the QML runtime. The controler is called when the models needs to be updated, e.g. I am calling them from ScriptAction on state transitions. For QML a model only needs to set the rolenames and then handle the different roles. This was working quite nicely, and the old modeltest can help to debug the model.
    After the above a simple ListView { model: myModel } will work nicely. Now I was writing about that we are using ListModel.get and I assumed that it would just magically work for my model as well, e.g. using the rolenames as well. From what I have seen that is not the case. This means your model needs to implement a Q_INVOKABLE QVariant get(int index); and internally use a QMap and somehow duplicate code that is already there.
    Another problem came from updating models. This is something that does not happen with static data, but happens in my case. I was using the big hammer with beginResetModel() and endResetModel() in the model and on the QML side one can use onCountChanged in the ListView to handle a massive update and execute JavaScript. In my case this was used to automatically select the first item and set the currentIndex of another ListView.
    QML and dealing with states

    QML and dealing with states

    In the last days I have resumed my QML work (I had a small break to work on the MGCP GW code of OpenBSC to fix some real world issues) and there is one kind of issue I tend to run in and I wonder how others are solving it. Let us imagine we have a QML Component for a Button. The Button itself can hold a text (property alias text: buttonLabel.text) and the button has three states (enabled, focused, pressed) that depend on the MouseArea that inside the button as well. Actually this approach is directly coming from the many nice examples and demos provided by Nokia.

    Now the problem is… I’m using the Button in many places and depending on some other external state the label of the Button should change and I keep writing things like this:
    UI.Button {
    id: text_button
    text: ‘My Text’
    MouseArea {
    anchors.fill: parent
    onClicked: { console.log(‘clicked’); }
    }
    states: [
    State {
    name: ‘some-state’
    PropertyChanges {
    target: text_button;
    text: ‘Other text’; }
    }
    /* more states… */
    ]
    }
    And then I am going to wonder why things don’t work. The first issue is that my own MouseArea will receive the mouse click and the button will not work… but that is easily fixed. Do not add a custom MouseArea and have a clicked signal inside the button component. The second issue is with the states.. the above code is breaking the focus/pressed logic.

    The way I am dealing with this kind of problem is to move the state into a parent and control the text from there. What is the proper way of solving this problem? Creating multiple buttons and control the visibility/opacity from outside? Duplicate the component states inside the custom states (cross product of my states and the component states)?
    I know that talking about errors is bad as this will make people remember the wrong solution but I hope that other people stepping into these kind of problems will remember this as a possible problem..