From f1237e1962a195a57c34344299a30e89b521c5f6 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 20 Jul 2026 08:33:00 -0700 Subject: [PATCH] Drive media play-order off MPRIS signals instead of polling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The media service ran a 500ms repeat timer calling syncPlayingOrder() for the whole session — two CPU wakeups a second even with nothing playing. syncPlayingOrder only depends on the set of MPRIS players and each player's isPlaying state, both of which the Mpris service already signals. Replace the timer with onPlayersChanged (players appearing/disappearing) plus an Instantiator that connects isPlayingChanged for each live player, and a Component.onCompleted for the initial sync. Verified with a test MPRIS player: play/pause and player add/remove all update the active player with no periodic timer. Co-Authored-By: Claude Fable 5 --- shell/plugins/services/media/Service.qml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/shell/plugins/services/media/Service.qml b/shell/plugins/services/media/Service.qml index e22bf236..1cfeb9c9 100644 --- a/shell/plugins/services/media/Service.qml +++ b/shell/plugins/services/media/Service.qml @@ -430,12 +430,20 @@ Item { return handled } - Timer { - interval: 500 - running: true - repeat: true - triggeredOnStart: true - onTriggered: root.syncPlayingOrder() + // Recompute play-order reactively instead of polling every 500ms. + // syncPlayingOrder only depends on the set of players and each player's + // isPlaying state: onPlayersChanged covers players appearing/disappearing, + // and the Instantiator wires isPlayingChanged for each live player. + Component.onCompleted: root.syncPlayingOrder() + onPlayersChanged: root.syncPlayingOrder() + + Instantiator { + model: root.players + delegate: Connections { + required property var modelData + target: modelData + function onIsPlayingChanged() { root.syncPlayingOrder() } + } } Timer {