perf: pause background polling and animations when tab is hidden

- Background polling pauses when tab is not visible
- Timer-based animations replaced with efficient frame-based updates
- Reduced CPU usage when OpenChamber is in background
This commit is contained in:
Bohdan Triapitsyn
2026-04-06 21:05:02 +03:00
parent 2f1377ec01
commit 16a4157440
4 changed files with 159 additions and 12 deletions
@@ -405,6 +405,10 @@ export function DesktopHostSwitcherDialog({
};
void run();
const interval = window.setInterval(() => {
// Skip polling when tab is hidden to reduce background work
if (typeof document !== 'undefined' && document.visibilityState !== 'visible') {
return;
}
void run();
}, 1_500);
@@ -1255,6 +1259,10 @@ export function DesktopHostSwitcherButton({ headerIconButtonClass }: DesktopHost
void run();
const interval = window.setInterval(() => {
// Skip polling when tab is hidden to reduce background work
if (typeof document !== 'undefined' && document.visibilityState !== 'visible') {
return;
}
void run();
}, 10_000);
return () => {