Atom is slow regaining focus on Windows and Linux with git repo

Atom has a delay of ~1 second to respond to input when re-focusing. Seems to only affect Atom when a project folder is in a git repository.

Steps to reproduce:
Open Atom
Add a directory to your project that is a git repository or a subfolder of a git repository.
Open a file or create a new document in the same Atom session.
Switch to a different application.
Click back on Atom and wait for your input to be accepted.

When you click back on Atom there is a delay of 1~1.5 seconds before your action is performed (tab switch if you clicked a tab, cursor to start blinking if you clicked in the text of a document).

I ran the profiler during the task switching and I got the following data (rename the file to .json if necessary):
TimelineRawData-20151112T091728.txt

I am able to solve the issue only by removing the git folder from my project.

I’m not versed in reading the profiling data but it looks like a call to git-repository.js is taking a lot of time up when the re-focus happens.

10 thoughts on “Atom is slow regaining focus on Windows and Linux with git repo

  1. Not just windows I think. I noted this in a cpu trace on linux 64 bit, Debian betsy. Node version v5.7.1. Atom 1.4.0

    self total function
    81975.5 ms 89.42 %% spawn
    81975.5 ms 89.42 %% internal/child_process.js:251
    81975.5 ms 89.42 %% child_process.js:343exports.spawn
    81975.5 ms 89.42 %% child_process.js:18exports.fork
    81975.5 ms 89.42 %% /usr/share/atom…src/task.js:26Task
    81975.5 ms 89.42 %% /usr/share/atom…src/task.js:13module.exports.Task.once
    76882.4 ms 83.86 %% /usr/share/atom…ository.js:365module.exports.GitRepository.refreshStatus

    Edit: Still exist on atom=1.7.1 linux 64 bit, Debian betsy, node=5.10.1.

  2. Also experiencing this on Windows 10. Every time the window regains focus I get an annoying pause before it becomes responsive. For me, the pause is about 1.6s which doesn’t sound like a lot but when you’re constantly switching back and forth during testing, it’s really noticeable. I opened the developer tools and the profiler shows that GitRepository.refreshStatus() is 100%% to blame for the pause.

  3. Confirmed:

    • macOS Sierra: 10.12.6
    • Atom: 1.18.0 x86

    I generally work on 6+ projects at a time in one Atom view, all Git repositories… and switch in and out of Atom/Terminal/Browser/etc constantly. Sitting at ~2-3sec refocus lag which is incredibly distracting and killing efficiency. I’ve disabled all un-necessary packages which didn’t seem to help at all.

    Any ETA on a resolution? This is unfortunately tetering on unusable.

  4. Fresh install Ubuntu 16.04, latest atom. Randomly freezes (as in I have to kill the process and restart atom) when alt+tab back to atom. Did not happen with Ubuntu 14.04.

    Anyone have a workaround for this? Is this a different issue?

  5. Hey everyone; I’m really sorry this went unaddressed for so long. It is fixed on master and will ship in Atom 1.22.0 (and 1.22.0-beta0 if you’re on our beta channel).

    The way we solved this was to introduce new native APIs for refreshing the git status on a background thread; that way we don’t need to spawn a child process.