Skip to content

Fix album art for browser players: fetch file:// thumbnails that only exist on the host#34

Open
JustLikeFrank3 wants to merge 1 commit into
StreamController:mainfrom
JustLikeFrank3:fix/flatpak-host-art-fallback
Open

Fix album art for browser players: fetch file:// thumbnails that only exist on the host#34
JustLikeFrank3 wants to merge 1 commit into
StreamController:mainfrom
JustLikeFrank3:fix/flatpak-host-art-fallback

Conversation

@JustLikeFrank3

Copy link
Copy Markdown

Problem

Browser-based players (Chromium/Chrome, and Firefox on some setups) expose mpris:artUrl as a file:// path in the host's /tmp (e.g. file:///tmp/.com.google.Chrome.XXXXXX). That directory is not visible inside the flatpak sandbox, so thumbnail() returns a path that fails the os.path.isfile check in the actions and the album art silently never renders — while https art (Spotify etc.) works fine.

Fix

When the resolved file:// path does not exist in the sandbox, fetch the file via flatpak-spawn --host cat (the app manifest already grants org.freedesktop.Flatpak talk permission) and store it in the existing plugin cache dir (gl.DATA_PATH/com_core447_MediaPlugin/cache, which the plugin already clears on startup).

Two details worth noting:

  • The cache file is keyed by content hash, not source path: Chromium reuses/rotates the same temp filenames between tracks, so a path-keyed cache would defeat the thumbnail change detection (last_thumbnail_path) and leave stale art on track changes.
  • flatpak-spawn must run with cwd="/" — it starts the host command in the caller's working directory, and the sandbox cwd (/app/bin/StreamController) does not exist on the host, which otherwise fails with Portal call failed: Failed to change to directory "/app/bin/StreamController".

Native paths that do exist in the sandbox are returned unchanged, and any failure falls back to the original path (current behavior).

Tested

StreamController 1.5.0-beta.15 (flatpak) on Ubuntu (GNOME 50, Wayland), Stream Deck MK.2, with Chrome as the MPRIS player: Thumbnail Background (2x2 grid mode) went from permanently blank to rendering and following track changes. https-art players are unaffected.

🤖 Generated with Claude Code

Browser-based players (Chromium, Firefox) expose mpris:artUrl as a file
in the host's /tmp, which is not visible inside the flatpak sandbox, so
their album art silently never rendered. When the art path does not
exist in the sandbox, fetch it via `flatpak-spawn --host` (the app
already has org.freedesktop.Flatpak talk permission) and cache it in the
plugin cache dir keyed by content hash, so track changes still produce a
new path for the thumbnail change detection. flatpak-spawn must be run
with cwd="/" because it starts the host command in the caller's working
directory, and the sandbox cwd (/app/...) does not exist on the host.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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