Disable background throttling

This commit is contained in:
Fedor Indutny 2025-08-15 15:26:49 -07:00 committed by GitHub
commit 27fd03f5f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 17 deletions

View file

@ -11,6 +11,10 @@ export class PreventDisplaySleepService {
constructor(private powerSaveBlocker: PowerSaveBlocker) {} constructor(private powerSaveBlocker: PowerSaveBlocker) {}
isEnabled(): boolean {
return this.blockerId !== undefined;
}
setEnabled(isEnabled: boolean): void { setEnabled(isEnabled: boolean): void {
log.info( log.info(
`Prevent display sleep service: ${ `Prevent display sleep service: ${

View file

@ -715,7 +715,6 @@ async function createWindow() {
: '../ts/windows/main/preload.js' : '../ts/windows/main/preload.js'
), ),
spellcheck, spellcheck,
backgroundThrottling: true,
}, },
icon: windowIcon, icon: windowIcon,
...pick(windowConfig, ['autoHideMenuBar', 'x', 'y']), ...pick(windowConfig, ['autoHideMenuBar', 'x', 'y']),
@ -1109,21 +1108,6 @@ ipc.on('title-bar-double-click', () => {
ipc.on('set-is-call-active', (_event, isCallActive) => { ipc.on('set-is-call-active', (_event, isCallActive) => {
preventDisplaySleepService.setEnabled(isCallActive); preventDisplaySleepService.setEnabled(isCallActive);
if (!mainWindow) {
return;
}
let backgroundThrottling: boolean;
if (isCallActive) {
log.info('Background throttling disabled because a call is active');
backgroundThrottling = false;
} else {
log.info('Background throttling enabled because no call is active');
backgroundThrottling = true;
}
mainWindow.webContents.setBackgroundThrottling(backgroundThrottling);
}); });
ipc.on('convert-image', async (event, uuid, data) => { ipc.on('convert-image', async (event, uuid, data) => {
@ -1168,7 +1152,7 @@ async function readyForUpdates() {
return ( return (
systemTrayService?.isVisible() === true && systemTrayService?.isVisible() === true &&
mainWindow?.isVisible() !== true && mainWindow?.isVisible() !== true &&
mainWindow?.webContents?.getBackgroundThrottling() !== false !preventDisplaySleepService.isEnabled()
); );
}, },
getMainWindow, getMainWindow,