Your submission was sent successfully! Close

You have successfully unsubscribed! Close

Thank you for signing up for our newsletter!
In these regular emails you will find the latest updates about Ubuntu and upcoming events where you can meet our team.Close

Using the ubuntu-app-platform content interface in app snaps

Guest

on 8 December 2016

Tags: Qt , Snap

This article is more than 7 years old.


This is a guest post by Olivier Tilloy, Software Engineer at Canonical. If you would like to contribute a guest post, please contact ubuntu-devices@canonical.com

Recently the ubuntu-app-platform snap has been made available in the store for application developers to build their snaps without bundling all their dependencies. The ubuntu-app-platform snap includes standard Qt libraries (version 5.6.1 as of this writing) and QML runtime, the ubuntu UI toolkit and related dependencies, and oxide (a web engine based on the chromium content API and its QML bindings).

This allows app developers to declare a dependency on this snap through the content sharing mechanism, thus reducing dramatically the size of the resulting app snaps.

I went through the exercise with the webbrowser-app snap. This proved surprisingly easy and the size of the snap (amd64 architecture) went down from 136MB to 22MB, a sizeable saving!

For those interested in the details, here are the actual changes in the snapcraft.yaml file: see here.

Essentially they consist in:

  • Using the ‘platform’ plug (content interface) and specifying its default provider (‘ubuntu-app-platform’)
  • Removing pretty much all stage packages
  • Adding an implicit dependency on the ’desktop-ubuntu-app-platform’ wiki part
  • Adding an empty ‘ubuntu-app-platform’ directory in the snap where snapd will bind-mount the content shared by the ubuntu-app-platform snap

Note that the resulting snap could be made even smaller. There is a known bug in snapcraft where it uses ldd to crawl the dependencies, ignoring the fact that those dependencies are already present in the ubuntu-app-platform snap.

Also note that if your app depends on any Qt module that isn’t bundled with ubuntu-app-platform, you will need to add it to the stage packages of your snap, and this is likely to bring in all the Qt dependencies, thus duplicating them. The easy fix for this situation is to override snapcraft’s default behaviour by specifying which files the part should install, using the “snap” section (see what was done for e.g. address-book-app at here.

Internet of Things

From home control to drones, robots and industrial systems, Ubuntu Core and Snaps provide robust security, app stores and reliable updates for all your IoT devices.

Newsletter signup

Get the latest Ubuntu news and updates in your inbox.

By submitting this form, I confirm that I have read and agree to Canonical's Privacy Policy.

Related posts

We wish you RISC-V holidays!

There are three types of computer users: the end user, the system administrator, and the involuntary system administrator. As it happens, everyone has found...

Optimise your ROS snap – Part 6

Welcome to Part 6 of our “Optimise your ROS snap” blog series. Make sure to check Part 5. This sixth and final part will  summarise every optimisation that we...

Optimise your ROS snap – Part 4

Welcome to Part 4 of our “optimise your ROS snap” blog series. Make sure to check Part 3 before. This fourth part is going to explain what dynamic library...