Musescore and Plasma Styles
Here’s another story of chasing a bug up and down the stack. The real work was done by Arjen, David, Marco and Noah whom I dragged into the debugging-and-fixing; mostly I sat and juggled bug reports in various up- and down- and side-stream trackers.
Musescore is a sheet-music making application. It’s written in C++ with Qt. In principle it can run anywhere. Upstream seems to follow the line that it shouldn’t be packaged, and anything other than the official AppImage on some unspecified platform is unsupported – that doesn’t stop Linux distro’s and FreeBSD from doing so, and some people care to run it on a KDE Plasma desktop.
For sheet music, Musescore is amazing. You name it, it can be written. Bagpipe music? It’s got you covered, including a whole collection of bagpipe embellishments.
I kind of assumed bagpipe embellishments would be amusing barnyard noises, since I know nothing about bagpipe music. Instead, there’s a “half heavy D throw” which sounds vaguely threatening.
Recently (I think for the 3.4 release), upstream Musescore converted the palette to a QML-based pane. That’s when the bug reports started – certainly in combination with Qt 5.15.
QML bits can use bits – import
them – dynamically, and this is not
immediately clear at build / compile / package time. So on the FreeBSD
front, the Musescore package was updated with the new QML bits,
but not the dependency information that the QML uses the graphicaleffects
Qt module. So then things fall over at runtime, rather than at build /
compile / package time – and I’d never noticed, because doing a quick
test-run in a KDE Plasma environment that has the dependency installed
doesn’t show that off.
Bug report came from an i3-on-FreeBSD user who also runs Musescore, so I fixed that in packaging.
Then another bug report came in, that the palette is missing entirely. No bagpipes. No key signatures (4/4, not GPG – remember this is music). We had fairly simultaneous independent reports in FreeBSD and in KDE about Musescore not behaving as expected in a KDE Plasma environment. Fortunately the KDE report was very detailed – thank you Hamel and Antonio from the Arch community for looking closely.
Watching Musescore stderr output shows a bunch of warnings, all of which come from Qt 5.15 deprecating some things and one peculiar warning about color not being a recognized property. A brainwave from Arjen found that changing the style used for QML worked-around the problem.
Musescore with a different style inside a KDE Plasma session looks funny, though: different margins and in-textbox padding, as well as upcased button texts.
So at that point we’ve got the problem location pinpointed: in KDE’s QML styling, not in Musescore and not in Qt. I’m not exactly sure what my KDE Plasma friends did, but using KDAB’s GammaRay, David tracked down the problem to a toolbar spacer. Toolbar spacers are generally used in a horizontal toolbar, but here in a vertical panel and some assumptions were violated. As a consequence, some element was getting a height of -33 and I’m sure you can imagine that that’s the start of a bad day.
Knowing that the issue was in the QML style code reduced the search space and after an hour or so of walking through the code there was an aha moment and six minutes later Noah had a merge request in KDE’s Invent – our GitLab instance (another part of the great Open Source ecosystem we’re part of).
Arch has since backported the fix. FreeBSD has since backported the fix, too – it’s just replacing one file and otherwise not intrusive.
The takeaway of all this is threefold:
- QML applications can be quite sensitive to the environment they run in,
- What looks like an application bug can be in surprising places, and
- The whole cooperating stack of applications, desktop environment and distributions works quite well together.
I should mention that GammaRay is one of the really cool Open Source tools for use with Qt that come from the KDAB stables. You can use it on Open Source platforms and projects, but it’s also available on commercial terms if you like that.
Edit: I wrote this and completely erased David Redondo’s contribution to the bugfixing; so if you use Musescore in KDE Plasma, spend at least a quarter-note on him.