Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show progress bar when getting GHC version to avoid freezing GUI #412

Closed
runeksvendsen opened this issue Jul 20, 2021 · 8 comments · Fixed by #414
Closed

Show progress bar when getting GHC version to avoid freezing GUI #412

runeksvendsen opened this issue Jul 20, 2021 · 8 comments · Fixed by #414
Labels
type: enhancement An enhancement to an already existing feature type: user experience An enhancement to the UX, e.g. better error handling

Comments

@runeksvendsen
Copy link
Contributor

This comment explains the issue: haskell/haskell-language-server#2010 (comment)

In short, the process of getting a project's GHC version when using cabal is as slow as resolving dependencies, which can be really slow (in the provided example it takes a minute). The result is that the user gets no feedback on what is going on, because HLS can't start until we know which GHC version the project uses. Also, the GUI may freeze, and prevent other extensions from starting.

The solution is to display a VS Code "progress popup" while we're trying to get the project's GHC version.

This issue is for tracking the required changes to vscode-haskell while the linked issue tracks the potential changes to haskell-language-server.

@jneira
Copy link
Member

jneira commented Jul 20, 2021

Many thanks for opening the issue here, i hope it would not too difficult

@jneira jneira added type: enhancement An enhancement to an already existing feature type: user experience An enhancement to the UX, e.g. better error handling labels Jul 20, 2021
@jneira
Copy link
Member

jneira commented Jul 20, 2021

@runeksvendsen after investigating the code a little bit i've found the code getting ghc already tries to do it creating a progress notification:

title: 'Working out the project GHC version',

have you come to see that message at some point?

@jneira
Copy link
Member

jneira commented Jul 21, 2021

ok, trying to open stack project without the appropiate ghc installed to trigger the slow ghc install, i' ve observed that:

  • the extension downloads the wrapper
  • but it gets stuck showing the progress of downloading the wrapper at 100% (i checked the wrapper executable already was in the vscode storage folder)
  • underneath the extension call the wrapper which in turn calls stack which in turn downloads and install ghc

@jneira
Copy link
Member

jneira commented Jul 21, 2021

.. and if the wrapper is already downloaded, the code dont show the Working out the project GHC version either

@runeksvendsen
Copy link
Contributor Author

@jneira

have you come to see that message at some point?

No, I don't recall ever seeing this message.

I have recorded a video of what the problem looks like when opening up VS Code for the project in question. See below. It takes one minute and 10 seconds before the language server is started, without any indication of what's going on before that.

vs-code-haskell-slow.mov

@jneira
Copy link
Member

jneira commented Jul 23, 2021

Thanks for checking it out, it seems the code tries to show a progress notificacion in the status bar but it is not working (maybe it did with older versions of vscode? i dont remember see it)

@runeksvendsen
Copy link
Contributor Author

@jneira I only see a progress notification two places in the code, both of which are related to downloading HLS:

title: 'Working out the project GHC version',

const downloadTask = window.withProgress(

But in my video above HLS isn't downloaded, it's hanging while starting up.

When I run the below command (in this repo)

/Users/rune/Library/Application\ Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-wrapper-1.2.0-darwin

it hangs for about a minute with the following output:

Found "/Users/rune/Obsidian/iohk/code/os-voltaire-fork/cardano-node/hie.yaml" for "/Users/rune/Obsidian/iohk/code/os-voltaire-fork/cardano-node/a"
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper-1.2.0-darwin) Version 1.2.0.0, Git revision be2071e985cb417f984ab00a1aad76dee02d6d0b (dirty) x86_64 ghc-8.10.4
Current directory: /Users/rune/Obsidian/iohk/code/os-voltaire-fork/cardano-node
Operating system: darwin
Arguments: []
Cradle directory: /Users/rune/Obsidian/iohk/code/os-voltaire-fork/cardano-node
Cradle type: Cabal

Tool versions found on the $PATH
cabal:		3.4.0.0
stack:		2.5.1
ghc:		8.10.4


Consulting the cradle to get project GHC version...

It looks like this is the reason VS Code is hanging: since haskell-language-server-wrapper is slow to start up because getting the project GHC version for cabal requires doing dependency resolution first (which can be slow).

Perhaps we need to add a progress dialog for Starting HLS?

@jneira
Copy link
Member

jneira commented Jul 23, 2021

The process is:

  • download haskell-language-server-wrapper-${hlsVersion}, it shows the download progress notification for me, maybe you already has it downloaded. It uses downloadTask
  • call haskell-language-server-wrapper --project-ghc-version to get the project ghc version. This should show 'Working out the project GHC version but it doesn't
  • download haskell-language-server-$hlsVersion}-${ghcVersion} using downloadTask. It shows the download progress notificaction too for me
  • run it

So the key is making 'Working out the project GHC version works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement An enhancement to an already existing feature type: user experience An enhancement to the UX, e.g. better error handling
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants