I had a lot of fun recently playing with Crosswalk. I was basically testing it’s features and extensions when it hit me: I know it’s possible to write Native extensions for crosswalk Tizen, but is it possible to write Native Extensions for Crosswalk-android? How would it behave?

Crosswalk android already provides a way to load Java extensions, and the Android-NDK provides a way to call a native library from a Java method. We just have to glue those things together.

Adding the .so inside your apk

Crosswalk-samples includes an example application named “extensions-android“. This application builds the extension code first using an “ant” recipe and then builds the html application itself and put both inside an apk file.

By the end of the extension build process, the ant recipe opens the extension.jar file to include the META-INF information inside that file. It’s the perfect time to inject our native library inside the package.

We only have to change the build.xml recipe to include the library.

<copy file="libs/armeabi/libMyLibrary.so" todir="${build}/lib/armeabi-v7a/"></copy>Be sure to do it between <unjar> and <jar> as we’re taking advantage of the fact that the extension jar is being opened and closed to include the META-INF.

Performance measurement

To make a performance test I used an algorithm to find the nth prime number. The approach is the simplest (no pre-built arrays, no recursion) and dumbest (no short-cuts, no AKS, etc) one, and share the same implementation. The implementation is the following:

Prelude

Jump to the next session if you don’t want to read lullabies

There was a time when I was a Qt application developer working with vim. It worked pretty well until I started to work with large applications such as Meego Application Framework.
Hundreds of thousands of files, classes, I couldn’t memorize everything. Then I discovered QtCreator with VI-mode.

I’d never really liked big/heavy IDEs but QtCreator wasn’t that heavy, it had a decent vi-mode and I was able to use the cool things such as auto-completion and jump-to-definition.

Three years later here I’m working with raw VIM again, on top of webkitgtk+ so QtCreator is not an option anymore. What to do?

You can tell me about ctags and cscope… Sorry, ctags and cscope sux for c++ code, really! I tried hard, I wrote scripts to parse the GNUMakefile.list.am and use only the important files but it wasn’t enough. Ctags can’t really deal with classes, doesn’t know much about scopes and VIM auto-completion wasn’t semantic. How to solve that problem all-in-once?

YouCompleteMe

Description

From the original website: “YouCompleteMe is a fast, as-you-type, fuzzy-search code completion engine for Vim.”

Installation

The installation procedures are quite simple and well defined on https://github.com/Valloric/YouCompleteMe#readme
Basically, you need to use Vundle (why are you not using it yet?!) and drop the YCM files in the right place. The installer will do the rest.

vimrc and vundle

if YouCompleteMe is your first Vundle plugin, your .vimrc file should start like this:

Remember to use those lines at the beginning of the file, other rules should appear after that.

How it works

Basically YouCompleteMe uses a .ycm_extra_conf.py, which is a python script that helps YouCompleteMe plugin to find the compiling flags. Those flags are required so clang can interpret #includes and #defines from other files. It might be required a .ycm_extra_conf.py for each project you work on (Although it would be awesome to have a generic Makefile parser).

For webkitGtk, you can drop this file into the root folder and you’re done. Or you can help me to add traction to Ycm and push this patch upstream.

If you’re used to the webkit codebase you know how painful it is when you touch one file, wait two minutes to build and find out that you forgot a semicolon.
You can type \y to check if the file is compilable (clang will actually compile the file for you) and give you warnings/errors for that specific file.
\pc and \pd are also usefull for jump to definition/declaration.

So, if you’re working on WebkitGtk now (or any other project that might benefit from YouCompleteMe), give it a try!

Last week I’ve attended to GStreamerConf and LinuxConf conferences in Prague, and Siraj and I had the honor of having our current project for Collabora exposed on Collabora’s booth. It shared space with two others amazing Collabora‘s demos:

Media Explorer running a Telepathy plug-in, which adds IM and Audio/Video capabilities to the system.

A little bit about Telepathy Webkit Client

During the last few weeks I’ve been working on a Telepathy client, a very special one, written almost only with HTML 5 and Javascript, on top of GTK WebKit and Seed.
The goal of this project was writing a Telepathy based IM client, to run on top of WebKit, and it should be able do make and receive audio and video calls.

GObject introspection magic

The first question to be answered was “How access the Telepathy methods from Javascript?”

As all Gnome developers know, GObject introspection (GIR) allows us to access a GObject written in C from a scriptable language, such as Javascript. So that’s part of the answer.

And Seed binds those introspected objects on WebKit JavascriptCore, which is pretty much what we wanted to do.

Following a few screen-shots

Contact List

Our first goal was to show the Telepathy’s roaster list on a HTML5 window. For the widgets, we choose to use joApp, which is a quite nice and stable UI library for HTML 5 applications.

Chat Window

What’s a IM client without a Chat window, right?!

The “tpwebkit” application with an opened text channel between two users.

Receiving a call

Telepathy WebKit application acting as a Telepathy approver for audio and video calls

That’s me, from the point of view of my test machine…

The real thing running

If you want to see the real thing running, you can watch this video showing the application during the early development state.

Conclusions and future work

As we can see from now, Telepathy is ready to be use on native and HTML applications.
I really would like to see the current implementation integrated with the bleeding edge RTC API, which some guys are pushing to WebKit. That would be something really awesome.

If you want to try it, you can get the code here and play with it. You’re also going to need a few special changes on Seed package. Check the linuxconf branch here.
Or, if you use Ubuntu, you can add Xavier’s PPA and install the tpwebkit package.

It is, basically, a drum loop emulator to be used by musicians during practicing sessions.

