Skip to content
This repository was archived by the owner on Apr 22, 2026. It is now read-only.

Keep Playing players valid when xesam:title is transiently empty#304

Open
RobRobM wants to merge 2 commits intosakithb:mainfrom
RobRobM:fix/keep-playing-player-valid
Open

Keep Playing players valid when xesam:title is transiently empty#304
RobRobM wants to merge 2 commits intosakithb:mainfrom
RobRobM:fix/keep-playing-player-valid

Conversation

@RobRobM
Copy link
Copy Markdown

@RobRobM RobRobM commented Apr 16, 2026

Summary

Chromium-based browsers (Brave, Chrome, etc.) that forward MediaSession to MPRIS sometimes publish an empty Metadata dict while PlaybackStatus stays Playing — typically during track transitions on streaming sites such as Radio Paradise. The empty window can last several seconds before real metadata reappears.

The current validatePlayer() marks a player invalid whenever xesam:title is missing. That causes the panel to drop the actually-playing browser player and switch to another (often paused) source, and it doesn't recover cleanly when the title returns.

Changes

src/helpers/shell/PlayerProxy.js

  • Relax validatePlayer(): a player is only invalid when it has no title and is not currently Playing. A Playing player with empty metadata is still a legitimate candidate.
  • Re-run validatePlayer() on PlaybackStatus changes, so a Paused-without-title player that later starts playing becomes valid again (and vice versa).

src/helpers/shell/PanelButton.js

  • Default xesam:title to "" at the two sites that pass it into ScrollingLabel / labelTextElements. Without this, GObject throws Invalid value 'undefined' for property text when an empty-metadata Playing player reaches the panel widgets, and updateWidgets aborts — which defeats the point of keeping the player valid.

Root cause / verification

Verified directly on the bus with gdbus call --session --dest org.mpris.MediaPlayer2.brave.instance_X --object-path /org/mpris/MediaPlayer2 --method org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player Metadata during a Radio Paradise track transition — the returned a{sv} is {} for up to several seconds while PlaybackStatus is Playing. This is not a stale-cache issue inside the extension; the publisher's DBus state is genuinely empty.

Test plan

  • Start Radio Paradise in Brave (GNOME 49, Wayland). Panel shows Brave as active.
  • Skip to next track. Panel keeps Brave selected through the empty-metadata gap instead of switching away.
  • journalctl --user -f | grep gnome-shell stays clean (no ScrollingLabel GObject errors, no playerProxy is null).
  • When a second player (Firefox/YouTube) starts/stops, selection logic still prefers the playing one.

Notes

  • Independent of Fix race: guard this.playerProxy against becoming null during awaits in PanelButton #303 (PanelButton race fix) — branch is based on main, no merge conflicts expected either way.
  • A follow-up PR is planned to cache last-known-good metadata per player so the panel can keep showing the previous title/artist during these empty windows instead of just a blank label. This PR only fixes the "player gets dropped" side of the bug.

RobRobM added 2 commits April 16, 2026 14:23
Browsers exposing MPRIS for web apps (e.g. Chromium + Radio Paradise)
can transiently publish an empty Metadata dict between tracks while
PlaybackStatus remains 'Playing'. validatePlayer() then marks the
player invalid, setActivePlayer() skips it, and the panel switches to
another (typically paused) player. No subsequent PropertiesChanged is
guaranteed, so the panel can stay stuck on the wrong player until the
next genuine track change fires.

Treat PlaybackStatus === Playing as sufficient for validity even
without xesam:title, and re-run validatePlayer() on PlaybackStatus
changes so Paused/Stopped players with empty metadata are still
flagged invalid as before.
PanelButton previously passed the raw xesam:title value straight to
ScrollingLabel and into the panel label list. For MPRIS players that
omit the key entirely (which now includes Playing players reaching
these code paths under the relaxed validatePlayer rule), this yields
'undefined', making ScrollingLabel throw 'Invalid value undefined for
property text' — and stopping the IsInvalid listener before
updateWidgets for other flags runs.

Match the fallback pattern already used for xesam:artist/album and
substitute an empty string when the title is missing.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant