Sailfish Community News, 25th August, Coffee

Subscribe to future posts here :bell:

Sailfish OS update from Jolla

Somehow, without any forethought or planning, this fortnight’s newsletter has become coffee-themed. We have news of an update to the forum software, to improve your reading while enjoying a coffee. We point you at some motivation to give someone else a coffee. And we discuss Java, the king of coffee-based languages. We’re very happy that Damien Caliste (dcaliste) is back once again to guide us through the Sailfish OS repositories, and we finish off by rounding up all the latest and greatest Sailfish OS app updates.

Whatever your beverage of choice, we hope you enjoy.

Forum upgrade

Although you may not have realised it, there’s every chance you’re reading this newsletter on an entirely new forum. Don’t worry, this doesn’t mean posts or functionality disappearing, but rather an upgrade to the Discourse 2.8 forum platform. Jolla’s forum-meister Ville Nummela (vige) explains what’s going on.

“The changes, at least those visible to users, are quite minor. We are aware that the new version is not compatible with older Sailfish browsers, so people should not file bugs unless they are using Sailfish OS 4.4.0 or later. Otherwise, for what to do in case of glitches, it’s the usual: File a bug report :slightly_smiling_face:

In terms of changes that you may see, expect some visual style improvements, better management for draft posts, and various visual tweaks to make it clearer which posts you’ve already read. In practice it should mean relatively minor changes for most users, but we hope they make your time here in the forum even more enjoyable.

Energy from the Community

Thank you and coffee

Coffee. Mmmmm. Like many parts of the world, we do like our coffee in Finland. That’s why we also know that coffee is a great motivator and energiser when it comes to producing code. So anything that helps get coffee into the mouths of the devs who need it has to be a good thing.

The big Thank You & Coffee thread aims to do just that. There are rules to follow if you want to join the thread, but Enrico (enrish) explains them succinctly in the first post, with helpful capitalisation of the important bits:

  1. Every single post must be preceded by a coffee to the dev (which means sending them a financial donation).
  2. Say thank you only for one app per post.
  3. Likes are not allowed.

So if you’ve every thought it might be good to send a small donation in the direction of the developer of your favourite app, but never quite got around to it, then hopefully this will provide the nudge you need.

Java on Sailfish OS?

Spaces or tabs? Emacs or Vi? Presidentti or Nordquist? C++ or Java? The answers to these questions give an insight into a person’s soul that might otherwise take a lifetime to uncover.

There are of course (or so I’m told) more programming languages besides just C++ and Java. Sailfish OS apps tend to be built using a mixture of C++ and QML/Javascript. But there’s also support for the likes of Python, C and Perl, and nascent support for Go and Rust. In theory, anything that compiles down to linkable native code can be used.

For a long time Java has been an exception to this: it’s not a compiled language, but it’s not an interpreted language either. It compiles down to bytecode which requires a native Java Virtual Machine (a “JVM”) to run.

Putting Android App Support to one side for the sake of simplicity, Sailfish OS doesn’t ship with a JVM, so building Java applications to run natively has been out of the question.

So, when we heard of a project to bring the Java programming language to Sailfish OS, our interest was piqued.

Sailing-to-Coffee

The initiative comes courtesy of Thilo (thigg) who describes himself as “a 30 year old software engineer from Germany”. Thilo knows a thing or two about Java, working as a consultant specialising in Java for a small company.

You may know Thilo from his involvement in various Sailfish OS projects, including helping to maintain podQast, creating the hydrogen Matrix client and being an active part of the Bug Coordination Team.

Thilo’s Sailing-to-Coffee project aims to allow Java code to be fully integrated with Sailfish OS apps, without the need to run a Java Virtual Machine in order to use the app. Quite apart from the ability to write completely new Java code to run on Sailfish OS, this also makes the massive corpus of existing Java code available as well, something that Thilo explained to us when we spoke to him recently.

Java is all around, or at least JVM languages like Kotlin and Groovy are. With this comes a huge ecosystem of libraries. In recent years Java became more performant, friendlier to develop in and less memory hungry. Since a few years Oracle has been developing GraalVM which contains the Graal Native Image. This allows you to build native executables or shared libraries with a minimal runtime packed in.

I wanted to try out the native builds and wanted to see if native Java applications provide a benefit to Sailfish OS app development. Sailing-to-Coffee tries to explore a way that allows using Java code in this way.

It’s worth pausing to think about that for a second. The Java language is more than just a compiler. It’s a framework that includes compiler, libraries and the JVM which requires tight integration with the host system. It includes capabilities that range from Big Number support to networking and more. Boiling that down to something that will run in combination with the existing Sailfish OS app development process is no mean feat. Thilo explains it like this:

