Skip to content

Saturday, 6 April 2024

For years KWin has offered modifier-only shortcut handling via an obscure and undocumented method of editing the kwinrc file. Well, no more: in Plasma 6.1, KDE’s shortcut choosers will accept lone modifier keys natively! This makes it much easier to, for example, re-bind what the Meta key does: now you can easily make it open Overview, KRunner, or anything else simply by assigning it directly to that something else. This work required extensive re-plumbing throughout KDE’s software stack and was undertaken by Yifan Zhu, closing multiple Bugzilla tickets in the process—some fairly old. Thanks a lot, Yifan! (Link 1, link 2, link 3, link 4, link 5, and link 6)

But that’s not all! Though bug-fixing is eternal, we’ve largely gotten over the hump for Plasma 6.0, and I’ve noticed that features and UI improvement have occupied more of people’s attention recently. So let’s start with a much-requested one…

New Features

Spectacle regains a Crop tool, this time integrated internally rather than coming from a 3rd-party annotations library. This also happens to fix a related bug (Noah Davis, Spectacle 24.05. Link 1 and link 2):

For laptops with RGB-backlit keyboards, Plasma has gained the ability to keep the backlight color in sync with the active accent color! And support for custom colors is coming too (Natalie Clarius, Plasma 6.1. Link 1 and link 2):

The new automatic crash reporter now gives you the option to let it always download debug symbols in the background to improve the crash reports it generates (Harald Sitter, Plasma 6.1. Link)

Going along with the theme of modifier-only shortcuts, you can now make an unused mouse button simulate pressing a modifier key alone (David Redondo, Plasma 6.1. Link)

Even though Snaps are supposed to auto-update, Discover has gained the ability to let you manually update them if desired (Kevin Ottens, Plasma 6.1. Link)

UI Improvements

Dolphin now shows a visible error message when you use a keyboard shortcut to trigger an action that can’t be performed in the current context, like cutting a file in a read-only folder (Jin Liu, Dolphin 24.05. Link):

In Elisa, you can now switch between list and grid views as you see fit (Jack Hill, Elisa 24.05. Link):

In Elisa, you can now search for albums on the Tracks page (Karl Hoffman, Elisa 24.05. Link)

You can now select multiple wallpapers in Plasma’s “add new wallpaper” dialog (Sahil Arora, Plasma 6.0.4. Link)

Changed Breeze-themed radio buttons and checkboxes to use the “Button” color role as most other interactive UI elements already do, which not only improves visual consistency, but also fixes a visual glitch in QtQuick-based software where these UI elements would have the wrong color some of the time (Akseli Lahtinen, Frameworks 6.1 and Plasma 6.1. Link 1, link 2, and link 3)

List headers in Kickoff now use the standard list header style seen in QtQuick-based KDE apps, which also necessitated creating a version of that component suitable for Plasma, so expect to see it showing up in more places too (me: Nate Graham, Plasma 6.1. Link 1 and link 2):

The Plasma Digital Clock widget’s holiday list picker no longer elides long text; instead it wraps the text, since there’s plenty of space to show it in the long already-scrollable list (Ivan Tkachenko, Plasma 6.1. Link)

Bug Fixes

Okular no longer asks you for a password to open encrypted PDF documents where the encryption isn’t actually applied to simply opening them (Nicolas Fella, sponsored by TU Dresden, Okular 24.02.2. Link)

Fixed a set of related crashes in Plasma that appear to have been a subtle side effect of the recent fix to make apps in Kickoff’s favorite grid disappear immediately when uninstalled (Fushan Wen, Plasma 6.0.4. Link)

Fixed another case where Plasma could crash when you plugged in a new screen (Fushan Wen, Plasma 6.0.4. Link 1 and link 2)

Fixed a rare Plasma crash that could happen when clicking on certain System Tray icons (Fushan Wen, Plasma 6.0.4. Link)

Fixed a case where Spectacle could crash after ending a screen recording when using certain GPU hardware (Fabian Vogt, Plasma 6.0.4. Link)

Fixed bug that had broken the ability to log out within 60 seconds of logging in when using Plasma’s systemd-enabled startup process (Harald Sitter, Plasma 6.0.4. Link)

Fixed an issue that caused two-finger touchpad taps on the Task Manager to not open a context menu with certain, shall we say, “less than premium” touchpad hardware (Fushan Wen, Plasma 6.0.4. Link)

Contributed code hardening for four additional crashes picked up by KDE’s automatic crash reporting system, which as you can tell is proving quite useful! (Fushan Wen again; he’s just that amazing! Plasma 6.0.4. Link 1, link 2, link 3, and link 4)

Fixed the date information in the tooltips of various clock widgets not being localized correctly (Albert Astals Cid, Plasma 6.0.4. Link 1 and link 2)

Fixed a variety of additional weird issues with mouse cursors in video games on Wayland (Xaver Hugl, Plasma 6.1. Link 1 and link 2)

Fixed some visual glitches that could happen on Wayland when you resize certain types of window that open in a maximized state (Ser Freeman, Plasma 6.1. Link)

Other bug information of note:

Performance & Technical

Spectacle is now less likely to show up in its own screenshots when used outside of Plasma and KWin on X11 (Konstantin Kharlamov, Spectacle 24.02.2. Link)

By default, Partition manager now mounts volumes (other than / and /home) with the nofail flag so they don’t block boot-up when not available for some reason (Thomas Bertels, Partition Manager 24.05. Link)

Fixed a memory leak in Plasma’s Networks widget (Fushan Wen, Plasma 6.0.4. Link)

Custom QML layouts for lock screens in Global Themes are no longer honored, as this is too security-sensitive (Marco Martin, Plasma 6.1. Link 1, link 2, link 3, and link 4)

The Dialog Parent effect (the thing that makes windows get dimmed when a child dialog window is open) now works on Wayland (Carlos Garnacho and David Redondo, Plasma 6.1 with Qt 6.8. Link)

Did a major code-quality overhaul of the Plasma Digital Clock and Calendar widgets, which fixed a bunch of fragility, warnings, and some minor glitches, with more to come soon (Ivan Tkachenko, Plasma 6.1. Link)

Automation & Systematization

Wrote a tutorial on how to publish your Android-compatible KDE app on the Google Play store (Ingo Klöcker, link)

…And Everything Else

This blog only covers the tip of the iceberg! If you’re hungry for more, check out https://planet.kde.org, where you can find more news from other KDE contributors.

How You Can Help

KDE has become important in the world, and your time and labor have helped to bring it there! But as we grow, it’s going to be equally important that this stream of labor be made sustainable, which primarily means paying for it. Right now the vast majority of KDE runs on labor that KDE e.V. didn’t pay for, and that’s a problem. We’ve taken steps to change this with paid technical contractors—but those steps are small due to limited financial resources. If you’d like to help change that, consider donating today!

Otherwise, visit https://community.kde.org/Get_Involved to discover other ways to be part of a project that really matters. Each contributor makes a huge difference in KDE; you are not a number or a cog in a machine! You don’t have to already be a programmer, either. I wasn’t when I got started. Try it, you’ll like it! We don’t bite!

Friday, 5 April 2024

Here is a set of highlighted CMake features and fixes in Qt Creator 13. Have a look at the ChangeLog for all the CMake changes.

KDE had a feature a lot of people didn’t know about. You could run a command when a notification triggered. The feature wasn’t very well documented and nobody really blogged about it.

However with the release of KDE Plasma 6, the feature was removed. I learned about it by accident, as it is tracked by Bug #481069. I really need the feature and I re-implemented it in KDE Plasma 6. I will be available in KDE Plasma 6.1 and KDE Frameworks 6.1.

KDE: Run a command
KDE: Run a command

Text-to-Speech for calendar events

I’m using the “Run a command” feature for calendar events. Normally you get a popup notification. The popup notification is small and pop up where all of them are shown. When I’m concentrated and working on some code I simply miss them. If I play a game, I miss them.

The solution for me is to use a Text to Speech (TTS) Engine. I’ve setup speech-dispatcher with piper-tts on my system. When an a reminder triggers it says: “Andreas, you have an appointment in 10 minutes: Samba Meeting”.

You can find the python script I use here.

Endless possibilities

The opportunities for doing cool stuff with this are endless. Here are some ideas what else you could do:

  • Start your meeting/conferencing application prior to the meeting
  • Change the desktop activity before a meeting
  • Lock the screen if a specific WiFi gets disconnected

If you have some nice idea or already used it in the past, leave a comment to let me know what else you can do.

KStars v3.7.0 is released on 2024.04.05 for Windows, MacOS & Linux. It's a bi-monthly bug-fix release with a couple of exciting features.

CI & CD Infrastructure


