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

[BUG] High energy consumption on macOS #1746

Closed
orlandommb opened this issue Feb 5, 2025 · 16 comments
Closed

[BUG] High energy consumption on macOS #1746

orlandommb opened this issue Feb 5, 2025 · 16 comments
Assignees
Labels
area-razor bug Something isn't working

Comments

@orlandommb
Copy link

orlandommb commented Feb 5, 2025

Describe the Issue

result from command code -status:
`Version: Code 1.96.4 (cd4ee3b1c348a13bafd8f9ad8060705f6d4b9cba, 2025-01-16T00:16:19.038Z)
OS Version: Darwin arm64 24.2.0
CPUs: Apple M1 Pro (8 x 2400)
Memory (System): 16.00GB (0.09GB free)
Load (avg): 7, 6, 4
VM: 0%
Screen Reader: no
Process Argv: --crash-reporter-id a61d8841-dc3f-4d9d-917e-d56ff42ebb1b

GPU Status:       2d_canvas:                              enabled
                  canvas_oop_rasterization:               enabled_on
                  direct_rendering_display_compositor:    disabled_off_ok
                  gpu_compositing:                        enabled
                  multiple_raster_threads:                enabled_on
                  opengl:                                 enabled_on
                  rasterization:                          enabled
                  raw_draw:                               disabled_off_ok
                  skia_graphite:                          disabled_off
                  video_decode:                           enabled
                  video_encode:                           enabled
                  webgl:                                  enabled
                  webgl2:                                 enabled
                  webgpu:                                 enabled
                  webnn:                                  disabled_off

CPU %	Mem MB	   PID	Process
    1	   197	  8906	code main
    0	    66	  8909	   gpu-process
    0	    33	  8910	   utility-network-service
   74	   672	  8912	window [1] (KoneksiServices.cs — AlphaSoftMedicPOS)
    2	   147	  8924	shared-process
    0	    49	  8927	ptyHost
    0	     0	  9766	     /bin/zsh -il
   22	   672	  9764	extensionHost [1]
  138	   475	  9869	     /usr/local/share/dotnet/dotnet /Users/macbookpro/.vscode/extensions/ms-dotnettools.csharp-2.61.28-darwin-arm64/.razor/rzls.dll --logLevel 3 --DelegateToCSharpOnDiagnosticPublish true --UpdateBuffersForClosedDocuments true --SingleServerCompletionSupport true --telemetryLevel all --sessionId fb98423f-11c6-4182-81e2-36f82fcdec8b1738776161252 --telemetryExtensionPath /Users/macbookpro/.vscode/extensions/ms-dotnettools.csharp-2.61.28-darwin-arm64/.razorDevKit/Microsoft.VisualStudio.DevKit.Razor.dll
   73	  1343	  9899	     /usr/local/share/dotnet/dotnet /Users/macbookpro/.vscode/extensions/ms-dotnettools.csharp-2.61.28-darwin-arm64/.roslyn/Microsoft.CodeAnalysis.LanguageServer.dll --logLevel Information --razorSourceGenerator /Users/macbookpro/.vscode/extensions/ms-dotnettools.csharp-2.61.28-darwin-arm64/.razor/Microsoft.CodeAnalysis.Razor.Compiler.dll --razorDesignTimePath /Users/macbookpro/.vscode/extensions/ms-dotnettools.csharp-2.61.28-darwin-arm64/.razor/Targets/Microsoft.NET.Sdk.Razor.DesignTime.targets --starredCompletionComponentPath /Users/macbookpro/.vscode/extensions/ms-dotnettools.vscodeintellicode-csharp-2.2.3-darwin-arm64/components/starred-suggestions/platforms/darwin-arm64/node_modules/@vsintellicode/starred-suggestions-csharp.darwin-arm64 --devKitDependencyPath /Users/macbookpro/.vscode/extensions/ms-dotnettools.csharp-2.61.28-darwin-arm64/.roslynDevKit/Microsoft.VisualStudio.LanguageServices.DevKit.dll --sessionId fb98423f-11c6-4182-81e2-36f82fcdec8b1738776161252 --extension /Users/macbookpro/.vscode/extensions/ms-dotnettools.csharp-2.61.28-darwin-arm64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.dll --extension /Users/macbookpro/.vscode/extensions/ms-dotnettools.csharp-2.61.28-darwin-arm64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics.dll --telemetryLevel all --extensionLogDirectory /Users/macbookpro/Library/Application Support/Code/logs/20250205T130606/window1/exthost/ms-dotnettools.csharp
    6	   180	  9900	     electron-nodejs (config.js )
    0	   115	  9927	       /Users/macbookpro/.vscode/extensions/ms-dotnettools.csdevkit-1.16.6-darwin-arm64/components/vs-green-server/platforms/darwin-arm64/node_modules/@microsoft/servicehub-controller-net60.darwin-arm64/Microsoft.ServiceHub.Controller 4f54ebca0b /ControllerCooldownTimeout:30000 /TelemetrySession:{"TelemetryLevel":"all","IsOptedIn":false,"HostName":"Default","AppInsightsInstrumentationKey":null,"AsimovInstrumentationKey":null,"CollectorApiKey":"0c6ae279ed8443289764825290e4f9e2-1a736e7c-1324-4338-be46-fc2a58ae4d14-7255","AppId":1010,"UserId":"eb77ed3b-5c5f-4786-9913-d078eca2f865","Id":"fb98423f-11c6-4182-81e2-36f82fcdec8b1738776161252","ProcessStartTime":133832497649066370,"SkuName":null,"VSExeVersion":null,"BucketFiltersToEnableWatsonForFaults":[],"BucketFiltersToAddDumpsToFaults":[]}
    5	   311	  9950	         /Users/macbookpro/.vscode/extensions/ms-dotnettools.csdevkit-1.16.6-darwin-arm64/components/vs-green-server/platforms/darwin-arm64/node_modules/@microsoft/visualstudio-code-servicehost.darwin-arm64/Microsoft.VisualStudio.Code.ServiceHost dotnet.projectSystem$C94B8CFE-E3FD-4BAF-A941-2866DBB566FE net.pipe://9927B227DA /TelemetrySession:{"TelemetryLevel":"all","IsOptedIn":false,"HostName":"Default","AppInsightsInstrumentationKey":null,"AsimovInstrumentationKey":null,"CollectorApiKey":"0c6ae279ed8443289764825290e4f9e2-1a736e7c-1324-4338-be46-fc2a58ae4d14-7255","AppId":1010,"UserId":"eb77ed3b-5c5f-4786-9913-d078eca2f865","Id":"fb98423f-11c6-4182-81e2-36f82fcdec8b1738776161252","ProcessStartTime":133832497649066370,"SkuName":null,"VSExeVersion":null,"BucketFiltersToEnableWatsonForFaults":[],"BucketFiltersToAddDumpsToFaults":[]}
    0	   115	  9980	           /usr/local/share/dotnet/dotnet /Users/macbookpro/.vscode/extensions/ms-dotnettools.csdevkit-1.16.6-darwin-arm64/components/CPS/platforms/darwin-arm64/node_modules/@microsoft/visualstudio-projectsystem-buildhost.darwin-arm64/Microsoft.VisualStudio.ProjectSystem.Server.BuildHost.dll
    0	   164	  9952	         /Users/macbookpro/.vscode/extensions/ms-dotnettools.csdevkit-1.16.6-darwin-arm64/components/vs-green-server/platforms/darwin-arm64/node_modules/@microsoft/visualstudio-code-servicehost.darwin-arm64/Microsoft.VisualStudio.Code.ServiceHost dotnet$C94B8CFE-E3FD-4BAF-A941-2866DBB566FE net.pipe://9927B227DA /TelemetrySession:{"TelemetryLevel":"all","IsOptedIn":false,"HostName":"Default","AppInsightsInstrumentationKey":null,"AsimovInstrumentationKey":null,"CollectorApiKey":"0c6ae279ed8443289764825290e4f9e2-1a736e7c-1324-4338-be46-fc2a58ae4d14-7255","AppId":1010,"UserId":"eb77ed3b-5c5f-4786-9913-d078eca2f865","Id":"fb98423f-11c6-4182-81e2-36f82fcdec8b1738776161252","ProcessStartTime":133832497649066370,"SkuName":null,"VSExeVersion":null,"BucketFiltersToEnableWatsonForFaults":[],"BucketFiltersToAddDumpsToFaults":[]}
    0	    49	  9947	     electron-nodejs (eslintServer.js )
    1	   115	  9949	     /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/html-language-features/server/dist/node/htmlServerMain --node-ipc --clientProcessId=9764
    0	    66	  9765	fileWatcher [1]
Workspace Stats: 
|  Window (KoneksiServices.cs — AlphaSoftMedicPOS)
|    Folder (AlphaSoftMedicPOS): 1055 files
|      File types: cs(578) razor(146) cshtml(15) json(14) css(14) cache(12)
|                  jpg(8) sql(7) png(5) dll(4)
|      Conf files: csproj(2) launch.json(1) settings.json(1) tasks.json(1)
|                  sln(1)`

and this is the energy consumption from activity monitor:

Image

Steps To Reproduce

open any project with asp.net core blazor on vs code (with c# and c# dev kit extensions installed)

Expected Behavior

No response

Environment Information

-OS: MacOS sequoia 15.2
-VS Code Version: 1.96.4 (Universal)

  • Extensions: C# Dev Kit, C#, .NET Install tool
@orlandommb orlandommb added the bug Something isn't working label Feb 5, 2025
@AllenD-MSFT
Copy link
Contributor

It doesn't look like this is specific to MAUI since the customer mentioned ASP.NET Core Blazor.

@GregCilio
Copy link

I have been experiencing this same issue when working with our Blazor web app on a MacBook Air M2. I started disabling extensions to try and find if one of them was the cause, and after I disabled C# the battery drain stopped. If it helps, I noticed output in the Problems pane constantly changing, indefinitely, almost as if it kept recompiling/analyzing the codebase.

@orlandommb
Copy link
Author

I have been experiencing this same issue when working with our Blazor web app on a MacBook Air M2. I started disabling extensions to try and find if one of them was the cause, and after I disabled C# the battery drain stopped. If it helps, I noticed output in the Problems pane constantly changing, indefinitely, almost as if it kept recompiling/analyzing the codebase.

it definitely stopped consuming battery, I made a video but its looks like too large to be uploaded.

@AllenD-MSFT this confirms it.

@orlandommb
Copy link
Author

@AllenD-MSFT @GregCilio here's the video, had to export it to 720p:

C.Extension.high.energy.consumption720p.mov

@orlandommb
Copy link
Author

#1740 seems like this issue is related

@orlandommb
Copy link
Author

Edit and removed the .net maui part.

@orlandommb
Copy link
Author

Any updates on this ?

@akorchev
Copy link

akorchev commented Mar 4, 2025

I think the high energy consumption is caused by high CPU usage that is triggered by certain Blazor apps (not all) when C# DevKit is used. I have logged a similar issue #1806

@orlandommb
Copy link
Author

orlandommb commented Mar 4, 2025

I think the high energy consumption is caused by high CPU usage that is triggered by certain Blazor apps (not all) when C# DevKit is used. I have logged a similar issue #1806

yeah, I just used my main problem with it as a title at the time 😅.

I believe the Blazor Apps this happens with tend to be the ones that are upgraded from older version of .NET this one im working on was originally built with .NET 5.

@GregCilio
Copy link

I believe the Blazor Apps this happens with tend to be the ones that are upgraded from older version of .NET this one im working on was originally built with .NET 5.

This could be right, we recently upgraded our Blazor app from .NET 6 to .NET 8.

@ryzngard
Copy link
Member

ryzngard commented Mar 4, 2025

This could be right, we recently upgraded our Blazor app from .NET 6 to .NET 8.

Just to be clear, is this with the same version of the extension or did that also change?

@orlandommb
Copy link
Author

This could be right, we recently upgraded our Blazor app from .NET 6 to .NET 8.

Just to be clear, is this with the same version of the extension or did that also change?

In my case the version I had when I posted this was 2.61.28 i've updated to 2.63.32 and still happens.

@orlandommb
Copy link
Author

today I've noticed that theres an exception being thrown in the console.

Image

idk if it helps but here's the screenshot.

@ryzngard
Copy link
Member

ryzngard commented Mar 6, 2025

That would indicate that code lense isn't working for razor files. I'm not sure if that specifically would have anything to do with high CPU consumption. It's possible but unlikely

ryzngard added a commit to dotnet/razor that referenced this issue Mar 11, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
After a few reports like microsoft/vscode-dotnettools#1746 and microsoft/vscode-dotnettools#1740 diagnostics are causing users some headaches (and a few other issues I can't find)

In VS we avoid this by using pull diagnostics. In VS Code we publish all diagnostics in the workspace. This PR simply makes it so VS Code now also uses pull diagnostics! There are a few caveats to this: 

1. HTML diagnostics aren't supported. As it turns out, they weren't before anyways. VS Code has no way to ask for them in a generic manner. This isn't a regression but I'll call it out
2. Workspace diagnostics aren't supported (yet). Users may notice that diagnostics aren't reported until a razor file is open. The generated document will still get C# diagnostics through Roslyn workspace diagnostics (I think? Assuming dynamic files aren't filtered...). This matches our VS behavior
3. This duplicates some code adn tests. VS had it's own pull diagnostics prior to it being in the spec. I think we can merge the two but I'm leaving that out of the scope of this PR.

This will require a PR in VS Code to adapt to the new data sent over our custom LSP method.
@GregCilio
Copy link

It appears it is constantly compiling or analyzing my code. The Problems tab is constantly changing, files coming in and out, with the count changing as well.

Here is an example. This will never stop as long as VSCode and this solution is open.

Image

@ryzngard
Copy link
Member

This will be coming in next week's prerelease when dotnet/razor#11602 makes it into the extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-razor bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants