git4idea lsRemote command causes UI to freeze.

Answered

I developed a basic plugin to open a file under git version control in its remote repository using the default browser. Just recently a few users of my plugin have reported the UI freezing (see issue #20). I have been able to reproduce the issue after updating my IDE and creating a new project. The UI completely freezes and the only option is to kill the IntelliJ IDE.

After some digging in the logs I tracked the issue down to the use of the lsRemote command in git4idea here which is used to determine if the current branch exists on the remote before opening it in the browser (falling back to the master branch if it does not). After further investigation I found that the issue is only present when the 'built-in' SSH executable is used which is specified in Preferences → Version Control → Git. Switching the executable to 'Native' works without issue.

0
5 comments

How do you call this command? If you call it from the EDT, it is quite natural that the UI is frozen for the time of the operation.

0

The problem is the operation never completes using the built-in SSH executable. Switching to the native SSH executable returns either a successful or failed result. I call the command here https://github.com/ben-gibson/jetbrains-open-in-git-host/blob/master/src/uk/co/ben_gibson/repositorymapper/Repository/Repository.java#L100. Thanks

0

Any idea what might be causing the built in ssh to never complete the process Kirill?

0

First of all, no matter how does the underlying command behave, you must not call git in the EDT. If you want the call to be synchronous, you can use Task.Modal (or simply one of ProgressManager "sync" methods). In general though it is better to make the call in the background, using Task.Backgroundable. Otherwise you freeze the UI for the user. 

Secondly, this command hangs probably exactly because you call it in the EDT. ls-remote is a remote command, which may require user interaction to enter login, password, passphrase, etc. But the EDT is occupied by waiting for Git command completion, thus the password prompt never appears.

 

 

0

Ah I see, using Task.Backgroundable did the job, thanks for the explanation!

0

Please sign in to leave a comment.