We say goodbye to KDE's binary factory as we transition to fully use Gitlab's CI/CD pipelines to build, test, and publish KStars. Over the last two months, Eric Dejouhanet worked with the KDE's Craft & System admin teams to transition KStars pipelines to the new framework. 



Short status on pipelines:
  • Merge requests run the custom build and the CI builds
  • Master runs the CI build (though there could be other things we run, such as CVE scans)
  • Craft recipes are run from the last commit of the master or release branch, they require "build" and "build-and-test-stable" to be run manually beforehand.
  • Publishing to Microsoft store is available after the Windows Craft is run.
This is still an ongoing process and we hope to have this process fully automated by 3.7.1 release where we will automatically publish latest releases for both stable and master branches.

Donut Buster


Rejoice Newtonian, SCT, and RC owners! With KStars new Donut Buster feature, your donut focusing woes might be something of the past. John Evans implemented this experimental feature to help protect against outliers that might affect your autofocus routine. In addition to that, the Focus Advisor is now automatically applied when creating new profiles. Based on the type of equipment you have in your optical train, the Focus Advisor would try to guess the optimal focus settings for your setup. Both features are experimental and would benefit from your feedback.

Custom Views


Akarsh Simha introduced the ability to orient the sky map to match the view through any instrument.

A view is a collection of settings: the orientation of the sky map, how the orientation changes as the sky map is panned, whether it is mirrored or not, and optionally the field-of-view to set the map to.

If no views are defined, KStars introduces a set of standard / "demo" views by default. Existing views can be edited and new views can be added using the "Edit Views..." interface. They can also be re-ordered in the interface. The ordering of the views in the "Edit Views..." dialog defines the order in which views will be cycled through using the keyboard shortcuts Shift + Page Up and Shift + Page Down. Thus, you can set up the views for easily switching between naked eye / finder scope / telescope views for easy star-hopping.


Furthermore, there is a new option in the View menu that enables mirroring the sky map so as to be able to match the view through an erecting prism used for example on a Schmidt-Cassegrain or Refracting type telescope.

The rotation feature overlay now also marks East in addition to north and zenith, so as to know easily whether the display is mirrored or not.

Blinking


Hy Murveit
added a very useful Blinking feature to the FITS Viewer tool. This adds several ways to blink; that is, compare multiple images.

In Analyze, one can now move from one session to the next (forward or backward).
Keyboard shortcuts are provided for that.

Another set of keyboard shortcuts both advance and show the next image in the same FITS Viewer.

Thus, for example, one can advance through all the captured images of the evening, showing all the captures on the FITS Viewer by repeating a keyboard shortcut.

A useful complement to this might be adding the ability to delete bad captures, but for now that will have to wait for a rainy day.


In the FITS Viewer, the Open File menu command (both in the main KStars top menu, and in the FITS Viewer menu) now allows multiple files to be selected. If they are then the files are opened in individual tabs.

Shift-selecting would select files from the first to the shift-clicked file. Clearly one wouldn't want to select 100 files resulting in 100 tabs, but this can be used to, e.g. compare 10 images.

Going along with the above, keyboard shortcuts have been added to move to the next or previous FITS Viewer tab, Also helpful to the above is a new command to zoom in/out all tabs (not just the current one).

There is a new Blink Directory menu command (in both menus, as above) which will open a single tab with a list of all the images below the directory selected (that is, both in that directory, and in directories below it). It initially displays the first image, but new commands work in that tab to switch to displaying the next (or previous) image file in the list. This could be used to blink hundreds of files.

Sky Flats


Dušan Poizl
added an option to capturing sky flats. When shooting flats at sky it often end up in never-ending loop of adjusting exposure because intensity of light change and calculation of exposure break down. Adjust the tolerance to 2000 ADU to higher for a better chance at capturing sky flats.

Scheduler Refactor


Wolfgang Reissenberger continues with his work on Separating Business Logic from UI in Scheduler. Over the years the Scheduler has grown to one of the most complex classes. With this release we refactored the Scheduler class and separated the UI from the underlying state model and its business logic. This opens the door for future development of new scheduling features and a much modular approach towards more flexible sequencing approaches.

Standalone Editor


To add any job to the scheduler, you need at minimum the following:
  1. Target
  2. Sequence File
The sequence file contains all your sequence settings (e.g. Capture 20x15 LRGB images). To create this file, you first need to add sequence job in the Capture module and then save the corresponding sequence. While this facilitates re-usability across different sessions, some users wanted to create sequence on-the-fly in the scheduler.




