Comments, Code and Qt. Some words about the wonderful world of software engineering


A MeeGo developer’s endeavors to the Symbian Qt world

I've been working with Qt for a while already and we all know what a great cross-platform framework it is. When Nokia bought Trolltech in 2008 it was clear that Nokia wanted to make Symbian development easier. However, the QWidget based toolkit would not fly on Symbian, or any other mobile platform for that matter, so Nokia built some mobile UI frameworks on Qt (and oh boy Nokia is good at building frameworks for everything. Everyone should have at least one framework, if not two. I could write another blog post about that...). But while people in Europe were fighting over their frameworks, it was not until the guys and gals in Brisbane came up with QML when everything changed. Qt could finally be cross platform again and in an elegant way! Symbian just isn't my cup of tea. But that doesn't prevent me from wanting to write something for Symbian if for nothing else other than being able to say I've done it. But just thinking of Symbian C++ or Avkon makes me feel sick. This has changed thanks to QML and especially Qt Components. Also Nokia has finally been able to put out a single SDK that I can just install, write Qt with, deploy the same code on any Qt-based Nokia mobile, publish in the Nokia Store and... Profit! Right? Well, my opportunity to find out came now thanks to my podcast application, Podcatcher for N9, that I've written for the Nokia N9 smartphone. It's has a MeeGo Harmattan Qt Components based UI with a Qt C++ middleware. These are my comments as a former MeeGo developer on the journey to the Qt world of Symbian.

And so it begins

I have my SDK installed, I have a freshly flashed Nokia C7 running Symbian Anna (thanks to @ltomuta!) that should support the recent SDK and I have my source tree checked out in a separate 'symbian' Git branch. Where should I start? I open the existing MeeGo project in a Symbian Anna target and connect the phone over USB to the PC. And nothing... Qt Creator tells me "Device: Not connected". Maybe I am just too used to any other modern install of an SDK of a competing brand, but when I connect a development ready device to the development computer, the SDK should notice it. Mind you Nokia, but it works out of the box even with your dead-born MeeGo Harmattan N9 smartphone! So here I am motivated and ready to target the 160 million new Symbian devices that Nokia has promised me and I can't even get the phone to connect to their SDK without "some" additional work. This was not a good start for my Symbian coding career. As it turns out you also need to have Nokia's desktop client installed called Nokia Suite on your development machine. This is because the phone drivers are distributed, for whatever reason, only with the application. I would think it would be possible to have them already bundled with the SDK. This also makes me think if it's worth even daydreaming of doing any Qt Symbian development on any other machine than Windows, no matter how cross platform Qt itself would be. (It's not worth it) So having that one sorted out and installed some hundred megs of software I don't want, I was on my way to have my app deployed on the device! I added the symbian: {} section to my .pro file to have Symbian specific compile and deployment information there. (I will write another post regarding the actual porting actions that I see that are needed to have a MeeGo application running on Symbian. So I am sorry to tell you that this is not yet that post). There was however one more obstacle before I could have my code running on Symbian. Namely Installation failed: 'Incorrect dependency: Qt Quick components for Symbian has version 1.00(0), need version 1.01(0) or newer' Code: 131073 Luckily I got some help on Twitter and @knobtviker quickly pointed out that that means that the device has an old version of Qt Components. This was quite a surprise since the Qt SDK 1.1.4 page specifically states that it supports Symbian Anna. So I had to go to the SDK program folder and find three .sis files that I had to install on the device in a correct order to update the device with Qt Components that I could run from this SDK. Oh, well. But after this things started to look brighter. I can see the default icon in the application grid! I have the intro page visible! My first Symbian app is running on Nokia C7! Yey! Crash. Okay. Well, there are always issues so let's fire up the debugger and see where it crashes. But to my disappointment all I get from the debugger is some disassembled byte code. Without exaggerating I spent the next afternoon hunting for the cause of this crash by stepping through the C++ code that is executed after the intro page and by commenting out pretty much everything from the QML code. I finally trace it to the loading of the QML file and the menu QML item. But then I get the crashes randomly no matter how I lay the menu out, no matter which items I put there and how many items the menu has. Very frustrating. Guess what the cause was? I found some values in Qt's documentation for the TARGET.EPOCHEAPSIZE and TARGET.EPOCSTACKSIZE variables that I though were sane and defined them in my .pro file! But I just commented out those two definitions and no more crashes! I was so happy. People familiar with Symbian coding are probably smiling right now, but I don't think there's anything funny in having to define heap and stack sizes in 2011. But I had the QML UI visible on my Symbian device so I was very excited to get on with the actual thing and have Podcatcher for N9 running on Symbian Anna.

Qt Components to the rescue

I really really like QML and Qt Components. It's such an elegant solution to a complex problem. This is why I was so excited to check out how easily I could get Podcatcher for N9 running on Symbian. And to make the story short, I can already let you know that it worked out pretty well. But there's always the one 'but'. Nokia is a big company and you can see it in Qt Components. It's a reflection of when business units inside Nokia have to work together to create a unified developer experience and a cohesive API. In the end to see what they've done I am impressed. But below are some examples of API differences in Qt Components between MeeGo and Symbian and I can't come up with any other explanation for these differences other than there were two separate set of people working on them. In MeeGo you put ToolIcons inside a ToolBarLayout, in Symbian you put ToolButtons. In MeeGo the icon is defined with iconId, in Symbian with iconSource. In MeeGo you show a InfoToolbar with show(), in Symbian you show it with open(). In MeeGo you can define for how long it is visible, in Symbian you cannot. I can't see any technical reason for these differences. I would love to hear the reason for these differences if anyone has some inside information or has some other rational explanation for that matter. When you realize these kind of differences, your excitement over a promise of a cross-platform development platform, based on Qt Components, starts to fade away a bit. You still remember the crash I talked about earlier? Well, it came back to haunt me. Every now and then when I open a QML page (without any C++ code that is being executed, I might add) the app crashes. I also want to point out that I simply cannot get the same QML and C++ code to crash on the N9. It's then when my good buddy Zchydem shared his experience with Symbian and pointed out again the variable TARGET.EPOCHEAPSIZE to me. He also had random crashes if that value "wasn't high enough". So this time, instead of commenting out the variable altogether, but that got me on the right track, I put some values there that I got from Zchydem. TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 in fact. I can only assume that there is now some magic maximum value Symbian is allocating for the heap. And look and behold - the app doesn't crash anymore (at least as often)! This leads me to believe that there are memory management issues in QML with Symbian when pushing and popping Pages from the pageStack and when you do this long enough (or fast enough) your device simply runs out of memory or corrupts its memory stack. Last but not least I must also tell you that the QueryDialog has a bug in Symbian. It will truncate the text you give it, no matter how long it is, if you don't add extra line breaks ('\n') at the end of the texts in the dialog.


I think the best way to summarize my experience with Qt on Symbian is to say "Not as bad as I though it would be, but had more bugs and issues than I hoped for". I am happy that I've done it, Podcatcher (that will be renamed in Nokia Store) runs quite nicely now on my Nokia C7 although it is seemingly slower than on the Nokia N9. Most of the work in porting was related to the lack of truly cross-platform Qt Components, random crashes that were impossible to debug properly, but also to the fact that the screens are different on the N9 and the Symbian^3 devices so adapting your layouts is just necessary. I wanted to avoid duplicating the QML files for Symbian, but this was impossible to avoid. There were just too many layout changes, missing Qt Components or components that had different API.Β  Qt Components (version 1.1 I might add) is not cross-platform between Symbian and MeeGo. Period. However I was happy to notice that absolutely most of the C++ code was running fine on Symbian without any need for modification and this alone is evidence that Qt on Symbian is a huge leap for Nokia to the right direction! To have a nicely running Podcatcher for N9 from MeeGo on Symbian Anna took me from start to finish some two days working on-and-off. It's not that bad, but considering how cross-platform Qt Components and the SDK could be made, it should be better. Would I do it again? Probably not on my spare time. But I could do it again if necessary since Qt on Symbian is not really that bad πŸ™‚


Podmaster is on its way to Nokia Store for all those millions of Symbian Anna and Belle devices as as soon as I get a new icon with a transparent background. So go get it then! πŸ™‚ In the meantime I'll continue writing some more with this same theme. In my next blog post I want to dig deeper into the details of what I did to have Podcatcher for N9 run on Nokia C7 and Symbian Anna and in general what I think are the necessary steps in general to have a MeeGo Qt Components based application run on Symbian. Until then, thanks for reading!  

Technorati Tags: , , , ,

  • KΓΆntzΓ€

    Good text.

    Below is my heavily biased rant about Symbian.

    EPOC/Symbian: it’s first incarnation was concocted together back in early nineties, perhaps earlier. In the times of a non-existing C++ standard, and low-power, low-resource, hand-held devices. (IMHO: at about that time, during my early career, working with embedded systems, I WOULD’VE NEVER THOUGHT ABOUT WRITING AN OS WITH C++). The guys over at Psion figured out some clever stuff to make things happen: let’s forget about pointers to any kind of strings, let’s use descriptors and clean up stacks, etc. They even hacked GCC to better suit their OS and its structures. This
    forced us to use GCC 2.9.something for waaayyy past its best-before -date.

    “There! It’s done. It’s alive, …” During the years, nothing changed, apart from Nokia jumping in and adding a framework after a framework. See, I used to work for Nokia for ~15 years, many a problem was ‘solved’ by creating a project, add lots of management for it, for developing a new framework.

    Regular SW products develop during their life-time. But at its core, Symbian OS didn’t. At some point they could’ve noticed that Hey! C++ has been standardized, it has a standard library that offers strings, exceptions, etc. Let’s add support for those into our OS. But no.

    Device connections are a pain. I’ve managed to get devices working 95% out of my tries. But during the years I’ve had lots of colleagues that have battled with non-functioning connections. My miss rate of 5% is because of some colleague’s computer setup that just wouldn’t work and he refused to uninstall any devices or SW just to reinstall them again, even though I tried to reassure him that things will just work after a reinstall.

    • Thanks for this interesting insight! I’ve never worked for the Symbian organization, but I’ve closely followed what happens with Symbian. And what you say isn’t far from what I would have expected πŸ™‚ I don’t know if things have become saner with Symbian^3, Anna and Belle but on the outside it looks like it and Qt on Symbian is a good step showing the progress. Also it seems that Symbian^3 made the core a lot less kludgy.

  • Anonymous

    Fantastic, cant wait to try it on my C7 πŸ™‚

    • I should be able to send it to Nokia Store QA by the end of the week πŸ™‚

  • Arun

    My C7 is Dead :'( Can u just send me step by step installation guide to my mail id or is there any other version of os compatible with Nokia C7.

    Thanks In Advance,

  • You have to support the symbian specific compile and deployment information describe Qt components different type of API to change the mobile layout view.