Canonical Voices

Posts tagged with 'article'

Benjamin Zeller

In the last couple of weeks, we had to completely rework the packaging for the SDK tools and jump through hoops to bring the same experience to everyone regardless if they are on LTS or the development version of Ubuntu. It was not easy but we finally are ready to hand this beauty to the developer’s hands.

The two new packages are called “ubuntu-sdk-ide” and “ubuntu-sdk-dev” (applause now please).

The official way to get the Ubuntu SDK installed is from now on by using the Ubuntu SDK Team release PPA:

Releasing from the archive with this new way of packaging is sadly not possible yet, in Debian and Ubuntu Qt libraries are installed into a standard location that does not allow installing multiple minor versions next to each other. But since both, the new QtCreator and Ubuntu UI Toolkit, require a more recent version of Qt than the one the last LTS has to offer we had to improvise and ship our own Qt versions. Unfortunately that also blocks us from using the archive as a release path.

If you have the old SDK installed, the default QtCreator from the archive will be replaced with a more recent version. However apt refuses to automatically remove the packages from the archive, so that is something that needs to be done manually, best before the upgrade:

sudo apt-get remove qtcreator qtcreator-plugin*

Next step is to add the ppa and get the package installed.

sudo add-apt-repository ppa:ubuntu-sdk-team/ppa \
    && sudo apt update \
    && sudo apt dist-upgrade \
    && sudo apt install ubuntu-sdk

That was easy, wasn’t it :).

Starting the SDK IDE is just as before, either by running qtcreator or ubuntu-sdk directly and also by running it from the dash. We tried to not break old habits and just reused the old commands.

However, there is something completely new. An automatically registered Kit called the “Ubuntu SDK Desktop Kit”. That kit consists of the most recent UITK and Qt used on the phone images. Which means it offers a way to develop and run apps easily even on an LTS Ubuntu release. Awesome, isn’t it Stuart?

The old qtcreator-plugin-ubuntu package is going to be deprecated and will most likely be removed in one of the next Ubuntu versions. Please make sure to migrate to the new release path to always get the most recent versions.

Read more

As a follow-up to our previous post A Fast Thumbnailer for Ubuntu, we have published a new tutorial to help you make the most of this new SDK feature in your apps.

You will learn how to generate on-demand thumbnails for pictures, video and audio files by simply importing the module in your QML code and slightly tweaking your use of Image components.

Read the tutorial ›

Read more
Thibaut Rouffineau

The Eclipse Foundation has become a new home for a number of IoT projects. For the newcomers in the IoT world it’s always hard to see the forest for the trees in the number of IoT related Eclipse projects. So here is a first blog to get you started with IoT development using Eclipse technology.

The place to start with IoT development is MQTT (Messaging Queuing Telemetry Transport). MQTT is a messaging protocol used to send information between your Things and the Cloud. It’s a bit like the REST API of the IoT world, it’s standardised and supported by most clients, servers and IOT Backend As A Service (BaaS) vendors (AWS IOT, IBM Bluemix, Relayr, Evrything to name a few).

If you’re not familiar with MQTT here is a quick rundown of how it works:

  • MQTT was created for efficient and lightweight message exchanges between Things (embedded devices / sensors).

  • An MQTT client is typically running on the embedded device and sends messages to an MQTT broker located on a server.

  • MQTT messages are made of 2 fields a topic and a message.

  • MQTT clients can send (publish in MQTT linguo) messages on a specific topic. Typically a light in my kitchen would send a message of this type to indicate it’s on:  topic =”Thibaut/Light/Kitchen/Above_sink/pub” message=”on”.

  • MQTT clients can listen (subscribe in MQTT linguo) to messages on a specific topic. Typically a light in my kitchen would subscribe to messages to await for instruction to be turned off by subscribing to the  topic =”Thibaut/Light/Kitchen/Above_sink/sub” and waiting for a message: message=”turn_off”.

  • MQTT brokers listen to incoming messages and retransmit the messages to clients subscribed to a specific topic. In this way it resembles a multicast network.

  • Most MQTT brokers are running in the cloud but increasingly MQTT brokers can be found on IoT gateways in order to do message filtering and create local rules for emergency or privacy reasons. For example a typical local rule in my house would be if a presence sensor in the kitchen sends a message saying that no one is in the kitchen a simple rule would send a message to the light to switch it. Our rules engine would look like: if receive message: topic=”Thibaut/presence_sensor/Kitchen/pub” message =”No presence”  then send message on topic =”Thibaut/Light/Kitchen/Above_sink/sub” with message=”turn_off”

  • BaaS vendors would typically offer a simple rules engine sitting on top of the MQTT broker, even though most developers would probably build their rules within their code. Your choice!

  • To get started Eclipse provides multiple MQTT client under the Paho project

  • To get started with your own broker Eclipse provides an MQTT broker under the Mosquitto project

  • Communication between MQTT client and broker supports different level of authentication from none to using public /private keys through username / password

  • When using a public MQTT broker (like the Eclipse sandbox) your messages will be visible to all people who subscribe to your topics so if you’re going to do anything confidential make sure you have your own MQTT broker (either through a BaaS or build your own on a server).

That’s all there is to know about MQTT! As you can see it’s both simple and powerful which is why it’s been so successful and why so many vendors have implemented it to get everyone started with IoT.
And now is your time to get started!! To help out here’s a quick example on Github that shows you how you can get the Paho Python MQTT running on Ubuntu Core and talking to the Eclipse Foundation MQTT sandbox server. Have a play with it and tell us what you’ve created with it!

Read more
April Wang



全球飞行影像系统开拓者DJI大疆创新发布专为飞行平台设计的嵌入式高性能机载电脑“妙算” Manifold。配合大疆Onboard SDK,妙算提供了便捷易用的全新功能,让开发者释放创造力,打造更加强大的无人机行业应用。

大疆创新战略合作总监Michael Perry表示:“妙算将开启智能飞行平台的全新时代,作为联接地面设备和飞行终端的智能协作中枢,妙算可为复杂的行业应用提供解决方案。我们非常期待开发者通过妙算开发出令人眼前一亮的应用”。

妙算能够广泛扩展第三方传感器,开发者在经纬M 100上可通过妙算连接红外摄像机、气象研究设备以及地理信息采集设备,并可在飞行中实时收集和分析数据。

妙算搭载Canonical公司的Ubuntu操作系统,并支持CUDA, OpenCV以及ROS。配备英伟达Tegra嵌入式处理器,其包含四核ARM Cortex A-15处理器和Kepler架构的图形处理单元,这使得妙算不仅能实现强大的图像处理能力,且能高效地处理并行任务。此外,妙算还可广泛应用于计算机视觉、深度学习等人工智能领域,并提供USB、Ethernet、HDMI等丰富的接口,用于连接传感器、显示屏等多种扩展设备。

Canonical公司智能设备及全球战略合作副总裁Mark Murphy说:“我们非常高兴能与DJI大疆创新合作,Canonical和大疆创新分享同样的愿景,致力于推动科技进步,为开发者铺平前进的道路”。

搭载Ubuntu 14.04 LTS版本的妙算将于今日在大疆创新官方商城全球同步预售,中国大陆地区该产品售价为人民币2999元。欲获取更多详情,请访问

Read more
April Wang

TC 北京黑客马拉松

Ubuntu在中国已经举办了两次黑客松了,而这次受TC 中国邀请有机会作为赞助方参加了TC北京黑客马拉松活动。规模当然更高、更大、更尚,这次活动让我们遇到了更多Ubuntu小伙伴们,也让更多志同道合的程序猿们进一步了解到Ubuntu;最开心的是在这次活动中还有遇到之前活动中认识的老朋友呢!

这次黑客松在位于北京五棵松的Hi-Park举行,这里需要特别强调并称赞一下TC中国TechNode队伍的能力和体力,让这个室内篮球场地一夜间变身Hi-Tech Power House. 正巧碰到是万圣节,活动现场诡异事件连连发生。开玩笑了,现场布置是一番万圣趴的气氛,相比寻常黑客松,也另增了一份活泼。

黑客松命题在这次活动中采用了混搭方式, 有三项挑战任务,设有专项命题和作品要求,有机会获得特别的几项大奖;同时开发者们也可以随意出作品做展示,依然有机会获得主办方为大家准备的丰厚礼品。作为命题挑战任务之一的Ubuntu任务,其实算是一个题目比较开放的任务,大家可以通过为Ubuntu手机开发应用或Scope来参与挑战, 也可以通过使用snappy Ubuntu Core来搭建任何智能物联网项目来参与挑战。


这次黑马是正式从第一天的下午1点进入组队开工的,在第二天的上午9点半就开始提交作品, 实际真正写打码的时间也就是20多个小时的样子。作品展示是在次日上午10点钟正式开始的,一共有29组成功完成了作品展示,这里我们挑俩组针对Ubuntu挑战任务而来的作品介绍一下,希望在之后的日子里能看到所有参加挑战的作品成功上线。



双人小组, 专为难以入睡的你们(夜猫子们)定制。这是一款基于Ubuntu手机的应用,通过播放音乐来协助入眠, 同时这款应用可以和手环对接, 通过手环对人体睡眠状态的检测给到应用提示来调整音乐音量,从而达到你已入睡音乐也停,解决睡意正浓时刻起身关音的痛苦。这款应用巧妙结合使用不同智能设备,完成解决了一个大家都曾遇到过的问题。我已经期待能早日在Ubuntu商店中看到并下载这款应用了。