You just need to select the samples, define a BPM value and listen to the rhythm ;)

If you can’t wait for the official release at Ovi Store, you can try the beta version for n900 devices.

Remember: it’s a beta version of an open source software. The code can be found linked to my gitorious account.

The technical point of view:

I’m a little bit disappointed with phonon. After a long discussion I’ve realized that phonon could not be used on Beat Maker.

At this time I’m using an approach suggested by Adriano Rezende: play the sound using pulseaudio’s API. I know, it’s not portable. But hey, my target is N900 devices and it worked pretty well at the time.
However, it doesn’t scale. So, now, I’m working on a kind of “in-app-mixer”, which should solve this problem.

There is another problem, related to QTimer. Qt can’t guarantee the timing between the beats using QTimer events. Especially when you generate mouse events. Anyway, the mixer controller loop should solve this as well.

Big thanks to Adriano for the tips, and Allyson who made the excellent UI design.

After two and a half years building rich UIs on top of QGraphicsView and trying every kind of exotic flags or approaches to get better performance results on symbian, I’ve decided to publish some of them which can be useful to game programmers.

With a little help of Ademar, we’ve selected a good use case: a bouncing game.

The game

This game is simple: there are some balls running on the screen, and if you press one of them it will explode, and if a red ball touches a exploded ball, it will explode too. However the game logic is not important here. Lets list some of the characteristics of this game from a developer’s point of view:

Static background.

Balls can be implemented as GraphicsItems.

Red balls are always moving.

Non-exploded ball doesn’t collide.

List of elements can grow fast.

The items are scattered on the screen

The comments bellow are only valid for the characteristics of a game defined above.

The flags

The results

* Those tests were performed on a Nokia 5800, type RM-356, with V51.0.006 firmware and Qt 4.6.3.
** The Y axis is measuring FPS: the higher, the better.

10 elements on the screen

First of all, I’ve tried the four ViewportUpdate methods, with 10 items on the screen, and the MinimalViewportUpdate and the SmartViewportUpdate gave me the highest FPS( 34 and 33.5) . Qt documentation shows NoIndex as the best option for dynamic scenes… well, the difference is small for few items, but it’s true =)

20 elements

30 elements

40 elements

Lessons Learned

It’s important to select the correct ViewportUpdate method for your kind of scene. It can make the difference.

If there is a lot of dynamic elements, and if they are scattered throughout the scene, it’s cheaper to paint the whole screen (or, at least, the bounding rect) instead of trying to determinate the affected area.

To be honest I was expecting a better result from FullViewportUpdate, but I believe it would be better than BoundingRect if we use non-static background.

What if?

What if I use only one graphicsItem to paint all the balls? What if a ball was not an item but an object with a render method?

I got a little bit surprised, it wasn’t the result I was expecting – it’s worst. It only gets to be better when I put more than 60 items on the screen.

Will I throw the code in the garbage can?

No! As the result of the tests and with a creative help of Nara – INdT designer – I’m releasing a playable alpha version of this game, called by Chubba-Lubba. It’s not finished, since it’s still missing the icon, sounds and scores features, but it’s testable =)

Trolls are working on that, but for now we’re using the runonphone tool. It’s the same tool used by QtCreator on Windows and you can get it by cloning Qt Repository and compiling the /tools/runonphone folder.

On device testing

After compiled, runonphone can be used by passing the serial port, the sis package and the executable file to it.runonphone -p /dev/ttyUSB0 -s test_package.sis test_package.exe

As you probably noticed all your qWarning() messages are being redirected to runonphone output. Which is very nice!

On device debugging

We don’t have an interative gdb tool as we have on windows, but Qt guys are close and I’m sure we will have good news in a few days.

Concluding

I’m sure that Symbian development on Linux is near, and it will be massively adopted when those tools became part of QtCreator for linux. For those who can’t wait, or think that VIM is the best IDE ever, I hope those tips can help you. =)

And for those who’re working with Qt for symbian, remember to join the #qt-symbian on Freenode.

First: KDE 4.2 was released. I’m using as my “oficial desktop manager” at work and I’m pretty happy about it.

Second: Debian Lenny might be released this month. I’m using it too, and I know the result will be very good!

Third: BossaConference agenda is ready. Think about great minds talking about OpenSource, Maemo, etc, in a paradisaical beach. I had the opportunity to join Bossa ’07, and it was great! We can’t miss this one! See you there! =)

When I was trying to pairing my keyboard, I could see that Su-8W is a pre-configurated keyboard, and with a little of patience, I dicovered the file who manages this: /usr/share/X11/xkb/symbols/nokia_vndr/su-8w.

With 5 minutes by reading this file you can be familiarized with file syntax. And, with 10 minutes, you can note that THERE IS NOT A LAYOUT DEFINITION FOR PORTUGUESE/SPANISH. So, now I know why the Portuguese layout doesn’t work =).

But, Ok. Lets try to fix it.

If I select portuguese layout, and there is no portuguese layout, I assume that it’ll use us-intl, right? But, in the begining of the intl definition exists a anoying comment: “I can’t belive! It’s not intl”. Hummm…

Lets ignore this, and go on… What do I need? Dead_keys in `,~,",',^, and ç when I press “ALTgr + c”.

I’ll not explain all the changes I did (it’s not too much, just 4 boring lines), is easier to download and replace the old file by this one, or see the diff. [ADVISE: DO NOT FORGET TO BACKUP THE OLD FILE]

And Voilà, Accents and Cedilla working like a charm.

The right workaround for it is create a valid portuguese layout, but just for testing proposes you can alter the intl layout.