Squirrel / Squirrel.Mac

:shipit: Cocoa framework for updating OS X apps :shipit:
MIT License
1.57k stars 128 forks source link

Squirrel-based Install Dialogue Burns CPU/Fans on Mac #247

Closed ambroselittle closed 3 years ago

ambroselittle commented 4 years ago

Please see this bug filed with VS Code for context/details. They suggested I file this with you since they are using this framework.

Let me know if you have any questions!

ambroselittle commented 4 years ago

Please note we found a workaround on the linked issue. Not sure if that's something that can be fixed here or not.

stk-ableton commented 3 years ago

This is a very annoying and long-standing problem, and it would be great to get it fixed. The workaround that @ambroselittle refers to in the comment above is not a real solution, because it involves chown-ing the application to the current user, which is not something that you want to do from a security point of view.

The problem occurs whenever the dialog "An update is ready to install." is on the screen, asking for an admin password; as long as this dialog is open, there's a very high CPU usage. I've seen this happen consistently in all apps that use Squirrel, e.g. WhatsApp, Signal, VS Code, and others. It is a problem because many times these apps start the update process in the night, so when I come to the machine in the morning, it's been running with fans on full speed for hours already.

And it's particularly problematic when you use the VS Code Insiders version, because then there's an update every day (or night).

So I tried to investigate a little where this comes from. Running Instruments seems to indicate that it comes from https://github.com/Squirrel/Squirrel.Mac/blob/master/Squirrel/SQRLZipArchiver.m#L70, which seems to be called repeatedly while the dialog is open.

I don't understand enough about Cocoa and ReactiveCocoa to say what's the best fix for this; one wild guess is that you should set standardErrorPipe.fileHandleForReading.readabilityHandler back to nil when the ditto task completes. Another wild guess is that there's something wrong with the lifetime of the SQRLZipArchiver object; it seems to be still around after unarchiveAndPrepareData returns, but maybe shouldn't, and it looks like that would also fix the issue.

stk-ableton commented 3 years ago

Just a friendly ping. Anybody?

Cc:ing @jspahrsummers who touched this code last.

jspahrsummers commented 3 years ago

Very sorry, but I haven't worked on this codebase in ~6 years. I'm not knowledgeable about it anymore.

tmoschou commented 3 years ago

Since all Electron applications that make use of Electron's Auto Updater API (e.g. (Visual Studio Code, Atom, Slack, to name a few) are affected by this transitive dependency on Squirrel.Mac, and given https://github.com/Squirrel/Squirrel.Mac/issues/247#issuecomment-757210176 and https://github.com/Squirrel/Squirrel.Mac/issues/256, I've raised the issue with Electron https://github.com/electron/electron/issues/29119.

Electron is already carrying patches for Squirrel.Mac https://github.com/electron/electron/tree/master/patches/squirrel.mac so its probably best to handle from their end.

codesimplicity commented 3 years ago

After I finally invested the time to investigate why that is still occurring regularly even on newer Macs, I stumbled upon this issue. I'm a bit confused that it does not have more attention as it at least annoys me regularly and must be burning a lot of energy for nothing.