看这名字大家也大约可以猜到会和我们的snappy Ubuntu Core有些关系了,没错,这款应用通过使用snappy Ubuntu Core利用音频来测算智能设备之间距离的跨平台(ubuntu,安卓和IOS)应用,简而言之就是智能设备相互距离的量尺。听起来仿佛很简单,在这个智能设备日益寻常的今天,它被进一步应用的场景其实展示了更多的可能性。你有想到吗?



TC Beijing Hackathon









Read more
April Wang

手机更新: OTA-7



- 社交应用功能提高, 现在支持点“赞”和转发功能


- 新增搜索历史记录
- 提高的场景菜单有下载链接选项
- Http基础验证支持


- 支持SVG格式
- Soundcloud网页版应用可以在后台播放


- 修复 test.mmrow exploit
- 修复UI冻结 (FD leaks)
- 默认不会在stable channel发布奔溃报告
- 修复 QML cache 和重新存储一致应用启动次数
- 在浏览器中默认使用更少的记忆空间,并且避免网页应用呈现白屏
- 用感应器侦测距离,自动关闭电话背光

Read more
April Wang


原作者:Richard Collins


当一部智能手机能够为用户提供和他们常用电脑同样的用户体验时,这部智能手机才是在真正意义上同时起到了移动手机兼个人电脑的重任。 这也是我们作为真正智能手机融合的一个起点 - (通过一款智能手机)来为成千上百对Ubuntu桌面电脑非常熟悉的用户提供同样的Ubuntu个人电脑体验。 简而言之,就是用户对一台个人电脑的使用体验期待必须也能够在他们的智能手机上获得。 这包括了:

- 轻松的多任务多窗口管理
- 全套支持移动和生产力的桌面应用和瘦客户端支持
- 带有桌面提示的集成服务
- 具有应用管理及便捷打开常用应用的能力
- 简单翻阅文档,创建和管理文档文件夹
- 响应性应用专为触屏和点击输入开发,可以自行根据设备环境调整UI呈现方式
- 综合性系统操控以及在需要时对底层操作系统的访问
- 包含一系列兼容第三方服务的统一应用商店
- 在桌面界面上使用手机电话和短信应用来进行交流

操作系统融合之路最初是从Unity 8开始的。 Unity 8 是Ubuntu自有的用户界面和呈现框架,它将预计被运行于所有基于同样底层代码库的Ubuntu设备上,支持一个常用的应用和服务开发基础架构。Unity 8的目标就是能够作为首要呈现框架运行于任何Ubuntu智能产品上。

这就意味着应用程序拥有了其他操作系统无法提供的一个东西:唯一的视觉框架以及一套让应用程序可以在任何类型的Ubuntu智能设备上运行的工具。为移动设备开发的应用程序可以轻松的扩展适用于桌面呈现,同时还支持点击类输入。我们的SDK会为移动应用开发者提供创建这些应用桌面版场景的工具。 类似的,桌面应用的开发者可以使用我们的SDK来延伸并加强他们程序应用于移动端的功能。 融合为开发者们带来了一套全新的场景,而我们的SDK将为开发者们让他们应用程序轻松应用于任何界面提供了基础类工具。

你在(ubuntu)手机上和(ubuntu)桌面上看到和使用的同一款应用程序, 他们将会是完全一样的一套代码运行着这款应用。Ubuntu不需要区别这款应用是专门为移动端还是为桌面呈现而编写的,而是这款应用会自动根据运行的设备呈现环境来自动调用相应的交互界面。第三方开发者们只需要为Ubuntu编写一次代码完成应用开发, 这款应用便可以运行于不同的Ubuntu界面。

我谈论智能手机进化成为一个融合型形态,提供个人电脑体验,是一个业内真实相关的需求为时很久了。 但是一个真正融合化的智能手机或平板,结合移动和桌面生产力而设计,是在使用搭建于唯一而且完全受控代码库基础上的操作系统才可以为被称为真正完成。

Read more
April Wang

支持 App 的蜘蛛机器人

本文是 Erle-Robotics 团队为《创业故事》系列博客文章撰写的一篇客座文章。《创业故事》系列主要介绍创新型公司为何以及如何运用 Ubuntu 技术。


Erle-Spider 是第一款由 ROS 提供支持并运行 Snappy Ubuntu Core 的多足无人机。 这款智能机器人配备 900 MHz 四核 ARM Cortex-A7 处理器,原生运行 Linux 操作系统,并嵌入了多个板载传感器。 它具有六只机器足,旨在满足学习、研究和开发领域对机器人套件不断增长的需求,同时所受的监管程度较低。 该无人机还能够进入管道和灾区等难以到达的地方,携带摄像头,并支持 Wi-Fi、蓝牙以及 3G 和 4G 网络技术,以根据需要提供连接。


这台 Linux 六足计算机由 Snappy Ubuntu Core 提供支持,并可连接 Canonical 推出的基于云的 App 商店,让用户可开发和出售机器人行为和无人机应用程序。 很快,此无人机将提供计算机视觉算法、不同的动态模型和传感器实施等一些功能。


