You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Opening Atom on MacOS from Desktop results in High CPU usage #22507
Expected behavior: 'What a nice normal text-editing experience this is'
Actual behavior: WOOOOOOOOSSHHHH goes the laptop fan
Additionally, atom does not respond if clicked on the following buttons: About Atom, View License
to any operation that involves opening a file.
I have not test all buttons so there may be more.
Reproduces how often:
Only if I launch atom from Desktop mode, it works perfectly fine if launched from terminal.
For my use case I rarely does this so I did not notice the issue until now, it could have been there for a while.
Since I rarely launch atom from Desktop, it does not affect me much.
Hence the current workaround is to launch atom from a shell.
As stated in the closed issue of #13084, it is likely due to the shell out process.
The reason that it does not affect Atom started from a shell is because ATOM_DISABLE_SHELLING_OUT_FOR_ENVIRONMENT=true is set in atom.sh.
Launching Atom from shell via /Applications/Atom.app/Contents/MacOS/Atom --safe will trigger the same issue, as that is the executable that will be ran if launched in Desktop mode. ( This is how MacOS Applications works. )
I found the cause for the bug, in my .zshrc file I did:
# make zsh appears to load faster.
precmd
print -Prn $PROMPT
I made zsh's interactive command prompt prints stuff on startup to make it appears to load up quicker ( inspired by powerlevel10k ), and that upsets the Atom app in which it doesn't terminate.
I tried printing to /dev/stderr instead of /dev/stdout but it did not solve the problem without removing the text printing commands in .zshrc.
I don't think that it is not acceptable to print stuff to stdout in .zshrc, since it is supposed to be sourced for interactive prompt only.
I think an App or script should be running /bin/zsh -lc command env instead of /bin/zsh -ilc command env, or perhaps allowing one to disable the shelling out behaviour as an option. ( I know about the command line variable of ATOM_DISABLE_SHELLING_OUT_FOR_ENVIRONMENT, but I am not sure I can config it for Desktop mode. )
Is that not possible to allow such options for the use case of Atom?
Interesting. Well I tested my precmd and it seems that this is keeping zsh alive:
# Took from: https://superuser.com/questions/357107/zsh-right-justify-in-ps1prompt-length() {
emulate -L zsh
local -i COLUMNS=${2:-COLUMNS}local -i x y=${#1} m #MAX_acc=1000 acc=1 if(( y ));thenwhile((${${(%):-$1%$y(l.1.0)}[-1]}));do
x=y
(( y *=2))# (( acc += 1 ))done# unset acc;# local -i acc=1;while(( y > x +1));do(( m = x + (y - x) /2))((${${(%):-$1%$m(l.x.y)}[-1]}= m ))# (( acc += 1 ))donefi
print "$x"
}
The function is used to allow one to create a multi-lined left and right aligned PROMPT.
The logic of cryptic lines like: ${${(%):-$1%$y(l.1.0)}[-1]} is to first do PROMPT expansion ( like colours, etc. ) for $1, then
see if its length is less then the integer in $y, append '1' to $1, else append '0'. [-1] extract the trailing 0 or 1.
The rest should be fairly readable.
The code is basically a binary search to determine the length of the interpolated string.
I had tried to make sure the loop terminates by setting a maximum amount of iteration, but they do nothing so I commented them out / removed them. The loop should always terminate regardless, which it does, as a matter of fact I am using it daily with no issues. For some reason the behaviour is different when the shell is spawned by child_process.
I am puzzled with this.
At the moment, bypassing this function on startup seems to have stopped the issue from happening.
Activity
ed9w2in6 commentedon May 31, 2021
I found the cause for the bug, in my
.zshrcfile I did:I made zsh's interactive command prompt prints stuff on startup to make it appears to load up quicker ( inspired by powerlevel10k ), and that upsets the Atom app in which it doesn't terminate.
I tried printing to
/dev/stderrinstead of/dev/stdoutbut it did not solve the problem without removing the text printing commands in.zshrc.I don't think that it is not acceptable to print stuff to
stdoutin.zshrc, since it is supposed to be sourced for interactive prompt only.I think an App or script should be running
/bin/zsh -lc command envinstead of/bin/zsh -ilc command env, or perhaps allowing one to disable the shelling out behaviour as an option. ( I know about the command line variable of ATOM_DISABLE_SHELLING_OUT_FOR_ENVIRONMENT, but I am not sure I can config it for Desktop mode. )Is that not possible to allow such options for the use case of Atom?
ed9w2in6 commentedon Jun 5, 2021
I wrote this so I will just quote it.
from: desktop/desktop#12320 (comment)
ThatXliner commentedon Jun 5, 2021
Doesn't seem Atom-specific...
sami-eljabali commentedon Dec 19, 2021
I've been experiencing the same. It has been hogging CPU with the app shut:
Mac: 11.6
Atom: 1.58.0