Consider the following example:
setInterval(function() { console.log(new Date()); });
If I run it using electron example.js under OS X, it will open the icon in my dock bar and start printing time on the console. However, if the application is not focused, after a while it starts to throttle.
I looked around and found that this is related to the OS X energy-saving strategy. Now, what if I need it to work in the background? My application will be daemons that do things from time to time, and I cannot endlessly look at my application at my application.
I found out here what I can do
electron.powerSaveBlocker.start('prevent-app-suspension');
Which actually fixes my problem. This, however, is quite invasive, because, as I understand it, this prevents the system from sleeping at all! I donβt need this, I just need my application to do something when the computer is active and online, without making it awake forever.
Isnβt there a middle ground between my users constantly keeping the application in the foreground and making their computer sleepless forever?
throttling electron power-saving
Matteo monti
source share