JVM Languages like Java compile into Java bytecode. Bytecode is a very low level (a few different instruction types) representation of your program. So there are two paths.

Either you hand the bytecode to a virtual machine (the JVM for example), it interprets the bytecode, optimises it during runtime and executes it. This is the “traditional” way of executing a Java program. Applets worked that way (they are quite dead now) and most other classic Java applications. The classic Java Runtime Environment (JRE) contains a lot of stuff, and lots of that is loaded upfront. Thus the footprint here used to be quite high (until project Jigsaw).

Or you compile it into something else. Most famously done by Dalvik, the JVM runtime for Android. This compiles the bytecode into Dalvik bytecode, which is then executed by Dalvik. This allows quite a few optimisations on the way. This is not totally native, but quite close.

The Graal Native Image does the last bit: it compiles all the way down to native and you don’t need a runtime anymore, it is included in your binary. The “runtime” here is called SubstrateVM.

The result from all this work is that Thilo is able to compile Java or Kotlin code into a shared library which can then be linked against a C++ binary, including those that build on top of Libsailfishapp.

Sailing-the-Flood-to-Java

The first demonstration of this approach comes in the form of a game for Sailfish OS: Sailing-the-Flood-to-Java.

I was looking for inspiration and scrolled through F-Droid. Open Flood was what I was looking for. I wanted to try to reuse code from an existing Android app, but it needed a simple GUI because I had to build this myself. As it goes, there is not too much left of the original code from Open Flood :wink:

The result, flood-java, is about to be released. I got a friend to design a logo for me, now I need to fix a few bugs and wait for Jolla Store approval.

So expect the game to be available in the Jolla Store very soon, at which point you can enjoy it’s calming colours and simple rules without ever having to worry about all of the heavy tech that went into it. “What I like about flood-java”, Thilo explains “is that it does not have many rules. You can set your own goals, try to optimise your strategy or just enjoy some clicking around.”

Thilo makes the interesting point that while flood-java is just an output from his Sailing-to-Coffee journey, it’s also been an essential input to the process too.

Sailing-to-Coffee was the base of flood-java, but will also be the endpoint. With all the knowledge I gathered, I’d like to think about a library which helps building applications in the same manner. And I’d like to have more people involved into that.

Interoperability

Since all of the interaction with the Qt layer is still handled on the C++ side, apps like flood-java that are developed this way retain their fully native feel: a Sailfish Silica UI, app covers, and so on. But mixing code from different languages always introduces interoperability challenges. Primitive types may have different byte ordering or sizes for example, and more complex types just add to the, well, complexity. A necessary part of getting Sailfish-to-Coffee to work has therefore been choosing a suitable interoperability layer, so that data can be shared between the C++ and the Java code.

This is one key area where flood-java provided important insights.

Sailing-to-Coffee follows the idea of pyOtherSide, offering a single entrypoint into your Java application. You send data and a methodhandle over, you get data back. In Sailing-to-Coffee this is all done via JSON.

With flood-java as a tech demo, I tried to explore the limits of this, especially performance-wise. The field in flood-java is an array of shorts (16-bit signed integers) and I wanted to see how huge of a field works. With 250 squared that’s 62500 shorts, as a JSON array in utf8 it is at least 62500*2 bytes (number + comma) = ~122 kb. Serialising and deserialising the JSON especially in QML seemed to take time.

To try to avoid this overhead, Thilo switched from JSON as an interoperability datatype to using Flatbuffers, which pack data into a much leaner, but still language-neutral, format.

Flatbuffers allow for a more efficient binary storage layout, especially if you don’t have to unpack it, you can directly read from it (I guess that’s why those buffers are “flat”!)

You compile the schema into Java classes and C++ classes and include those in your application code. You now use those classes and Flatbuffers takes care of serialising the data for you.

Thilo isn’t certain how much of a speed increase this gives over using JSON, but is nevertheless pleased with the final performance of the app. “I was generally surprised how well it works” he says “Initialisation seems to have almost no overhead. I would expect it to perform better than most Python code we see in apps”.

He also points out that he’s working on improving performance through tweaking the GraalVM parameters, and that he’s already managed to get the memory footprint at runtime quite low. His flood-java app requires only around 18 Mb for example.

Future development

Thilo has big plans for both flood-java as an app, and Sailing-to-Coffee as a process. He hopes it might even allow Java to become a more accepted part of the app landscape on Sailfish OS.

I would hope that Java actually becomes a normal language option. But we are not there quite yet. However if people show interest we might be there sooner than expected.

Pull requests are welcome. Sailing-to-Coffee needs to become a nice and usable project. I was thinking about a public call-for-AIs for flood-java after I create an interface for an AI-Opponent. Most of it is public domain. I want to encourage other people to take the code and build with it. Help is appreciated as well. If you have questions feel free to contact me, for example here on the forum.

Java remains a controversial choice of language for Sailfish OS. But for many developers it may be just what they’re looking for. Credible studies have shown that while it’s source is verbose compared to scripting languages, and with slower execution time compared to procedural languages, it compiles down to smaller executable and has runtime performance that beats scripting languages and even approaches that of C. It also has strong typing, garbage collection and avoids some of the more flamboyant distractions of newer languages. In Thilo’s words: “Its boring. And that’s a good thing.”

Let’s hope Thilo’s amazing work will pave the way for more coffee-based apps to be developed for Sailfish OS.

Repository roundup

It was already mentioned during the last community meeting on IRC, and the various commits of the last 15 days confirm it, there will be many new API allowed in harbour with next Sailfish OS version. This is visible with changes to sdk-harbour-rpmvalidator repository, but it becomes also possible thanks to the upgrade in documentations of the various implied packages.

Another noticeable direction pointed by the recent commits, is the work on making builds reproducible. This is an important measure to check against regressions during development and deployment.

Homescreen

Contact stack

  • buteo-sync-plugin-carddav, a plugin for synchronising contacts, HenkKalkwater has proposed a pull request to fix CardDav syncing with NextCloud servers where the .well-known index redirect omits the hostname. This addresses the bug raised on the forum about the issue. The fix has been accepted and merged after some review from pvuorela.

Network stack

Browser stack

Multi-user support

SDK

Software engineering

Documentation

Tools

Apps ahoy

You can’t yet get flood-java from the Jolla Store, but rest assured it’ll be featured here when you can. In the meantime, we have another new release and three other excellent app updates for you that you won’t want to miss.

TimeLapse Tools

Having taken my first steps into stop motion animation using poetaster’s new Stopmotion app, I was excited to try out TimeLapse Tools, a new suite of tools for creating time lapse videos from Sailfish OS developer veteran Lukáš Karas (karry). While there seems to be a lot of cross over, stop motion and time lapse are not the same thing. The former involves the creator configuring a scene frame-by-frame, while the latter often involves capturing real-life movement. For the final accelerated output a stop motion video will appear to run at real-world speeds. On the other hand a time lapse video condenses time so that everything appears to run at a higher speed. This can reveal a flow that might otherwise be hard to appreciate: the swirling of clouds in the sky or the undulation of the tides.

Like Stopmtion, TimeLapse Tools combines two separate stages: capture and assembly. In the first stage you can use either one of your phone’s inbuilt cameras, or hook up one of the many supported standalone cameras. The app allows for a good level of customisation of the camera, including exposure and focus modes. You can also crucially set the capture interval to allow for different levels of speedup.

No matter whether you’re using your phone’s or a separate camera, and tripod is pretty-much essential. Hit the vibrant “record” button and leave your camera for a couple of hours (or days) to capture its subject matter.

In the second stage you can either stitch the photos into a video directly inside the app, or export them in case you want to perform something more elaborate. If you choose the former you’ll still get options to set the video resolution, frames per second and processing to reduce flickering.

I’d like to say the results from my own testing were good, but while the app didn’t let me down, my lack of artistic skills and patience did. But with the app available it’s worth persevering, as with the right subject matter and a good eye, I’m certain it can produce excellent results.

At version 0.1 this is the first release of TimeLaps Tools for the Jolla Store and its already showing real promise. Alternatively the same version is also available from OpenRepos

Zollstock

Zollstock by Samuel Kron (black_sheep_dev) is becoming somewhat of a regular feature, having appeared in three out of the last four newsletters. Given this I’m not going to dwell on the details, but for those who don’t already know, it allows you to convert your phone into a surprisingly usable distance measuring tool. The clever draggable guides allow you to measure up to two metres in length using the edge of your phone as a ruler of sorts.

It’s excellent to see Samuel continuing to push updates out so frequently. The latest update adds Russian translations to the app courtesy of dimoon91.

Version 0.2.2 of Zollstock is available from both the Jolla Store and OpenRepos.

SeaPrint

Another app that’s becoming a regular feature (two out of the last three) is SeaPrint from Anton Thomasson (attah). Like Zollstock it’s also focused on functionality, but instead providing a digital equivalent to a physical thing, SeaPrint does the opposite, allowing you to print all of your digital documents in physical form. While we must have turned the tide of the paperless office by now, there are still some things that only properly work when they on physical paper, and for those occasions SeaPrint does a superb job. As long as your printer is networked, and as long as your document format is supported (there are too many to list here, but PDF, image files, Microsoft Office, ODF and text are all there) then it makes the process super simple.