Hy Murveit developed the standalone sequence editor in the scheduler module where it relies on settings saved from your last astrophotography session. Now it's easier than ever to plan scheduler jobs without having Ekos or your equipment profile running!

   

When using Qt Quick Layouts, it is necessary for the user to specify the attached properties Layout.fillWidth or Layout.fillHeight to stretch a child component. This process can become cumbersome as more components require it. Inline components may serve as an alternative, but they may not be as effective when dealing with different component types. To tackle these challenges, the size policy feature has been introduced in Qt Quick Controls in version 6.7 (under tech preview), mirroring similar functionality found in widgets.

Let’s go for my web review for the week 2024-14. I will be vacationing next week, so I might skip next week post. We’ll see.


German state moving 30,000 PCs to LibreOffice

Tags: tech, foss

Well done LibreOffice! I’d love to see many more announcements like this one.

https://blog.documentfoundation.org/blog/2024/04/04/german-state-moving-30000-pcs-to-libreoffice/


oss-security - backdoor in upstream xz/liblzma leading to ssh server compromise

Tags: tech, ssh, security, supply-chain

Good analysis of the backdoor recently discovered in xz. Really a bad situation. Luckily it was probably detected before it could do any real damage. What’s especially striking is the amount of patience it required, it’s really been put in place over a long stretch of time to reduce chances of detection.

https://www.openwall.com/lists/oss-security/2024/03/29/4


A Microcosm of the interactions in Open Source projects

Tags: tech, foss, community, security

Excellent post showing unhealthy consumer/maintainer dynamics in FOSS projects. This particular example was instrumental in getting the xz backdoor in place.

https://robmensching.com/blog/posts/2024/03/30/a-microcosm-of-the-interactions-in-open-source-projects/


Bullying in Open Source Software Is a Massive Security Vulnerability

Tags: tech, foss, security, burnout

You think the xz vulnerability was a one time event? Think again, this kind of bullying with ulterior motives happen regularly to critical projects.

https://www.404media.co/xz-backdoor-bullying-in-open-source-software-is-a-massive-security-vulnerability/


OSQI

Tags: tech, foss, sustainability, quality, security

Definitely a good idea, we’d need several such institutes across the world. Would governments be willing to try this?

https://www.tbray.org/ongoing/When/202x/2024/04/01/OSQI


Keeping your data from Apple is harder than expected | Aalto University

Tags: tech, apple, privacy

Can we let the myth of Apple being a proper steward with data privacy to rest please? I don’t know why people took their claims for granted to start… with so much opacity, it’s not a claim you could trust.

https://www.aalto.fi/en/news/keeping-your-data-from-apple-is-harder-than-expected


A ‘Law Firm’ of AI Generated Lawyers Is Sending Fake Threats as an SEO Scam

Tags: tech, ai, machine-learning, gpt, scam

AI supercharged scam. I guess we’ll see more of those.

https://www.404media.co/a-law-firm-of-ai-generated-lawyers-is-sending-fake-threats-as-an-seo-scam/


AI bots hallucinate software packages and devs download them • The Register

Tags: tech, ai, machine-learning, copilot, gpt, security, supply-chain

You should be mindful of the dependencies you add. Even more so when the name of the dependency has been proposed by a coding assistant.

https://www.theregister.com/2024/03/28/ai_bots_hallucinate_software_packages/


Towards 1-bit Machine Learning Models

Tags: tech, ai, machine-learning, power, energy

Smaller models with smarter architectures and low-bit quantized models are two venues for more efficient use. I’m really curious how far they’ll go. This article focuses on low-bit quantized models and the prospects are interesting.

https://mobiusml.github.io/1bit_blog/


LLaMA Now Goes Faster on CPUs

Tags: tech, ai, machine-learning, gpt, llama, optimization, performance, cpu

Excellent work to improve Llama execution speed on CPU. It probably has all the tricks of the trade to accelerate this compute kernel.

https://justine.lol/matmul/


Zoomer Tries RSS: In Praise of Yarr - tudor’s website

Tags: tech, rss, social-media

More people turning to RSS as a substitute for social media. There’s hope.

https://tudorr.ro/blog/zoomer-tries-rss/


KDE6 release: D-Bus and Polkit Galore | SUSE Security Team Blog

Tags: tech, processes, dbus, kde, security

Interesting article, shows quite well the complexities of D-Bus and Polkit. Unsurprisingly such complexity easily leads to mistakes which can compromise security. This then hints to interesting things to keep in mind when you have to deal with D-Bus and Polkit.

https://security.opensuse.org/2024/04/02/kde6-dbus-polkit.html


NTP Pool - The Internet Timekeeper | RIPE Labs

Tags: tech, ntp, dns, time

Fascinating article which explores the behavior of the NTP Pool. If you wondered how it gives you an NTP server to query, you’ll know the answer. It also covers the consequences of its restrictive approach. This even raises security concerns. Still even though it’s not perfect this keeps being an essential service mostly run by volunteers.

https://labs.ripe.net/author/giovane_moura/ntp-pool-the-internet-timekeeper/


Fast Development In Rust, Part One

Tags: tech, rust, performance, refactoring, type-systems, memory

Nice balanced view on some of Rust characteristics. This is much less naive than some of the “Rust is great” posts out there.

https://blog.sdf.com/p/fast-development-in-rust-part-one


On Garbage Collection

Tags: tech, memory, system

This is indeed a more interesting way to perceive garbage collection. This also lead to proper questions to explore on the topic.

https://xorvoid.com/on_garbage_collection.html


Optimizing SQLite for servers

Tags: tech, databases, sqlite, server, performance, complexity

With some tuning SQLite can go a long way, even for server type workloads. There are still a few caveats but in some case this can reduce complexity and cost quite a bit.

https://kerkour.com/sqlite-for-servers


Enforcing conventions in Django projects with introspection - lukeplant.me.uk

Tags: tech, craftsmanship, developer-experience, django, python

Another example of enforcing conventions using automated checks. This time using Python and Django tricks.

https://lukeplant.me.uk/blog/posts/enforcing-conventions-in-django-projects-with-introspection/


A proposal to add signals to JavaScript.

Tags: tech, javascript, web, frontend

A proposal for data bindings as first class citizens in JavaScript? This could be a good thing indeed.

https://github.com/proposal-signals/proposal-signals


Git as debugging tool - Lucas Seiki Oshiro

Tags: tech, git, version-control

Or why a clean commit history can help quite a lot to find how and why a bug was introduced. This shows a few nice tricks around git log to speed up the process.

https://lucasoshiro.github.io/posts-en/2023-02-13-git-debug/


Improvements to static analysis in the GCC 14 compiler | Red Hat Developer

Tags: tech, c, memory, static-analyzer, compiler

Improved static analysis for C straight from GCC. This is definitely welcome.

https://developers.redhat.com/articles/2024/04/03/improvements-static-analysis-gcc-14-compiler#


On Invariance and Inconsistency

Tags: tech, programming, safety, logic, mathematics

On the importance of invariants and consistent requirements in our trade. Admittedly it’s a long demonstration but it show the point well.

https://www.hansdieterhiep.nl/blog/on-invariance-and-inconsistency/


TDD’s Missing Skill: Behavioral Composition - by Kent Beck

Tags: tech, tests, tdd, design

This is indeed too often overlooked. Producing a test list and picking the tests in the right order is definitely a crucial skill to practice TDD. It goes hand in hand with software design skills.

https://tidyfirst.substack.com/p/tdds-missing-skill-behavioral-composition


Basic Things

Tags: tech, organization, community, craftsmanship

Lots of good advices of course. It goes a long way to improve the quality of the project and the ease to on-board people. This is quite some initial work though.

https://matklad.github.io/2024/03/22/basic-things.html


Programming Apprenticeships

Tags: tech, teaching, learning, pairing

Funny experiment. This shows what you can achieve in terms of teaching and learning during pair programming setups. Shadowing someone is a powerful approach.

https://two-wrongs.com/programming-apprenticeships.html


Mentorship, coaching, sponsorship: three different — and equally important — tools for developing talent - Jacob Kaplan-Moss

Tags: management, coaching, mentoring

This is a nice way to frame the three activities. They help people progress but in different ways.

https://jacobian.org/2024/apr/1/mentorship-coaching-sponsorship/


Ping Me, Please!

Tags: tech, remote-working, asynchronous, communication

When you’re distributed, this is all about asynchronous communication. You can’t walk to a person desk (and you should probably avoid it anyway if colocated).

https://www.yegor256.com/2024/04/01/ping-me-please.html



Bye for now!

With the Qt WebEngine module, Qt makes it possible to embed a webview component inside an otherwise native application. Under the hood, Qt WebEngine uses the Chromium browser engine, currently the de facto standard engine for such use cases.

While the task of writing a brand new standard-compliant browser engine is infamous as being almost unachievable nowadays (and certainly so with Chromium coming in at 31 million lines of code), the Rust ecosystem has been brewing up a new web rendering engine called Servo. Initially created by Mozilla in 2012, Servo is still being developed today, now under the stewardship of the Linux Foundation.

With the browser inherently being exposed to the internet, it is usually the biggest attack vector on a system. Naturally this makes Servo very attractive as an alternative browser engine, given that it is written in a memory-safe language.

A Servo WebView

At KDAB we managed to embed the Servo web engine inside Qt, by using our CXX-Qt library as a bridge between Rust and C++. This means that we can now use Servo as an alternative to Chromium for webviews in Qt applications.

From a QML perspective this component is similar to the Chromium WebView, such as providing canGoBack, canGoForward, loading, title, url properties and goBack, goForward methods. The QML item itself acts in the same way with the contents being rendered to match its size.

import QtQuick
import QtQuick.Window

import com.kdab.servo

Window {
  height: 720
  width: 1280
  title: webView.title
  visible: true

  ServoWebView {
    id: webView
    anchors.fill: parent
    url: "https://servo.org/"
  }
}

The screenshot below shows a basic QML application with a toolbar containing back, forward, go buttons and an address bar. We use CXX-Qt to define Qt properties, invokables, and event handlers (e.g. touch events) in Rust and trigger events in the Servo engine. Then any update requests from Servo can trigger an update of the Qt side via the Qt event loop.

As we move towards stabilising CXX-Qt at KDAB, investigating real world use cases, such as exposing Servo to Qt, allows us to identify potential missing functionality and explore what is possible when joining the Rust and Qt ecosystems together.

Technical details

Under the hood most of the heavy lifting is done by our CXX-Qt bindings, which already bridges the obvious gap between the Rust and Qt/C++ worlds. However, some further glue is needed to connect the rendering contexts of Servo to being able to render the surfaces into the actual Qt application. Internally, Servo uses surfman, a Rust library to manage rendering surfaces. At the time of writing, surfman supports OpenGL and Metal, with support for Vulkan being planned.

We use surfman to create a new OpenGL context, that Servo then uses for rendering. To render the result into the QtQuick scene, we borrow the surface from Servo, create a new framebuffer object and blit the framebuffer into a QQuickFrameBufferObject on the Qt side.

Future possibilities

Servo development is active again after a period of less activity, therefore the API is evolving and there is work to improve the API for embedders. This could result in a simpler and documented process for integrating Servo into apps. Also as part of the Tauri and Servo collaboration, a backend for WRY could become available. All of these result in many possible changes for the bridge to Qt, as currently this demo directly constructs Servo components (similar to servoshell) but could instead use a shared library or WRY instead.

On the Qt side, there are areas that could be improved or investigated further. For example, currently we are using a framebuffer object which forces use of the OpenGL backend, but with RHI, developers might want to use other backends. A way to solve this for QML would be to change the implementation to instead use a custom Qt Scene Graph node, which can then have implementations for Vulkan, OpenGL etc and read from the Servo engine.

Alternatively Qt 6.7 has introduced a new QQuickRhiItem element, which is currently a technical preview, but can be used as a rendering API-agnostic alternative to QQuickFrameBufferObject.

If this sounds interesting to your use case or you would like to collaborate with us, the code for this tech demo is available on GitHub under KDABLabs/cxx-qt-servo-webview or contact KDAB directly. We also have a Zulip chat if you want to discuss any parts of bridging Servo or CXX-Qt with us.

Come and see us at Embedded World 2024 where we will have the Servo demo and others on display!

 

The post Embedding the Servo Web Engine in Qt appeared first on KDAB.

Recently news went around about explicit sync being merged into Wayland protocols, and in the wake of that I saw a lot of people having questions about it, and why it was such a big deal… So here’s a short-ish explanation of what it is, why it’s needed and what the benefits are over the old model.

Why is synchronization needed?

When applications “render” things, that rendering doesn’t happen immediately. Instead, they effectively record a list of commands with OpenGL or Vulkan for the GPU to execute, and that list then gets handed to the GPU to execute at its own pace.

