dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 672 forks source link

Extension hangs with high CPU usage #2763

Open erictraut opened 5 years ago

erictraut commented 5 years ago

Issue Description

When loading some projects, the C# extension hangs, and the "mono" process is stuck running at at 100%+ CPU utilization. No language services that involve the language server (IntelliSense, hover, etc.) work.

Steps to Reproduce

On a Mac, clone the Microsoft Python Language Server project (https://github.com/Microsoft/python-language-server) Launch VSCode and open the primary workspace for the cloned repo Install the C# extension if it's not already installed

Open the "Activity Monitor" and sort the processes by CPU. Note that the "mono" process is now running at 100%+ In VSCode, open the output view and switch to the "OmniSharp Log". Note that the last line says: Loading project: /python-language-server/src/LanguageServer/Impl/Microsoft.Python.LanguageServer.csproj

I allowed it to run for 15 minutes before terminating it.

I presume this is an issue with OmniSharp, as opposed to the javascript portion of the language server.

I tried rebuilding previous versions of the C# extension (1.16.2, 1.15.2) to see if this was a recent regression, but I was able to repro the same problem with those versions.

I tried the same scenario on Windows, and it worked fine. The OmniSharp log contained additional contents including the line Successfully loaded project file. On the Mac, this was never emitted to the log.

OmniSharp log

Starting OmniSharp server at 12/24/2018, 11:38:57 PM
    Target: /Users/eric/source/python-language-server/src/PLS.sln

OmniSharp server started.
    Path: /Users/eric/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/run
    PID: 10020

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on MacOS 10.13.6 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 15.0 - "/Users/eric/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to '/Users/eric/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin/MSBuild.dll'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 15.0 - "/Users/eric/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin"
            MSBuildExtensionsPath = /Users/eric/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild
            BypassFrameworkInstallChecks = true
            CscToolPath = /Users/eric/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin/Roslyn
            CscToolExe = csc.exe
            MSBuildToolsPath = /Users/eric/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/Users/eric/source/python-language-server/src'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.WorkspaceInitializer
        Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in '/Users/eric/source/python-language-server/src/PLS.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/eric/source/python-language-server/src/LanguageServer/Impl/Microsoft.Python.LanguageServer.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/eric/source/python-language-server/src/UnitTests/Core/Impl/UnitTests.Core.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/eric/source/python-language-server/src/Analysis/Engine/Impl/Microsoft.Python.Analysis.Engine.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/eric/source/python-language-server/src/Analysis/Engine/Test/Microsoft.Python.Analysis.Engine.Tests.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/Users/eric/source/python-language-server/src'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location '/Users/eric/source/python-language-server/src' on host 10001.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/eric/source/python-language-server/src/LanguageServer/Impl/Microsoft.Python.LanguageServer.csproj

C# log

<No output>

Environment information

VSCode version: 1.30.1 C# Extension: 1.17.1

Mono Information OmniSharp using built-in mono
Dotnet Information .NET Core SDK (reflecting any global.json): Version: 2.2.101 Commit: 236713b0b7 Runtime Environment: OS Name: Mac OS X OS Version: 10.13 OS Platform: Darwin RID: osx.10.13-x64 Base Path: /usr/local/share/dotnet/sdk/2.2.101/ Host (useful for support): Version: 2.2.0 Commit: 1249f08fed .NET Core SDKs installed: 2.2.101 [/usr/local/share/dotnet/sdk] .NET Core runtimes installed: Microsoft.AspNetCore.All 2.2.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.2.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.2.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |cpptools|ms-vscode|0.20.1| |csharp|ms-vscode|1.17.1| |python|ms-python|2018.12.1| |tslint|eg2|1.0.42| |vscode-docker|PeterJausovec|0.4.0| |vscode-proto3|zxh404|0.2.2|;
Jma353 commented 5 years ago

+1 - I have experienced the same issue with the same project.

Something to note, I have not experienced this issue when opening other sub-projects of the python-language-server (e.g. Core sub-project).

Jma353 commented 5 years ago

@akshita31 @rchande any help with this?

akshita31 commented 5 years ago

@erictraut @Jma353 Could you try with the latest release of the C# extension? We have made some performance improvements that should make the experience better.

Jma353 commented 5 years ago

@akshita31 I installed 1.18.1-beta1 extension (under 1.19.0 release). I still faced these issues when trying to open up the LanguageServer project in the Python LS github repo. However, I do notice better text editing features in the other sub-projects in the repo with this beta release.

Does this repo for you on a Mac? Something I notice is that, initially, on opening a file in LanguageServer, the text is not sent to the language server at all. I have to edit the file in order for the client to "bootstrap" the file by sending the text to the server. Eventually, the queue of requests server side gets backed up the and the language server stops providing any sort of LSP capabilities. When I turned on trace logging, the OmniSharp Logs presented the following:

[trce]: OmniSharp.MSBuild.ProjectManager
        Started waiting for projects queue to be empty when requested '...' 

along with infinite progress bar at the top of vscode.

Hope these details are helpful in repo-ing / debugging.

mic-hnk commented 5 years ago

I found a hint in #3079 and removing IDisposable implementations actually helped.

onionhammer commented 1 year ago

Is this related to https://github.com/dotnet/sdk/issues/23267