And you can even use it to print from other apps using the SeaPrint Share Plugin.

The latest release brings SeaPrint to version 1.2.1, which adds support for custom page ranges and decreases the time it takes to send documents to the printer by disabling anti-aliasing. You can get it now from the Jolla Store.

WORDLE

There was a time when you couldn’t open a Twitter feed without being bombarded by mysterious yellow and green blocks. Thankfully the craze for sharing daily WORDLE results has subsided, but the game remains a taxing yet satisfying way to pass the time. This version from prolific app creator and Jolla dev Slava Monich (slava) retains all of that satisfying gameplay, but without being restricted to just one puzzle per day.

The aim of the game is simple: guess the five letter word within six attempts. After submitting an attempt the app reveals which letters are correct and in a correct location, as well as which are correct but in an incorrect location. An extra catch prevents you reusing incorrect letters in future guesses. It sounds simple, and it is, but also surprisingly challenging.

A particularly nice feature of Slava’s implementation is that it comes with dictionaries for nine different languages, with Portuguese a new addition for this release. Version 1.0.10 also adds the option to display a timer to add that extra bit of pressure.

The latest Version of WORDLE is available from the Jolla Store, OpenRepos and also Chum.

Please feed us your news

We hope you enjoy this community news, which we’ll continue to refine over the coming months. This is your news, and frankly we can’t always keep up with all the exciting stuff happening in the Sailfish community, so please help us out by replying to this post in the forum if you’d like to see something included.

And do also join us at our community meetings on IRC, Matrix and Telegram. It’s a great place to discuss any of the content you see here, ask questions and share your ideas. The next meeting will be on the 1st September.

15 Likes

Will Discourse upgrade bring dark mode? :slight_smile:

1 Like

Minor correction regarding MPRIS: Amber.Mpris was already allowed when Sailfish OS 4.4.0 was released. For some reason that didn’t make the headlines at the time, but it’s there already. Documentation is available at Amber MPRIS - Sailfish OS.

3 Likes

Another question - what about official SFOS QML bindings for Rust? Maybe based on https://github.com/woboq/qmetaobject-rs?

Thanks for featuring me. If you want you can download Sailing to Java from this github release already

5 Likes

I’m told that the authors of qmetaobject-rs will be deprecating their library. They seem to be working on cxx-qt now.

I cannot imagine Jolla exposing official SFOS QT bindings any time soon, given that there’s no “one” Rust-Qt library.

I think some official Rust support (and occasional updates) would be great, however :wink: That said, I should continue working on my Rust 1.61 update…

7 Likes

An implementation of the Flood game is also included in the Android port of Simon Tatham’s Puzzles (available with the name “Puzzles” on F-Droid). It’s an excellent puzzles app.

1 Like

What about Ambience White on Black?

1 Like

I didn’t try on phone. Great if it works. But I don’t find anything in that direction on this Discord on “PC” platform. Any ideas?

Sorry for a dumb question, but how do I send a coffee (i.e. donation) to the dev? Is there a single platform (link, please) or every dev has different approach?

1 Like

Hi,
There are different approaches.
But often, you can find how to donate or contribute in the “about” of your favorite apps.
There is also this thread which contains links for coffees:

2 Likes

Yeah, not a dumb question at all, but a very good one. Just as @ric9k points out, different devs provide different routes, and some don’t yet provide any at all. As well as the “about” page that @ric9k has already mentioned, I’d also suggest checking the app’s OpenRepos page as it’s common for app maintainers to post links there as well.

For devs publishing on Chum, there is a metadata field for donation links:

3 Likes

Thank you for the informative post, making technicalities clear to non-techies. A lot of coffee news, I hope to see the sailing-to-coffee project take off and its author popular in the thank you thread. Oh, and thank you for endorsing the thread early on, that does make a difference.

4 Likes

I haven’t tried, but Firefox UserCSS works in principle on Sailfish Browser.

So you could try something like https://github.com/StylishThemes/Discourse-Dark
But I guess UserCSS is a topic for another thread.

[EDIT:] yes that does work, except for some elements like embedded content.

3 Likes

I was told that I’m mistaken. They’re working on something else now. This is maybe a useful table: https://github.com/KDAB/cxx-qt#comparison-to-other-rust-qt-bindings

I use this css for this forum - https://pastebin.com/UpM8vfAt. It’s some discourse dark theme from userstyles.org which I modified to work better with this forum.

1 Like

Thx! In testing. For now it looks good.

I pulished Flood to Java in openrepos, as jolla store approval is still pending.

4 Likes

It is now also published in the jolla store

5 Likes