This is needed for performance reasons: If the CPU had to wait for the GPU to execute each command one by one, both CPU and GPU would often sit around, doing nothing except waiting for the other one to finish its task. By executing commands on the GPU while the CPU does other things, like preparing new commands for the GPU, both can do a lot more work in the same time.

However, in practice, rendering commands don’t stand alone on their own. You might be running one task to render an image, and another one to process the result into something else, or to read it back to the CPU, so that it can be saved as a file on disk. If you do that without synchronization, you might be reading from the image in the middle of rendering, or even before the GPU has started to work on the buffer at all.

The “old” model: Implicit sync

Traditionally with graphics APIs like OpenGL, the necessary synchronization has been done implicitly, without the application’s involvement. This means that the kernel and/or the userspace graphics driver look at the commands the application is sending to the GPU, check which images the commands are using, which previous tasks have to be completed before it, and potentially make the application wait until the dependencies of the commands it wants to execute are resolved.

The so-called dma buffer infrastructure that the Linux graphics stack uses for exchanging images between applications - like Wayland apps and the compositor - also uses the same model. When the render commands from the compositor try to read from an app’s buffer, the kernel will delay the command’s execution until the app has completed its rendering to the buffer.

This model makes it easy for application developers to write correctly working applications, but it can also cause issues. The most relevant of them for Wayland is that the application isn’t aware of which tasks it’s synchronizing to, and it can happen that you accidentally and unknowingly synchronize to GPU commands that don’t have any relevance to your task.

This has been a problem that Wayland compositors have been affected by for a long time: When presenting application images to the screen, compositors picked the latest image that the application has provided, which could still have GPU tasks running on it, instead of an earlier image that’s actually ready for presentation. This meant that sometimes presentation was delayed by the kernel, and you’d see a frame be dropped entirely, instead of just a slightly older image. This issue has been solved for most compositors in the last two years using the kernel’s implicit-explicit sync interop mechanism1; I won’t explain the details of that here, but you can read Michel Dänzer’s blog post about it instead.

The “new” model: Explicit sync

The name already suggests exactly what it does: Instead of the driver or the kernel doing potentially unexpected things in the background, the application explicitly tells the relevant components (driver / kernel / compositor / other apps) when rendering is complete and what tasks to synchronize to in the first place, using various synchronization primitives.

On the application side, explicit sync is used in Vulkan, and the Wayland protocol specifically is used internally by OpenGL and Vulkan drivers to synchronize with the Wayland compositor.

This explicit way of synchronizing GPU commands doesn’t just help avoid accidental synchronizations, it also helps improve performance by reducing the work drivers have to do. Instead of having to figure out the dependencies of tasks from a relatively opaque list of commands, apps just tell them directly.

An important thing to mention here is that we already had a protocol for explicit sync, zwp_linux_explicit_synchronization_unstable_v1, but it shared a limitation with implicit sync: In order to get a synchronization primitive, it still required the GPU commands to be first submitted to the kernel. The new protocol in contrast allows to create and share synchronization primitives without submitting work to the GPU first, which - at least in theory - will allow applications to squeeze a little bit more performance out of your hardware in the future.

Do keep in mind though that these performance improvements are minor. While there may be some special cases where implicit sync between app and compositor was the bottleneck before, you’re unlikely to notice the individual difference between implicit and explicit sync at all.

Why the big fuzz then?

If we already have most of the compositor-side problems with implicit sync solved, and explicit sync doesn’t bring major performance improvements for everyone, why is it such big news then?

The answer is simple: The proprietary NVidia driver doesn’t support implicit sync at all, and neither commonly used compositors nor the NVidia driver support the first explicit sync protocol, which means on Wayland you get significant flickering and frame pacing issues. The driver also ships with some workarounds, but they don’t exactly fix the problem either:

  • it delays Wayland commits until rendering is completed, but it goes against how graphics APIs work on Wayland and can cause serious issues, even crash apps in extreme cases
  • it delays X11 presentation until rendering is completed, but as Xwayland copies window contents sometimes, that still often causes glitches if Xwayland is also using the NVidia GPU for those copies

There’s been a lot of discussions around the internet between people experiencing the issues constantly, and others not seeing any, and now you should know why it doesn’t seem to affect everyone: It’s not a deterministic “this doesn’t work” problem but a lack of synchronization, which means that a lot of factors - like the apps you use, the CPU and GPU you have, the driver version, the kernel, compositor and so on - decide whether or not you actually see the issue.