Erle-Spider 项目已在 Indiegogo 平台上启动 (,并将于今年圣诞节上市,售价仅为 399 美元。

Read more

After Victor Palau wrote a new blog for his PiGlow API snap, I tried to operate PiGlow LED and learnt following ways to interact with it.

a. Use python:

python3 -c 'from urllib.request import urlopen; print(urlopen("http://REALIP:8000/v1/on", data=b""))'

b. Use curl:

curl -i -X POST "http://REALIP:8000/v1/on"

c. Use html web page in web browser

<title>test piglow</title>
<form action="" method="post">
<input type=submit value=flare>

Read more
Zsombor Egri

Adaptive page layout made flexible

A few weeks ago Tim posted a nice article about Adaptive page layouts made easy. It is my turn now to continue the series, with the hope that you will all agree on the title.

Ladies and Gentlemen, we have good news and (slightly) bad news to announce about the AdaptivePageLayout. If the blogging would be interactive, I’d ask you which one to start with, and most probably you would say with the bad ones, as it is always good to get the cold shower first and then have a sunbath. Sorry folks, this time I’ll start with the good news.

The good news

We’ve added a column configurability API to the AdaptivePageLayout! From now on you can configure more than two columns in your layout, and for each column you can configure the minimum, maximum and preferred sizes as well as whether to fill the remaining width of the layout or not. And even more, if the minimum and maximum values of the column configuration differs, the column can be resized with mouse or touch. See the following video demonstrating the feature.

And all this is possible right now, right here, only with Ubuntu UI Toolkit!

You can configure any number of column configurations, with conditions when those should be applied. The one column mode doesn’t need to be configured, that is automatically applied when none of the specified column configuration conditions apply. However, if you wish, you can still configure the single column mode, in case you want to apply minimum width value for the column. Note however that the minimum width configuration will not (yet) be applied on the application’s minimum resizable width, as you can observe on the video above.

The video above was made based on the sample code from Tim’s post, with the following additions:

AdaptivePageLayout {
    id: layout
    \\ [...]
    layouts: [
        // configure two columns
        PageColumnsLayout {
            when: layout.width >
            PageColumn {
            PageColumn {
                fillWidth: true
        // configure minimum size for single column
        PageColumnsLayout {
            when: true
            PageColumn {
                fillWidth: true

The full source code is on lp:~zsombi/+junk/AdaptivePageLayoutMadeFlexible.

The bad news

Oh, yes, this is the time you guys start to get mad. But let’s see how bad it is going to be this time.

We started to apply the AdaptivePageLayout in a few core applications, when we realized that the UI is getting blocked when Pages with heavy content are added to the columns. As pages were created synchronously, we would have had to redo each app’s Page content management to be able to load at least partially asynchronously using Loaders. And that seemed to be a really bad omen for the component. So we decided to bring in an API break for the AdaptivePageLayout addPageTo{Current|Next}Column() functions, so if the second argument is a file URL or a Component, the functions now return an incubator object which can be used to track the loading completion. In the case of an existing Page instance, as you already have it, the functions will return null. More on how to use incubators in QML can be read from

A code snippet to catch page completion would then look like

var incubator = layout.addPageToNextColumn(thisPage, Qt.resolvedUrl(pageDocument));
if (incubator && incubator.status == Component.Loading) {
    incubator.onStatusChanged = function(status) {
        if (status == Component.Ready) {
            // incubator.object contains the loaded Page instance
            // do whatever you wish with the Page
            incubator.object.title = "Dynamic Page";

Of course, if you want to set up the Page properties with some parameters, you can do it in the good old way, by specifying the parameters in the function, i.e.

addPageToNextColumn(thisPage, Qt.resolvedUrl(pageDocument), {title: “Dynamic Page”}).

The incubator approach you would need if you want to do some bindings on the properties of the page, which cannot be done with the creation parameters.


So, the bad news is not so bad after all, isn’t it? That’s why I started with the good news ;)

More “bad” news to come

Oh, yes, we have not finished yet with the bad news. So from now on pages added to the columns are asynchronous by default, except the very first page. That is still going to be loaded synchronously. The good news: it is not for long ;) We are planning to enable asynchronous loading of the primary page as well, and most probably you will get a signal triggered when the page is loaded. In this way you would be able to show something else while the first page is loading, an animation, another splash screen, or the Flying Dutchman, whatever :)

Stay tuned! We’ll be back!


Read more
David Planella

Snappy Ubuntu + Mycroft = Love

This is a guest post from Ryan Sipes, CTO of the Mycroft project, explaining how snappy Ubuntu will enable them to deliver a secure and open AI for everyone.

When we first undertook the Mycroft project, dubbed the “AI For Everyone”, we knew we would face interesting challenges. We were creating a voice-controlled platform not only for assisting you in your daily life with weather, news updates, calendar reminders, and answers to your questions - but also a hub which would allow you to control your Internet of Things, specifically in the form of home automation. Managing all these devices through a seamless user experience requires a strong backbone for developers, and this is where snappy Ubuntu Core works wonders.

Since choosing to base our open source, open hardware product called Mycroft on snappy Ubuntu Core, we have found the platform to be amazing. Being able to build and deliver apps easily through Snappy packages, makes for a quick and painless packaging experience with only a short bit required to get up to speed and start creating your own. We’ve taken advantage of this and are planning to use Snappy packages as the main delivery method of apps on our platform. Want to install the Spotify app on Mycroft? Just install the Snappy package, which you’ll be able to do with a just a click.

But Snappy Core’s usefulness goes beyond creating packages, the ability to do transactional updates of apps makes testing and stability easier. We’ve found that the ability to rollback an update to be critical in ensuring that we are our platform is working when it needs to, but it has also made it possible to test for bugs on versions that we are unsure about - and rollback when there is serious breakage. As we continue to learn more, we are every impressed with this feature of Snappy.

We’re going to be leveraging snappy Ubuntu Core and “Snaps” to deliver applications to Mycroft, and when talking about a platform that sits in your home and has the ability to install third party software an important conversation about privacy in necessary. We are doing our best to ensure that user’s critical data and interactions with Mycroft are kept private, and Snappy makes our job easier. Having a great deal of control over security policies of apps and being able to make applications run in a sandbox, allows us to take measure to ensure the core system isn’t compromised. In a world where you are interacting with lots of IoT devices every day, security is paramount, and Snappy Core Ubuntu doesn’t let you down.

In case you couldn’t tell from the paragraphs above, the Mycroft team is ecstatic to be using such an awesome technology on which to build our open source artificial intelligence and home automation platform. But one thing I didn’t talk about was the awesome community surrounding Ubuntu and the passionate people working for Canonical that have poured their time into this amazing project and that, above all, is the best reason for using Snappy Core.

If you are interested in learning more about Mycroft, please check out our Kickstarter and consider backing the project. We’ve only got a few days left, but we promise that we will continue to keep everyone posted about our experiences as we continue to use Snappy Core while we work on the #AIForEveryone.

I want AI for everyone too! >

Read more
Zoltán Balogh

The Next Generation SDK

Up until now the basic architecture of the SDK IDE and tools packaging was that we have packaged and distributed the QtCreator IDE and our Ubuntu plugins as separate distro packages which strongly depend on the Qt available in the same release.

Since 14.04 we have been jumping through hoops to provide the very same developer experience from a single development branch of the SDK projects. Just to give a quick picture on what we have available in the last few releases (note that 1.3 UITK is not yet released):

14.04 Trusty Qt 5.2.1 QtCreator 3.0.1 UI Toolkit 0.1
14.10 Utopic Qt 5.3. QtCreator 3.1.1 UI Toolkit 1.1
15.04 Vivid Qt 5.4.1 QtCreator 3.1.1 UI Toolkit 1.2
15.10 Wily Qt 5.4.2 QtCreator 3.5.0 UI Toolkit 1.3

Life could have been easier by sticking to one stable Qt and QtCreator and base our SDK on it. Obviously it was not a realistic option as the phone development needed the most recent Qt and our friend Kubuntu required a hot new engine under its hood too. So Qt was quickly moving forward and the SDK followed it. Of course it was all beneficial as new Qt releases brought us bugfixes, new features and improved performance.

But on the way we came to realize that continuously backporting the UITK and the QtCreator plugins to older releases and the LTS was simply not going to be possible. It went fine for some time, but the more API breaks the new Qt and QtCreator releases brought the more problems we had to face. Some people have asked why we don’t backport the latest Qt releases to the LTS or to the stable Ubuntu. As an idea it may sound good, but changing the Qt to 5.4.2 under an application in LTS what was built against 5.2.1 Qt would certainly break that application. So it is simply not cool to mess around with such fundamental bits of a stable and long term supported release.

The only option we had was to decouple the SDK from the archive release of Qt and build it as a standalone package without any external Qt dependencies. That way we could provide the exact same experience and tools to all developers regardless if they are playing safe on Trusty/LTS or enjoy the cutting edge on the daily developed release of Wily.

The idea manifested in a really funny project. The source tree of the project is pretty empty. Only cmake and the debian/rules take care of the job. The builder pulls the latest stable Qt, QtCreator and UITK. Builds and integrates the libdbusmenu-qt and appmenu-qt5 projects and deploys the SDK IDE. The package itself is super skinny. Opposing the old model where QtCreator has pulled most of the Qt modules as dependencies this package contains all it needs and the size of it is impressing 36MB. Cheap. Just the way I like it. Plus this package already contains the 1.3 UITK as our QtCreator plugin (Devices Tab) is using it. So in fact we are just one step from enabling desktop application development on 14.04 LTS with the same UI Toolkit as we use on the commercial phone devices. And that is a super hot idea.

The Ubuntu SDK IDE project lives here:

If you want to check out how it is done:

$ bzr branch lp:ubuntu-sdk-ide

Since we considered such a big facelift on the SDK I thought why not to make the change much bigger. Some might remember that there was a discussion on the Ubuntu Phone mailing list about the possibility to improve the Kit creation in the IDE. Since then we have been playing with the idea and I think it is now a good time to unleash the static chroots.

The basic idea is that creating the builder chroots runtime is a super slow and fragile process. The bootstrapping of the click chroot already takes a long time and installing the SDK API packages (all the libs and dev packages with headers) into the chroot is also time consuming. So why not to create these root filesystems in advance and provide them as single installable packages.

This is exactly what we have done. The base of the API packages is the Vivid core image. It is small and contains only the absolutely necessary packages, we install the SDK libs, dev packages and development tools on the core image and configure the Overlay PPA too. So the final image is pretty much equivalent with the image on a freshly updated device out there. It means that the developer can build and test against the same API set as it is available on the devices.

These API packages are still huge. Their size is around 500MB, so on a slow connection it still takes ages to download, but still it is way faster than bootstrapping a 1.6GB chroot package by package.

This API packages contain a single tar.gz file and the post install script of the package puts the content of this tar.gz to the right place and wires it in, in the way it should be. Once the package is installed the new Kit will be automatically recognized by the IDE.

One important note on this API package! If you have an armhf 15.04 Kit (click chroot) already on your system when you install this package, then your original Kit will not be removed but simply renamed to backup-[timestamp]-[original name]. So do not worry if you have customized Kits, they are safe.

The Ubuntu SDK API project is only a packaging project with a simple script to take care of the dirty details. The project is hosted here:

And if you want to see what is in it just do

$ bzr branch lp:ubuntu-sdk-api-15.04  

The release candidate packages are available from the Tools Development PPA of the SDK team:

How to test these packages?

$ sudo add-apt-repository ppa:ubuntu-sdk-team/tools-development -y

$ sudo apt-get update

$ sudo apt-get install ubuntu-sdk-ide ubuntu-sdk-api-tools

$ sudo apt-get install ubuntu-sdk-api-15.04-armhf ubuntu-sdk-api-15.04-i386

After that look for the Ubuntu SDK IDE in the dash.

Read more
April Wang

因为黑客松活动,在炎炎夏日的8月里第一次飞到了深圳,这个潮湿闷热的城市让我“大跌眼镜”(不停冒汗,眼镜真的一直往下掉)。 活动现场是在位于福田区华强北商圈中的华强创客中心,不论是平日里还是周末,路边楼下仿佛永远都是人流涌动热闹非凡。华强北创客中心是由华强集团倾力打造,中国第一个为创业者提供一站式服务的综合型创新创业生态平台。一期建筑面积有5000㎡,位于华强广场B座7楼的空中花园,堪称是华强北闹市中的一片室外桃园。整体设计布满了类似街头艺术的graffiti式画作,置身其中就能感受到它灵感激发的能量,黑客松选这里自然是理所当然。


Canonical一直坚信激励创新的最佳方式就是将他们需要的技术给到创新者的手中,这次深圳黑客松除了Ubuntu手机操作系统平台之外,我们还带了Ubuntu Snappy Core, 一款安全易用的智能硬件操作系统技术。针对这个最新技术, 我们在活动TechTalk环节详细讲解了如何通过KVM来做开发的上手介绍。错过的同学可以在这里下载文档参看视频。而参加活动的同学们通过将Ubuntu手机平台和Snappy技术相结合将会获得特别IoT奖项。所以这场活动的亮点和看点更加有趣。 


呵呵, 开玩笑了,一定是有吃有喝有玩有乐了,而且还有夜宵火锅,台式足球。

既然是场hackathon,重头戏当然还是这场hacking party产出的作品了。下面我就挑几组现场做了作品和大家分享。

QML Git-OSC是由开源中国团队开发的一款基于QML的Ubuntu手机应用,有了它程序猿攻城狮们可以直接通过Ubuntu手机端访问查看保存在自己在Git@OSC上的Repo详情和代码了。作为一款为写代码人群定制的应用,这组团队成功获得了最佳上手奖- 樱桃机械键盘。


这场黑客松中最吸引眼球的团队E Minor(E小调),在30个小时的黑客松内产出了两款作品:LibreOffice Impress Remote 和让我从第一天就在期待的Project MrRobot。Impress Remote作品正如其名,可以让你的Ubuntu手机即刻变成你Impress文档的remote,简单但超级实用。Project Mr Robot是一款由Ubuntu手机操控超萌Rapiro机器人的应用,通过这款应用你可以通过语音,按键和摇手机来操控它。两款作品的代码也完全开源,感兴趣的同学们可以在这里这里分别找到他们的代码。这支团队,轻松拿下我们的最佳颜值奖(Ubuntu双肩背包)和最佳极客奖(由华硕公司特别赞助的移动便携投影仪);这里也特别感谢为这组颁奖,也是我们现场评审之一的美女评审秦夏鸿女士(灵游科技的副总裁)。此外Project Robot在活动结束第二天就已经被Softpedia点名报道了。

IoT Ranger是一款专为电脑牵挂强迫症人群定制的应用。它为Ubuntu手机用户提供了一个随时监测家里电脑运行状态的应用。这款基于cordava的Ubuntu手机应用,巧妙使用运行在kvm环境下的网络服务框架,成功的将Ubuntu Snappy Core技术和Ubuntu手机应用开发相结合。绝对是这次黑客松中当之不愧的IoT特别奖项作品,自然拿下了我们精心准备的Beaglebone Black。

活动现场展示的作品还有几组我就不在这里一一介绍了, 感兴趣的同学们可以后续在Ubuntu开发者网站(的黑客松页面找到每组作品介绍。在短短的30个小时内,我们见证了如此之多的精彩,不禁就已经开始期待下一次了。 希望在后面的日子里,每个团队都能实现作品的成功部署,在外面的世界里成功立足。 代码写的辛苦,但是能和兴趣相投的人一起通宵畅聊应该是最过瘾的事了。在此献上活动现场制作的文化衫照片和大家分享。

最后要再次感谢这次活动的特约赞助商华硕,除了特别极客奖之外,还为大家提供了丰盛的签到奖和现场Demo奖;感谢线上线下的协办单位和论坛平台让这场黑客松成为可能(Git@OSC, SegmentFault,开源中国开源社Linux伊甸园Linux中国Linuxtoy.orgQTCN开发网, Meego南极圈深圳开放创新实验室SegmentFault腾讯开放平台优麒麟中芬设计园),感谢现场评审团队,还有让这场活动分外精彩的场地赞助华强北创客中心,为大家提供分外精彩的场地赞助,轻松愉快的氛围激发大家无限的创作灵感。


Read more
Michi Henning

A Fast Thumbnailer for Ubuntu

Over the past few months, James Henstridge, Xavi Garcia Mena, and I have implemented a fast and scalable thumbnailing service for Ubuntu and Ubuntu Touch. This post explains how we did it, and how we achieved our performance and reliability goals.


On a phone as well as the desktop, applications need to display image thumbnails for various media, such as photos, songs, and videos. Creating thumbnails for such media is CPU-intensive and can be costly in bandwidth if images are retrieved over the network. In addition, different types of media require the use of different APIs that are non-trivial to learn. It makes sense to provide thumbnail creation as a platform API that hides this complexity from application developers and, to improve performance, to cache thumbnails on disk.

This article explains the requirements we had and how we implemented a thumbnailer service that is extremely fast and scalable, and robust in the face of power loss or crashes.


We had a number of requirements we wanted to meet in our implementation.

  • Robustness
    In the event of a crash, the implementation must guarantee the integrity of on-disk data structures. This is particularly important on a phone, where we cannot expect the user to perform manual recovery (such as cleaning up damaged files). Because batteries can run out at any time, integrity must be guaranteed even in the face of power loss.
  • Scalability
    It is common for people to store many thousands of songs and photos on a device, so the cache must scale to at least tens of thousands of records. Thumbnails can range in size from a few kilobytes to well over a megabyte (for “thumbnails” at full-screen resolution), so the cache must deal efficiently with large records.
  • Re-usability
    Persistent and reliable on-disk storage of arbitrary records (ranging in size from a few bytes to potentially megabytes) is a common application requirement, so we did not want to create a cache implementation that is specific to thumbnails. Instead, the disk cache is provided as a stand-alone C++ API that can be used for any number of other purposes, such as a browser or HTTP cache, or to build an object file cache similar to ccache.
  • High performance
    The performance of the thumbnailer directly affects the user experience: it is not nice for the customer to look at “please wait a while” icons in, say, an image gallery while thumbnails are being loaded one by one. We therefore had to have a high-performance implementation that delivers cached thumbnails quickly (on the order of a millisecond per thumbnail on an Arm CPU). An efficient implementation also helps to conserve battery life.
  • Location independence and extensibility
    Canonical runs an image server at that provides album and artist artwork for many musicians and bands. Images from this server are used to display artwork in the music player for media that contains ID3 tags, but does not embed artwork in the media file. The thumbnailer must work with embedded images as well as remote images, and it must be possible to extend it for new types of media without unduly disturbing the existing code.
  • Low bandwidth consumption
    Mobile phones typically come with data caps, so the cache has to be frugal with network bandwidth.
  • Concurrency and isolation
    The implementation has to allow concurrent access by multiple applications, as well as concurrent access from a single implementation. Besides needing to be thread-safe, this means that a request for a thumbnail that is slow (such as downloading an image over the network) must not delay other requests.
  • Fault tolerance
    Mobile devices lose network access without warning, and users can add corrupt media files to their device. The implementation must be resilient to partial failures, such as incomplete network replies, dropped connections, and bad image data. Moreover, the recovery strategy for such failures must conserve battery and avoid repeated futile attempts to create thumbnails from media that cannot be retrieved or contains malformed data.
  • Security
    The implementation must ensure that applications cannot see (or, worse, overwrite) each other’s thumbnails or coerce the thumbnailer into delivering images from files that an application is not allowed to read.
  • Asynchronous API
    The customers of the thumbnailer are applications that are written in QML or Qt, which cannot block in the UI thread. The thumbnailer therefore must provide a non-blocking API. Moreover, the application developer should be able to get the best possible performance without having to use threads. Instead, concurrency must be internal to the implementation (which is able to put threads to use intelligently where they make sense), instead of the application throwing threads at the problem in the hope that it might make things faster when, in fact, it might just add overhead.
  • Monitoring
    The effectiveness of a cache cannot be assessed without statistics to show hit and miss rates, evictions, and other basic performance data, so it must provide a way to extract this information.
  • Error reporting
    When something goes wrong with a system service, typically the only way to learn about the problem is to look at log messages. In case of a failure, the implementation must leave enough footprints behind to allow someone to diagnose a failure after the fact with some chance of success.
  • Backward compatibility
    This project was a rewrite of an earlier implementation. Rather than delivering a “big bang” piece of software and potentially upsetting existing clients, we incrementally changed the implementation such that existing applications continued to work. (The only pre-existing interface was a QML interface that required no change.)

System architecture

Here is a high-level overview of the main system components.

A Fast Thumbnailer for UbuntuExternal API

To the outside world, the thumbnailer provides two APIs.

One API is a QML plugin that registers itself as an image provider for QQuickAsyncImageProvider. This allows the caller to to pass a URI that encodes a query for a local or remote thumbnail at a particular size; if the URI matches the registered provider, QML transfers control to the entry points in our plugin.

The second API is a Qt API that provides three methods:

QSharedPointer<Request> getThumbnail(QString const& filePath,
                                     QSize const& requestedSize);
QSharedPointer<Request> getAlbumArt(QString const& artist,
                                    QString const& album,
                                    QSize const& requestedSize);
QSharedPointer<Request> getArtistArt(QString const& artist,
                                     QString const& album,
                                     QSize const& requestedSize);

The getThumbnail() method extracts thumbnails from local media files, whereas getAlbumArt() and getArtistArt() retrieve artwork from the remote image server. The returned Request object provides a finished signal, and methods to test for success or failure of the request and to extract a thumbnail as a QImage. The request also provides a waitForFinished() method, so the API can be used synchronously.

Thumbnails are delivered to the caller in the size they are requested, subject to a (configurable) 1920-pixel limit. As an escape hatch, requests with width and height of zero deliver artwork at its original size, even if it exceeds the 1920-pixel limit. The scaling algorithm preserves the original aspect ratio and never scales up from the original, so the returned thumbnails may be smaller than their requested size.

DBus service

The thumbnailer is implemented as a DBus service with two interfaces. The first interface provides the server-side implementation of the three methods of the external API; the second interface is an administrative interface that can deliver statistics, clear the internal disk caches, and shut down the service. A simple tool, thumbnailer-admin, allows both interfaces to be called from the command line.

To conserve resources, the service is started on demand by DBus and shuts down after 30 seconds of idle time.

Image extraction

Image extraction uses an abstract base class. This interface is independent of media location and type. The actual image extraction is performed by derived implementations that download images from the remote server, extract them from local image files, or extract them from local streaming media files. This keeps knowledge of image location and encoding out of the main caching and error handling logic, and allows us to support new media types (whether local or remote) by simply adding extra derived implementations.

Image extraction is asynchronous, with currently three implementations:

  • Image downloader
    To retrieve artwork from the remote image server, the service talks to an abstract base class with asynchronous download_album() and download_artist() methods. This allows multiple downloads to run concurrently and makes it easy to add new local or remote image providers without disturbing the code for existing ones. A class derived from that abstract base implements a REST API with QNetworkAccessManager to retrieve images from
  • Photo extractor
    The photo extractor is responsible for delivering images from local image files, such as JPEG or PNG files. It simply delegates that work to the image converter and scaler.
  • Audio and video thumbnail extractor
    To extract thumbnails from audio and video files, we use GStreamer. Due to reliability problems with some codecs that can hang or crash, we delegate the task to a separate vs-thumb executable. This shields the service from failures and also allows us to run several GStreamer pipelines concurrently without a crash of one pipeline affecting the others.

Image converter and scaler

We use a simple Image class with a synchronous interface to convert and scale different image formats to JPEG. The implementation uses Gdk-Pixbuf, which can handle many different input formats and is very efficient.

For JPEG source images, the code checks for the presence of EXIF data using libexif and, if it contains a thumbnail that is at least as large as the requested size, scales the thumbnail from the EXIF data. (For images taken with the camera on a Nexus 4, the original image size is 3264×1836, with an embedded EXIF thumbnail of 512×288. Scaling from the EXIF thumbnail is around one hundred times faster than scaling from the full-size image.)

Disk cache

The thumbnailer service optimizes performance and conserves bandwidth and battery by adopting a layered caching strategy.

Two-level caching with failure lookup

Internally, the service uses three separate on-disk caches:

  • Full-size cache
    This cache stores images that are expensive to retrieve (images that are remote or are embedded in audio and video files) at original resolution (scaled down to a 1920-pixel bounding box if the original image is larger). The default size of this cache is 50 MB, which is sufficient to hold around 400 images at 1920×1080 resolution. Images are stored in JPEG format (at a 90% quality setting).
  • Thumbnail cache
    This cache stores thumbnails at the size that was requested by the caller, such as 512×288. The default size of this cache is 100 MB, which is sufficient to store around 11,000 thumbnails at 512×288, or around 25,000 thumbnails at 256×144.
  • Failure cache
    The failure cache stores the keys for images that could not be extracted because of a failure. For remote images, this means that the server returned an authoritative answer “no such image exists”, or that we encountered an unexpected (non-authoritative) failure, such as the server not responding or a DNS lookup timing out. For local images, it means either that the image data could not be processed because it is damaged, or that an audio file does not contain embedded artwork.

The full-size cache exists because it is likely that an application will request thumbnails at different sizes for the same image. For example, when scrolling through a list of songs that shows a small thumbnail of the album cover beside each song, the user is likely to select one of the songs to play, at which point the media player will display the same cover in a larger size. By keeping full-size images in a separate (smallish) cache, we avoid performing an expensive extraction or download a second time. Instead, we create additional thumbnails by scaling them from the full-size cache (which uses an LRU eviction policy).

The thumbnail cache stores thumbnails that were previously retrieved, also using LRU eviction. Thumbnails are stored as JPEG at the default quality setting of 75%, at the actual size that was requested by the caller. Storing JPEG images (rather than, say, PNG) saves space and increases cache effectiveness. (The minimal quality loss from compression is irrelevant for thumbnails). Because we store thumbnails at the size they are actually needed, we may have several thumbnails for the same image in the cache (each thumbnail at a different size). But applications typically ask for thumbnails in only a small number of sizes, and ask for different sizes for the same image only rarely. So, the slight increase in disk space is minor and amply repaid by applications not having to scale thumbnails after they receive them from the cache, which saves battery and achieves better performance overall.

Finally, the failure cache is used to stop futile attempts to repeatedly extract a thumbnail when we know that the attempt will fail. It uses LRU eviction with an expiry time for each entry.

Cache lookup algorithm

When asked for a thumbnail at a particular size, the lookup and thumbnail generation proceed as follows:

  1. Check if a thumbnail exists in the requested size in the thumbnail cache. If so, return it.
  2. Check if a full-size image for the thumbnail exists in the full-size cache. If so, scale the new thumbnail from the full-size image, add the thumbnail to the thumbnail cache, and return it.
  3. Check if there is an entry for the thumbnail in the failure cache. If so, return an error.
  4. Attempt to download or extract the original image for the thumbnail. If the attempt fails, add an entry to the failure cache and return an error.
  5. If the original image was delivered by the remote server or was extracted locally from streaming media, add it to the full-size cache.
  6. Scale the thumbnail to the desired size, add it to the thumbnail cache, and return it.

Note that these steps represent only the logical flow of control for a particular thumbnail. The implementation executes these steps concurrently for different thumbnails.

Designing for performance

Apart from fast on-disk caches (see below), the thumbnailer must make efficient use of I/O bandwidth and threads. This not only means making things fast, but also to not unnecessarily waste resources such as threads, memory, network connections, or file descriptors. Provided that enough requests are made to keep the service busy, we do not want it to ever wait for a download or image extraction to complete while there is something else that could be done in the mean time, and we want it to keep all CPU cores busy. In addition, requests that are slow (because they require a download or a CPU-intensive image extraction) must not block requests that are queued up behind them if those requests would result in cache hits that could be returned immediately.

To achieve a high degree of concurrency without blocking on long-running operations while holding precious resources, the thumbnailer uses a three-phase lookup algorithm:

  1. In phase 1, we look at the caches to determine if we have a hit or an authoritative miss. Phase 1 is very fast. (It takes around a millisecond to return a thumbnail from the cache on a Nexus 4.) However, cache lookup can briefly stall on disk I/O or require a lot of CPU to extract and scale an image. To get good performance, phase 1 requests are passed to a thread pool with as many threads as there are CPU cores. This allows the maximum number of lookups to proceed concurrently.
  2. Phase 2 is initiated if phase 1 determines that a thumbnail requires download or extraction, either of which can take on the order of seconds. (In case of extraction from local media, the task is CPU intensive; in case of download, most of the time is spent waiting for the reply from the server.) This phase is scheduled asynchronously from an event loop. This minimizes task switching and allows large numbers of requests to be queued while only using a few bytes for each request that is waiting in the queue.
  3. Phase 3 is really a repeat of phase 1: if phase 2 produces a thumbnail, it adds it to the cache; if phase 2 does not produce a thumbnail, it creates an entry in the failure cache. By simply repeating phase 1, the lookup then results in either a thumbnail or an error.

If phase 2 determines that a download or extraction is required, that work is performed concurrently: the service schedules several downloads and extractions in parallel. By default, it will run up to two concurrent downloads, and as many concurrent GStreamer pipelines as there are CPUs. This ensures that we use all of the available CPU cores. Moreover, download and extraction run concurrently with lookups for phase 1 and 3. This means that, even if a cache lookup briefly stalls on I/O, there is a good chance that another thread can make use of the CPU.

Because slow operations do not block lookup, this also ensures that a slow request does not stall requests for thumbnails that are already in the cache. In other words, it does not matter how many slow requests are in progress: requests that can be completed quickly are indeed completed quickly, regardless of what is going on elsewhere.

Overall, this strategy works very well. For example, with sufficient workload, the service achieves around 750% CPU utilization on an 8-core desktop machine, while still delivering cache hits almost instantaneously. (On a Nexus 4, cache hits take a little over 1 ms while concurrent extractions or downloads are in progress.)

A re-usable persistent cache for C++

The three internal caches are implemented by a small and flexible C++ API. This API is available as a separate reusable PersistentStringCache component (see persistent-cache-cpp) that provides a persistent store of arbitrary key–value pairs. Keys and values can be binary, and entries can be large. (Megabyte-sized values do not present a problem.)

The implementation uses leveldb, which provides a very fast NoSQL database that scales to multi-gigabyte sizes and provides integrity guarantees. In particular, if the calling process crashes, all inserts that completed at the API level will be intact after a restart. (In case of a power failure or kernel crash, a few buffered inserts can be lost, but the integrity of the database is still guaranteed.)

To use a cache, the caller instantiates it with a path name, a maximum size, and an eviction policy. The eviction policy can be set to either strict LRU (least-recently-used) or LRU with an expiry time. Once a cache reaches its maximum size, expired entries (if any) are evicted first and, if that does not free enough space for a new entry, entries are discarded in least-recently-used order until enough room is available to insert a new record. (In all other respects, expired entries behave like entries that were never added.)

A simple get/put API allows records to be retrieved and added, for example:

auto c = core::PersistentStringCache::open(
    “my_cache”, 100 * 1024 * 1024, core::CacheDiscardPolicy::lru_only);
// Look for an entry and add it if there is a cache miss.
string key = "Bjarne";
auto value = c->get(key);
if (value) {
    cout << key << ″: ″ << *value << endl;
} else {
    value = "C++ inventor";  // Provide a value for the key. 
    c->put(key, *value);     // Insert it.

Running this program prints nothing on the first run, and “Bjarne: C++ inventor” on all subsequent runs.

The API also allows application-specific metadata to be added to records, provides detailed statistics, supports dynamic resizing of caches, and offers a simple adapter template that makes it easy to store complex user-defined types without the need to clutter the code with explicit serialization and deserialization calls. (In a pinch, if iteration is not needed, the cache can be used as a persistent map by setting an impossibly large cache size, in which case no records are ever evicted.)


Our benchmarks indicate good performance. (Figures are for an Intel Ivy Bridge i7-3770k 3.5 GHz machine with a 256 GB SSD.) Our test uses 60-byte string keys. Values are binary blobs filled with random data (so they are not compressible), 20 kB in size with a standard deviation of 7,000, so the majority of values are 13–27 kB in size. The cache size is 100 MB, so it contains around 5,000 records.

Filling the cache with 100 MB of records takes around 2.8 seconds. Thereafter, the benchmark does a random lookup with an 80% hit probability. In case of a cache miss, it inserts a new random record, evicting old records in LRU order to make room for the new one. For 100,000 iterations, the cache returns around 4,800 “thumbnails” per second, with an aggregate read/write throughput of around 93 MB/sec. At 90% hit rate, we see twice the performance at around 7,100 records/sec. (Writes are expensive once the cache is full due to the need to evict entries, which requires updating the main cache table as well as an index.)

Repeating the test with a 1 GB cache produces identical timings so (within limits) performance remains constant for large databases.

Overall, performance is restricted largely by the bandwidth to disk. With a 7,200 rpm disk, we measured around one third of the performance with an SSD.

Recovering from errors

The overall design of the thumbnailer delivers good performance when things work. However, our implementation has to deal with the unexpected, such as network requests that do not return responses, GStreamer pipelines that crash, request overload, and so on. What follows is a partial list of steps we took to ensure that things behave sensibly, particularly on a battery-powered device.

Retry strategy

The failure cache provides an effective way to stop the service from endlessly trying to create thumbnails that, in an earlier attempt, returned an error.

For remote images, we know that, if the server has (authoritatively) told us that it has no artwork for a particular artist or album, it is unlikely that artwork will appear any time soon. However, the server may be updated with more artwork periodically. To deal with this, we add an expiry time of one week to the entries in the failure cache. That way, we do not try to retrieve the same image again until at least one week has passed (and only if we receive a request for a thumbnail for that image again later).

As opposed to authoritative answers from the image server (“I do not have artwork for this artist.”), we can also encounter transient failures. For example, the server may currently be down, or there may be some other network-related issue. In this case, we remember the time of the failure and do not try to contact the remote server again for two hours. This conserves bandwidth and battery power.

The device may also disconnected from the network, in which case any attempt to retrieve a remote image is doomed. Our implementation returns failure immediately on a cache miss for a remote image if no network is present or the device is in flight mode. (We do not add an entry to the failure cache in this case).

For local files, we know that, if an attempt to get a thumbnail for a particular file has failed, future attempts will fail as well. This means that the only way for the problem to get fixed is by modifying or replacing the actual media file. To deal with this, we add the inode number, modification time, and inode modification time to the key for local images. If a user replaces, say, a music file with a new one that contains artwork, we automatically pick up the new version of the file because its key has changed; the old version will eventually fall out of the cache.

Download and extraction failures

We monitor downloads and extractions for timely completion. (Timeouts for downloads and extractions can be configured separately.) If the server does not respond within 10 seconds, we abandon the attempt and treat it it as a transient network error. Similarly, the vs-thumb processes that extract images from audio and video files can hang. We monitor these processes and kill them if they do not produce a result within 10 seconds.

Database corruption

Assuming an error-free implementation of leveldb, database corruption is impossible. However, in practice, an errant command could scribble over the database files. If leveldb detects that the database is corrupted, the recovery strategy is simple: we delete the on-disk cache and start again from scratch. Because the cache contents are ephemeral anyway, this is fine (other than slower operation until the working set of thumbnails makes it into the cache again).

Dealing with backlog

The asynchronous API provided by the service allows an application to submit an unlimited number of requests. Lots of requests happen if, for example, the user has inserted a flash card with thousands of photos into the device and then requests a gallery view for the collection. If the service’s client-side API blindly forwards requests via DBus, this causes a problem because DBus terminates the connection once there are more than around 400 outstanding requests.

To deal with this, we limit the number of outstanding requests to 200 and send another request via DBus only when an earlier request completes. Additional requests are queued in memory. Because this happens on the client side, the number of outstanding requests is limited only by the amount of memory that is available to the client.

A related problem arises if a client submits many requests for a thumbnail for the same image. This happens when, for example, the user looks at a list of tracks: tracks that belong to the same album have the same artwork. If artwork needs to be retrieved from the remote server, naively forwarding cache misses for each thumbnail to the server would end up re-downloading the same image several times.

We deal with this by maintaining an in-memory map of all remote download requests that are currently in progress. If phase 1 reports a cache miss, before initiating a download, we add the key for the remote image to the map and remove it again once the download completes. If more requests for the same image encounter a cache miss while the download for the original request is still in progress, the key for the in-progress download is still in the map, and we hold additional requests for the same image until the download completes. We then schedule the held requests as usual and create their thumbnails from the image that was cached by the first request.


The thumbnailer runs with normal user privileges. We use AppArmor’s aa_query_label() function to verify that the calling client has read access to a file it wants a thumbnail for. This prevents one application from accessing thumbnails produced by a different application, unless both applications can read the original file. In addition, we place the entire service under an AppArmor profile to ensure that it can write only to its own cache directory.


Overall, we are very pleased with the overall design and performance of the thumbnailer. Each component has a clearly defined role with a clean interface, which made it easy for us to experiment and to refine the design as we went along. The design is extensible, so we can support additional media types or remote data sources without disturbing the existing code.

We used threads sparingly and only where we saw worthwhile concurrency opportunities. Using asynchronous interfaces for long-running operations kept resource usage to a minimum and allowed us to take advantage of I/O interleaving. In turn, this extracts the best possible performance from the hardware.

The thumbnailer now runs on Ubuntu Touch and is used by the gallery, camera, and music apps, as well as for all scopes that display media thumbnails.

This article has been originally published on Michi Henning's blog.

Read more
Daniel Holbach

Announcing UbuContest 2015

Have you read the news already? Canonical, the Ubucon Germany 2015 team, and the UbuContest 2015 team, are happy to announce the first UbuContest! Contestants from all over the world have until September 18, 2015 to build and publish their apps and scopes using the Ubuntu SDK and Ubuntu platform. The competion has already started, so register your competition entry today! You don’t have to create a new project, submit what you have and improve it over the next two months.

But we know it's not all about shiny new apps and scopes! A great platform also needs content, great design, testing, documentation, bug management, developer support, interesting blog posts, technology demonstrations and all of the other incredible things our community does every day. So we give you, our community members, the opportunity to nominate other community members for prizes!

We are proud to present five dedicated categories:

  1. Best Team Entry: A team of up to three developers may register up to two apps/scopes they are developing. The jury will assign points in categories including "Creativity", "Functionality", "Design", "Technical Level" and "Convergence". The top three entries with the most points win.

  2. Best Individual Entry: A lone developer may register up to two apps/scopes he or she is developing. The rest of the rules are identical to the "Best Team Entry" category.

  1. Outstanding Technical Contribution: Members of the general public may nominate candidates who, in their opinion, have done something "exceptional" on a technical level. The nominated candidate with the most jury votes wins.

  1. Outstanding Non-Technical Contribution: Members of the general public may nominate candidates who, in their opinion, have done something exceptional, but non-technical, to bring the Ubuntu platform forward. So, for example, you can nominate a friend who has reported and commented on all those phone-related bugs on Launchpad. Or nominate a member of your local community who did translations for Core Apps. Or nominate someone who has contributed documentation, written awesome blog articles, etc. The nominated candidate with the most jury votes wins.

  1. Convergence Hero: The "Best Team Entry" or "Best Individual Entry" contribution with the highest number of "Convergence" points wins. The winner in this category will probably surprise us in ways we have yet to imagine.

Our community judging panel members Laura Cowen, Carla Sella, Simos Xenitellis, Sujeevan Vijayakumaran and Michael Zanetti will select the winners in each category. Successful winners will be awarded items from a huge pile of prizes, including travel subsidies for the first-placed winners to attend Ubucon Germany 2015 in Berlin, four Ubuntu Phones sponsored by bq and Meizu, t-shirts, and bundles of items from the official Ubuntu Shop.

We wish all the contestants good luck!

Go to or for more information, including how to register and nominate folks. You can also follow us on Twitter @ubucontest, or contact us via e-mail at


Read more
April Wang




  • 图标更新,包括应用和提示类图标
  • Shell rotation
  • 增加了更多欧洲小语种语言类键盘,包括罗马尼亚语,苏格兰盖尔语,希腊语,挪威文,乌兰克语,斯洛伐克文,冰岛文


  • 默认聚合类新闻,照片,和今天Scope中都已经支持关键词标注


  • 退款功能 (Ubuntu商店目前允许用户在购买应用后15分钟内取消订单)
  • 新增应用评级编辑


  • 新增书签文件夹
  • 键盘便捷键功能


  • 改善了来电转发的用户界面(在系统设置 > 手机)
  • 添加了WPA企业级支持到系统设置和网络中
  • 在魅族MX4手机上实现了,通过LED闪灯提示用户手机有最新提示讯息
  • 新增在拨号和短信应用中编辑联络人信息的功能
  • 支持在拨号和短信应用中使用群发信息
  • 添加了GPS位置标注到照相机中
  • SDK最新添加了让显示屏持续开启的功能(例如,在游戏开发中,开发者可以避免屏幕自动超时黑屏的情况)
  • 另外还修复了50多个小八哥

Read more
April Wang



To celebrate the Developer Edition Ubuntu phone launch in China, Canonical organized a “celebrate Ubuntu” hackathon for phone in Beijing. It is also hosted as part of the on-going China Mobile & Ubuntu Developer Innovation Contest, all projects that were coded during the hackathon can be submitted into the contest afterwards.  This 30+ hour hackathon was packed with creativity, excitement and laughter, it was exhausting but amazingly fun.

With the help of media partners (TechCrunch CN, Tech Noda), local tech partners & communities (GitCafe, MS OpenTech,  Ubuntu Kylin, Kaiyuanshe, SegmentFault, CSDN, linuxCN, OSCN, Linuxeden, QTCN,, there are over 120 people signed up online pre-hackathon, and 70+ people turned up onsite.



Being the first ever Ubuntu phone hackathon in China, it doesn’t have any fixed topic and project requirement, as long as it will run on an ubuntu phone in the end. The entire hackathon was driven by pure innovation and creativity.

Ideas and solutions to problems that can benefit or provide entertainment for phone users is the key for this hackathon. There are 7 different awards to be given out to credit different types of ideas.

  • Avant-garde Award - for the most innovative ideas and projects

  • Geek Award - for hardcore techy geeky projects

  • Foolproof Award - for most user friendly projects

  • TalkDaTalk Award - for best project demonstration

  • Stunning Award - for best design projects

  • Entertaining Award - for most fun and entertaining projects

  • Special Content Award - for certain most needed content providing categories

And every team who stood up and provided a project demo received a final demo prize.

Final judging panels were made up by teams from Canonical and China Mobile device company. Each project are being reviewed by its creativity, usability, problem solving level, technical difficulty, design and the completion level. 30 hour straight hackathon is an intense exercise, there were 14 teams in the end proved their talent and effort through their live demo sessions. Four Meizu MX4 phone were given out for the top 4 teams, and all final teams received a Qt Core Tutorial book and numerous small gifts.



A live weibo tweets & hackathon countdown wall, that was put together by @penk , provided a great live interactive platform for onsite participants and online fans and community members.


The 30+ hour hackathon was fueled with energy, determination and of course food, water, cans of redbull & sweets! :) Here is a few clips on how the energy and creativity was flowing throughout the event.
Some of the teams were fresh learners, spent the first day learning and second day coding. However, some of them in the end were part of the final winners too!


Then of course, all work and no play makes Jack a dull boy. Various gaming sessions and polaroid fun took place naturally to keep things alive and exciting!




Now let’s take a look at some of the finalists and their amazing work after the 30 hour hackathon.

Douban FM

A great qml app with neat design and smooth user login experience, which also enables multi device sync up under your own account.  Coded by the one man(the guy on the right hand side of the picture) team @DawnDIYSoft, who is also the man behind the current youku scope in the Ubuntu store



A brand new programming language, which was re-implemented with an interpreter built with JavaScript and ported to Ubuntu phone. Their project can be found here on github.  As you have probably guessed by now, they are of course the winner of the Geek Award, which was presented by Caobin, Project Manager from the China Mobile Device Company.


Memory Dictionary
Utilizing fragmented time slots in your life, such as when you are travelling on a metro train, to memorizing new words and phrases (English language learning app). The app was already built for MacOS, iOS and Android, and is very popular on those platforms. During the hackathon, the team ported it to Ubuntu phone based on cordova.


Couple Like:

An html5 app that compares two person’s pictures to provide a conclusion on what type of couple the two will make. It’s light hearted, fun and packed with love, coded by a team of couple who were on the dance floor not long before the demo.  Also one of the project that runs smoothly on the phone by the end of the hackathon.


Dou Dizhu (poker game)

A single poker game with it's own memory management system and AI. It was implemented in qt widget, so still need some work to port it to Ubuntu phone. But through the desktop demo, it already looking addictive and entertaining.


Utu / uPhoto

It’s an app implemented with C++ for image/photo processing, still a WIP project, but exciting enough for us to know that soon we can beautifying our snapshots on our Ubuntu phone.  


uChat/(Ubuntu Chat)

A dating messaging service application dedicated for anyone who finds it difficult to make the first move or the right move when it comes to meeting someone. It involves server side and client side technology, despite their initial plan of using html5 based on webapp or cordova, the prototype in the end was built with qml by a team of university students in their second and third year.


A few more clips of the hackathon and of course a happy group shot.



Read more
April Wang

2015年7月4-5日,我们聚集北京一起经历了Ubuntu手机在中国的首场黑客松。@DawnDIY最近发布了一篇细心记录下的活动回忆录, 在这里和大家分享。 

Ubuntu Hackathon

 2015年07月08日  DawnDIY


很早就知道"黑客松"(Hackathon),也关注过一些国内的 Hackathon 活动,只是一直都没有去尝试参与过。以前是没有美工前端,所以自己变成了个野生渣前端。最近很长时间都在关注 Ubuntu Touch 的进度,得知有在北京举办 Hackathon 活动,也就迅数报名了。好吧,我的第一次 Hackathon 献给 Ubuntu 了。


当然这次 Ubuntu Hackathon 是为 Ubuntu Touch 开发应用。Ubuntu Touch 上的开发基本分三类。

一是 Scope,Scope 目前在中文也没有很合适的翻译,官方也没有给出中文名称我们都以 Scope 来叫它就好了。开发 Scope,官方给出了一个框架并提供了各类API,可以快速的做出一个不错的 Scope,具体可以参见这里 (友情提示: 网页底部有切换简体中文的链接)

二是 QML App,这也是真正意义上的 Native App 吧。使用 QML 语言进行开发,当然可以结合Qt使用C++对其做支持。

三是 HTML5 App,HTML5 应用,当下比较流行吧。因为今年的 HTML5 标准正式发布,和之前各种宣传,HTML5技术也多用于移动设备开发,最大的好处就是 write once, run everywhere 。

四是 Webapp,这个其实就没什么了,可以把现有的网站 url 打包成一个简单的入口 webapp。其实就是一个网站的快捷方式。

对于 Qt/QML,虽然很早也知道了解过,但从来没写过东西。那Qt是用的C++,好久没碰了。其实 QML 里面可以直接写 Javascript 也不用担心太多,真是万能的 Javascript 啊。那后来发现一些比较复杂不方便在QML里面做的事情,还有一些敏感的内容不能直接暴露在 QML 里面,那么就只能用 C++ 了,写了一段时间发现真的是生疏了。后来 Google 之发现有人说可以用 Golang,瞬间欣喜起来,自己学习过 Golang 也做过一些项目,而且也在期待 Google 将其用在 Android 开发上。然后就得知了 go-qml 这个项目后,就开始深入使用 QML 结合 Golang 来做 GUI 应用。其实 go-qml 的作者也说了,这个库属于 alpha 阶段,而且确实从 v0 到 v1 的时候有些写法和API也确实变了,读了部分源码后发现源码里面一些 Comment 也标记了一些 TODO 和 疑问。所以就当实验性开发吧,不过现在用过来并没有发现很多问题,唯一比较麻烦的就是 Golang Type 到 QML Type 的转换上面有限制。

对于 Scope,第一感觉就像是 Android 里面的 Widget。后来慢慢啃文档也就慢慢理解了,Scope 主要的作用也就是作为一种对信息的聚合、展示、搜索等功能。Scope 可以聚合子 Scope 的信息,也可以对子 Scope 进行搜索。不过目前的 Scope 在功能性方面还是不是特别多,并且 Scope 里的 previewwidget 的功能目前也比较弱,使得很多想象力被限制了。所以 Joey Chan 和 校长 也都和我说 Scope 也就那样了,做 App 吧。So... Learn by doing...


7月4~5日,自从 Rex 那里知道有 Hackathon 以后这个日子已经期待很久了,终于来了~由于最近比较忙,4日凌晨1点才睡觉的,也没怎么准备早上7点40起来,随便把电脑、各种线往书包里面塞,另外还带了我做了特殊处理出国网络比较快的 Raspberry Pi2~

9点多到了 Microsoft 大厦,后来回想起来倒是怪怪的,抱着装着 Ubuntu 的 MacbookPro 去了 Microsoft 大厦参加 Ubuntu Hackathon~呵呵~

一进会场~哇,有美女接待,一紧张忘记拍照了,后悔啊~~~然后默默地找自己的名字,然后弱弱地说我没有团队一个人来的 :) 。找到一个比较靠前的 8 号桌坐下来了。整理好东西,坐下等待安排了。瞬间发现0点钟方向坐着刘老师、11点钟方向坐着 Rex 和 Penk 。刘老师之前见过,Rex第一次见面,不过看见他一直拿着笔记本蹲跪在地上忙,就没过去打扰了。后来上前和刘老师打了声招呼然后聊了会儿之前我和他说用 Golang 的事情。

Rex 和 Penk 上台做简要介绍,Rex 介绍说已经有国内开发者在开发 Ubuntu Touch 平台的 App 了,出现了 Joey Chan 的 AesyWeibo,然后PPT上突然出现我之前做的 Youku Scope,嘿嘿~欣喜一下。然后 Rex 说 Youku Scope 是在场的一位开发者做的,问他在哪。我开始懵了一下然后站起来,只见 Penk 在那喊了一声,“原来就是你啊”。然后继续,今天的主题就是没有主题。Let's start...

现场很多人是没有 Nexus4 或者其他可以运行 Ubuntu Touch 的手机,于是官方向每一桌提供开发机。哇,是刚才签到的妹纸来发~~只见快到我这桌了,好紧张,然后就看到她默默地走过去了,略过我这桌了,为什么?我很费解,此时 Penk 突然在我面前坐下了。好吧,妹纸走了,Penk大神来了~哈哈,都不用相互介绍我们就聊起来了,问我要做什么,我说还没想好,可能做个音乐相关的吧。Penk说要不要把Youku Scope 完善一下,也行...然后 coding...

为 Scope 添加 Account 功能之前还没看,这下顺便开一下,还请教了几次刘老师,遇到了挺多困难的。后来休息一下,想想,还是尝试做新的东西吧,这样在限时里完成才有挑战,那好,开启 QML 模式~ 之前就想在 Ubuntu Touch 做类似豆瓣FM的app,那好就定这个了~

哈哈,晚饭居然可以自助选择盖饭和麻辣烫~ 吃饱喝足继续 Hack~ 不过每次红牛都被抢光了,都是结束的时候 Rex 分了我一灌,感谢~


我算是坚持的比较晚的吧~4日晚上基本没睡,电脑里面一直循环着一些 Death Metal。邻座的一组貌似还是外地来参加的学生,他们也比较努力也都好多没睡,听他们在讨论,发现年轻真好,比我在大学的时候强多了!PS:刘老师混进了同学们中,开始还在聊技术,后来还聊到大学生活,刘老师真能聊,哈哈~~

5日凌晨的时候还遇到了一个好玩的事情~调试了一个微博的接口,用到了上传图片,由于权限的问题,我只能上传整张图片,而不能给定url。这个接口调了我好久,就是为了能有一个分享音乐的功能,后来去请教 Penk,Penk 也是一夜没有睡了佩服!向 Penk 说了一下后,他理解了我的思路也确定没问题,但怎么就不行了呢~调用微博的接口总报错不给通过,好吧,吐槽一下微博的文档好多细节没写好。见 Penk 也是一夜没睡,很累的样子,感谢听我瞎扯~ 后来自己想办法吧!快速用 Python 在本地做了个服务,直接发请求到本地,看看是不是自己的问题,瞬间条理就清晰了~哈哈~ Penk 给我当了一次小黄鸭~后来在厕所碰到 Penk,兴奋的和 Penk 说了我怎么解决的~ 回来后瞬间感觉又有能量了,直到坚持到7点后吃了 Joe 提供的早餐,我就小睡了一会儿~~~

Debug 到早上8点,基本要完成的都完成了。嘿嘿~豆瓣FM for Ubuntu Touch ! 还有一个离线播放的功能还没做完,因为目前没法精确判断 WiFi 和 移动数据 的状态,不过已经有人在 Launchpad 上提交 Bug 了。PS: 其实 Ubuntu Touch 现在就像一个小孩子,我也是慢慢看着它一点点的变化,要不是平时很忙,我恨不得仔细读读所有的源码,把一些我发现的 Bug 直接 fix 掉再提交。呵呵,我早晚会仔细研究其源码的。不过我还是贡献了挺多翻译的~


  • 尺子
  • Couple like
  • 优图
  • 斗地主
  • 日记本
  • 记忆词典
  • 路痴助手
  • uChat
  • rocket 拼图
  • LoLi team(mb)
  • 撞脸
  • 小飞机
  • 需求交互
  • 豆瓣FM for Ubuntu touch

上面的就是小伙伴们30个小时的奋战成果!值得一提的是其中有些朋友是刚开始学习开发,尺子的作者他就提到他也是学习 C++/Qt 不久,但我觉得尺子这个作品很实用的。

Couple Like 是一对搭档完成的,嘿嘿,这个创意不错,是一款通过图像人脸识别辨别其年龄以及两个人的匹配程度的应用。最强的是演示时候用的 Demo 图片。

斗地主、日记本等那些,原来大家都是qt高手啊,都在 Ubuntu 平台上实现了很好玩的应用。希望早日在 Ubuntu Touch 见到。

值得一提的是 LoLi team 他们在用 Js 在 Ubuntu Touch 上实现了 LoLi 的解析器,LoLi 是他们自己发明的一个 Lisp 的方言,纯技术层面来说,这个很牛啊~佩服佩服~而且让我感觉到年轻真好~~要哭了

uChat 一款基于 LBS 的社交应用,是一组在校的同学做的,他们做的演示和理念都不错,我以前也想过一个类似的应用~

轮到我的 豆瓣FM for Ubuntu Touch 登场了~哈哈~可能一晚上没睡,感觉自己演讲的不好吧~随便整理了一个slide, 这个 slide 也是开源的哦,大家可以folk,里面有一些有用的资料。借用 Rex 的电脑简单的把 slide 讲了一遍,还是那句话,因为我喜欢音乐,所以我做了相关的应用,这样真的很开心。然后就是演示了,点击应用播放的刚好是 自然卷 的单曲《坐在巷口的那对男女》,大家都挺熟悉的,当我把话筒对着手机的扬声器时,大家听见音乐都鼓起掌了。谢谢大家喜欢,然后介绍了一些必要的功能(后来发现其实我好多忘记演示了),然后...然后就没有然后了... No~还有 One More Thing... 大家听到还有"One more thing"的时候有惊奇起来。为了纪念这次活动,我在 豆瓣FM for Ubuntu Touch 中制作了一个彩蛋,嘿嘿,只有特殊的方式才能进去的哦~大家看到后都哈哈大笑起来。待我把它完善好后,大家自己去发现吧 :)


第一次参加 Hackathon,感觉很充实,也认识了很多朋友。最好的感受就是和一群兴趣相投的朋友做自己爱做的事情真好~最后就是回家睡个天昏地暗~


Read more
David Callé

Add a C++ backend to your QML UI

Whether you are creating a new app or porting an existing one from another ecosystem, you may need more backend power than the QML + JavaScript duo proposed in the QML app tutorial.

Let's have a peek at how to to add a C++ backend to your application, using system libraries or your own, and vastly increase its performance and potential features.

In this tutorial, you will learn how to use and invoke C++ classes from QML and integrate a 3rd party library into your project.

Read the tutorial

Read more
April Wang

Pawel Stolowski于2015年6月11日发布一篇名为“Cleaning up scopes settings”的博文,我们在这里简单翻译转发和大家分享一下。

Unity 7(在当前桌面上提供Ubuntu shell和默认UX体验)和Unity 8(支持手机且很快将支持融合桌面)在数据源可见性方面存在很大程度的差异。未来Unity 8版本将废弃过去遗产的隐私标记,会更偏向于一种更加清晰的方式,让用户自己决定将数据发送到哪里。

Unity 7中的Scope搜索并保存隐私 

在默认情况下,在Unity 7中使用常规Dash搜索时,它将首先联络Canonical的智能Scope服务器,该服务器会推荐适合搜索关键词的最好或最相关的Scope。然后,下一步是在这些Scope中筛选查询到实际结果,然后呈现出来。


Unity 8中的Scope搜索

Unity 8中的Scope体系结构截然不同:整个搜索过程不会涉及到智能Scope服务器。


如果是在使用一个聚合类Scope的情况下, 其中聚合了不同数据来源的子Scope,它的设置页面内会列出所有聚合了的子Scope。用户可以选择自行设置禁用每个单独子Scope的数据源。 

Unity 8废弃了过去遗留的隐私标记

由于在Unity 8中进行内容搜索查询时,可以清晰的看到并且可以轻松禁用Scope及其子Scope的数据源,隐私标记自然就变成了多此一举多余设置。正因如此,我们决定在我们的手机系统/ Unity 8后续简介中去掉清除这一项过去遗留下的设置。

如果你在Unity 8中有使用这一标记,其实通过取消收藏设置(在手机上点掉星号设置)或禁用聚合类Scope中对应的子Scope数据源都可以达到相同的效果。你还可以卸载独立Scope。

在Unity 8中保护隐私

在shell中,你可以看到两种Scope:普通独立/品牌类Scope和聚合类Scope。品牌类/独立Scope可以访问自己独立数据源,但不能同时访问其他或此品牌之外的数据源。因此,例如名叫“我的音乐”的Scope,将仅查询你的手机上本地的音乐文档,而名为“BBC News”的Scope也只能查询到的新闻内容。如果你不希望使用“BBC News”Scope,就不调用(通过manage dash)或收藏该Scope(类似于不调用网页应用程序)。



Pawel Stolowski工作于Unity API团队,致力于开发并实现Unity Shell搜索功能的Scope中间件及API有关的工作。他还致力于实际Scope(例如Music、Video、Apps等等)的开发以及Ubuntu Linux相关的其他项目中。大家可以通过Twitter关注Pawel - @pstolowski

Read more