From fcde3c57f1fe0257cdf9a32655896d26ea03f38f Mon Sep 17 00:00:00 2001 From: sentriz Date: Thu, 4 Dec 2025 17:47:29 +0100 Subject: [PATCH] player: don't update progress when page is not focused Fixes an issue where on Firefox, airsonic-refix uses ~50% CPU when playing a track. Even when not focused. The issue lies somewhere in the progress bar being updated form ontimeupdate Looking at a profile: RefreshDriver tick (70%) -> Update the rendering paint (55%) -> Paint (54%) Chrome seems not have the issue, maybe it's internally throttling when not focused. For Firefox, just not updating the store when the document is hidden dropped usage down to 8% from 50% for me. --- src/player/store.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/player/store.ts b/src/player/store.ts index 760983fe..73749e59 100644 --- a/src/player/store.ts +++ b/src/player/store.ts @@ -244,6 +244,7 @@ export const usePlayerStore = defineStore('player', { export function setupAudio(playerStore: ReturnType, mainStore: ReturnType, api: API) { audio.ontimeupdate = (value: number) => { + if (document.hidden) return playerStore.currentTime = value } audio.ondurationchange = (value: number) => {