With the explicit sync protocol being implemented in compositors and very soon in Xwayland and the proprietary NVidia driver, all those problems will finally be a thing of the past, and the biggest remaining blocker for NVidia users to switch to Wayland will be gone.


  1. this was referred to as “explicit sync through a backdoor” in an earlier version of this post 

Thursday, 4 April 2024

Developing embedded software is notoriously difficult – how can we simplify the process? Fortunately, there are lots of techniques you can use daily to help streamline your development.

Embracing Automation

The specialized nature of embedded systems extends the ramp-up time for developers and necessitates a higher level of expertise. Automating hardware-specific tasks, such as deploying applications to boards, initializing debuggers, and resetting systems, can significantly reduce the time penalties that embedded developers face. Using automation to streamline setup for new engineers, everyday development routines, and testing workflows not only speeds up development but also ensures consistency.

Prototyping is Vital

Prototyping is an indispensable part of embedded software development. Given the high cost and complexity associated with changes to software and hardware later in a project, early detection of potential issues is invaluable. Embedded prototypes need not be elaborate; rather, they should precisely address specific aspects such as hardware selection, software performance, integration strategies, and user interface design.

Prototyping serves multiple purposes, from assessing hardware performance metrics to conducting preliminary user-interface tests. Importantly, prototypes can also help pre-empt critical issues, form the basis of future test scaffolding, avoid the need to discard early code iterations, and even lay the groundwork for initial development.

Integrate Early and Often

Integration represents a critical phase in development, one that brings together disparate pieces of the software puzzle. This includes various internal components developed by separate teams — like the middleware stack, user interface, and backend services — as well as third-party software. While the temptation might be to delay this challenging step, early and regular integration is the wiser approach. This proactive strategy facilitates the early identification and resolution of issues that are not evident in unit testing, helping to avoid last-minute crises.

Optimize, but Carefully

The famous caution against premature optimization, coined by Donald Knuth in the 1960s, remains relevant today, especially where the interplay between hardware and software leads to complex performance issues in embedded systems. The key is not to avoid optimization but rather approach it with a thorough understanding of your application’s specific performance bottlenecks. Optimizing is both a time-consuming activity and a source of potential bugs, so optimize only when you need to and when you can show it can have a substantial impact. Use tools like perf, hotspot, and various other memory profilers to accurately diagnose performance problems. Once you have a clear understanding of the issues at hand, you can formulate an effective optimization strategy and establish benchmarks to maintain performance standards.

Byte-Wise, Megabyte-Foolish: A Cautionary Tale

It’s important not to lose sight of the forest for the trees. We learned this firsthand when helping a client who optimized their application’s search functionality to an impressive degree, only to overlook a major memory drain caused by an inefficient background image file format. This oversight led to unnecessary memory consumption that eclipsed the benefits gained by optimizing their search feature’s memory use – a reminder to consider the broader implications before optimizing.

Best Practices

For those looking to delve deeper into the intricacies of embedded system design, our guides, Designing Your First Embedded Linux Device and Best Practices: Embedded Development provide insights and a wealth of detailed best practices to ensure your project begins and stays on a solid foundation.

If you want to learn more about embedded Linux, come talk to us at Embedded World 2024 (9th-11th April) in Nürnberg: KDAB at EW24.

About KDAB

If you like this article and want to read similar material, consider subscribing via our RSS feed.

Subscribe to KDAB TV for similar informative short video content.

KDAB provides market leading software consulting and development services and training in Qt, C++ and 3D/OpenGL. Contact us.

The post Streamlining Strategies for Embedded Software Development appeared first on KDAB.

If you have used a moderately complex application there are chances that you have interacted with what is called a “modal” dialog. A modal dialog is a dialog that requires you to close/address it before you can continue interacting with the main application window. This can be implemented by the application in a straightforward manner but compositor didn’t know if a dialog was modal or not.

That is until now the new xdg-dialog-v1 protocol allows applications to mark their dialogs as modal or not modal. This allows the compositor to adapt its behavior according to this hint. For example when trying to activate the main window it can activate the modal dialog instead. It also enables KWin to use the darkening effect on the parent window on Wayland.

I implemented support for the protocol into KWin and Qt which will be part of the Plasma 6.1 and Qt 6.8 releases respectively. The protocol was created from functionality in GTK and Mutter by Carlos Garnacho and I am happy seeing the overall Wayland eco-system now being able to benefit from it.