Skip to content

Name cached artwork by its bytes so art that arrives before its metadata still refreshes - #21

Merged
chrisuthe merged 2 commits into
masterfrom
chrisuthe/task/name-cached-artwork-by-its-bytes-so-art-that
Sep 2, 2026
Merged

chrisuthe merged 2 commits into
masterfrom
chrisuthe/task/name-cached-artwork-by-its-bytes-so-art-that

Conversation

@chrisuthe

Copy link
Copy Markdown
Owner

Why

With a queue in place, Music Assistant can deliver the next track's picture before the next track's metadata. The cache named the file from the metadata the group held when the bytes arrived, so that picture overwrote the current track's file in place under an unchanged path. Every consumer dedupes by path: the window reloads only when the path changes, and the Plasma and GNOME applets cache cover art by URL. So the art stayed stale until a later track whose picture happened to follow its metadata. Not a platform difference: the Windows and macOS heads joined fresh with no queue and never saw the order.

What

  • MediaSessionMapper.ArtworkFileName hashes the image bytes (SHA-256, first 16 bytes, hex) instead of the track identity. A new picture is always a new path; the same picture re-sent is the same path, which is the dedupe working as intended.
  • ArtworkCache.Write drops its track-identity parameter; retention (keep the newest eight) is unchanged and now has tests.
  • SendspinPlayerService.OnArtworkReceived no longer reads the group's metadata.
  • MainViewModel.LoadArtwork keeps its path check, with the comment saying why the path is trustworthy.
  • Tests: the mapper test becomes "differs per picture, stable for one"; a service test replays metadata 1, art A, art B, metadata 2 and asserts the published path changes on B (it fails on master with both paths equal); a second covers two pictures before any metadata; ArtworkCacheTests pins retention.
  • Docs: the ARCHITECTURE MPRIS and Flatpak notes say files are named by content and why. NEXT_STEPS records the loose thread this exposed: the handler ignores the artwork frame's channel and display timestamp.

Observed live

On this box against MA Production, running this branch's Release build under the usual settings, with a Tame Impala artist queue (different covers per track):

  • MPRIS mpris:artUrl moved to a new content-hashed path on each skip: Lonerism, then Sundown Syndrome / Remember Me, then Live Versions.
  • Window screenshots after each skip show the cover changing to match.
  • Before the swap, the old build was showing the bug live: artUrl pointed at artwork-notrack.jpg while "The Moment" was loaded.

Two caveats against the acceptance criterion as written. The player was not grouped with another player; the trigger is the queue's ordering, not grouping, and the ordering was reproduced (two pictures were written for the first track, the second before its metadata). The Plasma applet was not screenshotted, since opening it needs a click; it keys its cache on the MPRIS URL, which is now new per picture.

Checks

  • make test: 348 + 172 passing
  • Release build with warnings as errors on every Linux-buildable project: clean
  • dotnet format --verify-no-changes on Core, Platform.Shared, Player, Tests: clean

…ata still refreshes

With a queue the server can deliver the next track's picture before the next
track's metadata. Named from the current metadata, that picture overwrote the
current track's file in place, and every consumer dedupes by path: the window's
reload check and the Plasma and GNOME applets' URL cache. So nothing refreshed
until a later track whose art followed its metadata.

Hash the image bytes instead. A new picture is always a new path; the same
picture re-sent is the same path, which is the dedupe working as intended.
…ationale in one place

Retention had nothing behind it; content naming adds a new interaction (a
re-sent picture moves to newest rather than taking a ninth slot), so pin both.
The why lives in ArtworkFileName's remarks now and the other sites point there.
Note the loose thread the fix exposed: the handler ignores the frame's channel
and display timestamp.
@chrisuthe
chrisuthe marked this pull request as ready for review September 2, 2026 11:25
@chrisuthe
chrisuthe merged commit e78a444 into master Sep 2, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant