Marco Pracucci

Electron - Slow performances in background

by Marco Pracucci Comments

Chromium recently became more aggressive on power saving when the browser window is in background or minimized. This is usually not a problem, but in some specific applications built with Electron this could lead to performance issues.

For example, we’re building Spreaker Studio for Desktop, an audio broadcasting tool for Mac and Windows, and performances should never degrade while broadcasting, either the app is in foreground or background.

To avoid such issue, you can add the Chromium switch --disable-renderer-backgrounding: it basically tells Chromium to not reduce performances (and save CPU cycles) when the window is in background.

var app = require("app");

app.commandLine.appendSwitch("disable-renderer-backgrounding");
app.on("ready", function () {
    // ...
});

About page-visibility BrowserWindow option

When you spawn a new BrowserWindow() you can specify a set of options. Electron supports many options, including { "web-preferences": { "page-visibility": true }} that forces the page to be always in the visible state, instead of reflecting current window’s visibility.

Unfortunately, it doesn’t fix our performances issue, so in case it doesn’t help you too please give a try to --disable-renderer-backgrounding switch.


You may also be interested in ...


Upcoming conferences

I will join the following conferences. Reach me out on Twitter if you wanna meet:
KubeCon Europe Barcelona 20 May 2019 until 23 May 2019
ServerlessDays Milan 21 June 2019

Comments