Disable background throttling (#171)

* disable background throttling for consistent setInterval

* add disable throttle as config option
This commit is contained in:
Cukmekerb 2022-10-05 10:38:01 -07:00 committed by GitHub
parent 5f330a7c48
commit 9de8cea50e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 0 deletions

View File

@ -15,6 +15,7 @@ const settings = {
playBackControl: "playBackControl", playBackControl: "playBackControl",
muteArtists: "muteArtists", muteArtists: "muteArtists",
mutedArtists: "mutedArtists", mutedArtists: "mutedArtists",
disableBackgroundThrottle: "disableBackgroundThrottle",
apiSettings: { apiSettings: {
root: "apiSettings", root: "apiSettings",
port: "apiSettings.port", port: "apiSettings.port",

View File

@ -91,6 +91,11 @@ function createWindow(options = {}) {
// load the Tidal website // load the Tidal website
mainWindow.loadURL(tidalUrl); mainWindow.loadURL(tidalUrl);
if (store.get(settings.disableBackgroundThrottle)) {
// prevent setInterval lag
mainWindow.webContents.setBackgroundThrottling(false);
}
// run stuff after first load // run stuff after first load
mainWindow.webContents.once("did-finish-load", () => {}); mainWindow.webContents.once("did-finish-load", () => {});

View File

@ -10,6 +10,7 @@ let trayIcon,
port, port,
menuBar, menuBar,
mutedArtists, mutedArtists,
disableBackgroundThrottle,
singleInstance, singleInstance,
disableHardwareMediaKeys, disableHardwareMediaKeys,
gpuRasterization; gpuRasterization;
@ -38,6 +39,7 @@ function refreshSettings() {
singleInstance.checked = store.get(settings.singleInstance); singleInstance.checked = store.get(settings.singleInstance);
disableHardwareMediaKeys.checked = store.get(settings.flags.disableHardwareMediaKeys); disableHardwareMediaKeys.checked = store.get(settings.flags.disableHardwareMediaKeys);
gpuRasterization.checked = store.get(settings.flags.gpuRasterization); gpuRasterization.checked = store.get(settings.flags.gpuRasterization);
disableBackgroundThrottle.checked = store.get("disableBackgroundThrottle");
} }
/** /**
@ -117,6 +119,7 @@ window.addEventListener("DOMContentLoaded", () => {
enableDiscord = get("enableDiscord"); enableDiscord = get("enableDiscord");
muteArtists = get("muteArtists"); muteArtists = get("muteArtists");
mutedArtists = get("mutedArtists"); mutedArtists = get("mutedArtists");
disableBackgroundThrottle = get("disableBackgroundThrottle");
singleInstance = get("singleInstance"); singleInstance = get("singleInstance");
disableHardwareMediaKeys = get("disableHardwareMediaKeys"); disableHardwareMediaKeys = get("disableHardwareMediaKeys");
gpuRasterization = get("gpuRasterization"); gpuRasterization = get("gpuRasterization");
@ -135,6 +138,7 @@ window.addEventListener("DOMContentLoaded", () => {
addInputListener(minimizeOnClose, settings.minimizeOnClose); addInputListener(minimizeOnClose, settings.minimizeOnClose);
addInputListener(muteArtists, settings.muteArtists); addInputListener(muteArtists, settings.muteArtists);
addTextAreaListener(mutedArtists, settings.mutedArtists); addTextAreaListener(mutedArtists, settings.mutedArtists);
addInputListener(disableBackgroundThrottle, settings.disableBackgroundThrottle);
addInputListener(singleInstance, settings.singleInstance); addInputListener(singleInstance, settings.singleInstance);
addInputListener(disableHardwareMediaKeys, settings.flags.disableHardwareMediaKeys); addInputListener(disableHardwareMediaKeys, settings.flags.disableHardwareMediaKeys);
addInputListener(gpuRasterization, settings.flags.gpuRasterization); addInputListener(gpuRasterization, settings.flags.gpuRasterization);

View File

@ -222,6 +222,16 @@
<span class="switch__slider"></span> <span class="switch__slider"></span>
</label> </label>
</div> </div>
<div class="group__option">
<div class="group__description">
<h4>Disable Background Throttling</h4>
<p>Makes app more responsive while in the background, at the cost of performance.</p>
</div>
<label class="switch">
<input id="disableBackgroundThrottle" type="checkbox">
<span class="switch__slider"></span>
</label>
</div>
</div> </div>
</section> </section>

View File

@ -12,6 +12,7 @@ const store = new Store({
playBackControl: true, playBackControl: true,
muteArtists: false, muteArtists: false,
mutedArtists: ["TIDAL"], mutedArtists: ["TIDAL"],
disableBackgroundThrottle: true,
menuBar: true, menuBar: true,
apiSettings: { apiSettings: {
port: 47836, port: 47836,