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:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user