Open Laci0503 opened 2 years ago
Does this reproduce in the latest VS Code insiders build with all extensions disabled?
Yes, I am able to reproduce it in the latest insiders build as well.
This is the exact piece of code that makes it lag. However having only one this.voice_connection.on()
part makes it lag just as much.
this.voice_connection
is a VoiceConnection
object from the @discordjs/voice
library.
These are the npm packages installed:
"dependencies": {
"@discordjs/voice": "^0.9.0",
"discord.js": "^13.6.0",
"ffmpeg-static": "^4.4.1",
"googleapis": "^100.0.0",
"prism-media": "^1.3.2",
"sodium": "^3.0.2",
"tinyduration": "^3.2.2",
"ts-node": "^10.7.0",
"typescript": "^4.6.3"
}
this.voice_connection.on(VoiceConnectionStatus.Disconnected, (old_state, new_state)=>{
if(this.state=="PLAYING"){
this.pause();
}
});
this.voice_connection.on(VoiceConnectionStatus.Ready, (new_state, old_state)=>{
if(this.state=="PAUSED"){
this.resume();
}
});
this.voice_connection.on(VoiceConnectionStatus.Connecting, (old_state, new_state)=>{
if(this.state=="PLAYING"){
this.pause();
}
});
this.voice_connection.on(VoiceConnectionStatus.Signalling, (old_state, new_state)=>{
if(this.state=="PLAYING"){
this.pause();
}
});
this.voice_connection.on(VoiceConnectionStatus.Destroyed, (old_state, new_state)=>{
if(this.state=="PLAYING" || this.state=="PAUSED"){
this.stop();
}
});
EDIT: The lag stops if there are 0 or 1 arguments in the handler. For example: this.voice_state.on(VoiceConnectionStatus.Disconnected, ()=>{}) or this.voice_state.on(VoiceConnectionStatus.Disconnected, (new_state)=>{})
Can you please share a small, self contained project that demonstrates the issue?
I could not really find out why it happens with this library, but here is an example of the problem: https://github.com/Laci0503/vscode-lag-issue-test-project.git I have tried to recreate it without the @discordjs/voice library but there must be something in its types of source which makes it lag.
Thanks @Laci0503
With the project, I see encodedSemanticClassifications-full
taking a long time
Info 239 [20:51:09.308] request:
{
"seq": 74,
"type": "request",
"command": "encodedSemanticClassifications-full",
"arguments": {
"file": "/workspaces/vscode-lag-issue-test-project/index.ts",
"start": 0,
"length": 162,
"format": "2020"
}
}
Perf 240 [20:51:12.988] 74::encodedSemanticClassifications-full: elapsed time (in milliseconds) 3680.1233
Moving for TS for investigation
Thanks for your help.
Issue Type: Performance Issue
JavaScript autocomplete becomes very slow and uses a lot of cpu. Steps to reproduce: I am using the Discord.JS library, and the VoiceConnection object uses events which are not named with strings but objects. For example: (method) TypedEmitter.on(event: VoiceConnectionStatus.Disconnected, listener: (oldState: VoiceConnectionState, newState: (VoiceConnectionDisconnectedOtherState & {
...;
}) | (VoiceConnectionDisconnectedWebSocketState & {
...;
})) => Awaited<...>): VoiceConnection
It seems to me that if I bind an event to this emitter, the autocomplete becomes slow. Example: this.voice_connection.on(VoiceConnectionStatus.Disconnected, (old_state, new_state)=>{ if(this.state=="PLAYING"){ this.pause(); } }); However if I comment this out it stops lagging. I reproduced this with extensions disabled.
VS Code version: Code 1.66.2 (dfd34e8260c270da74b5c2d86d61aee4b6d56977, 2022-04-11T07:46:01.075Z) OS version: Windows_NT x64 10.0.19043 Restricted Mode: No
System Info
|Item|Value| |---|---| |CPUs|AMD Ryzen 5 2600X Six-Core Processor (12 x 3593)| |GPU Status|2d_canvas: enabledcanvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|15.95GB (8.38GB free)| |Process Argv|--crash-reporter-id 47a451dd-9d7e-42a4-85ae-b917b84d9992| |Screen Reader|no| |VM|0%|
Process Info
``` CPU % Mem MB PID Process 0 95 13412 code main 0 121 7776 extensionHost 0 703 8776 "C:\Program Files\Microsoft VS Code\Code.exe" --ms-enable-electron-run-as-node --max-old-space-size=3072 "c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js" --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName C:\Users\kecsk\AppData\Local\Temp\vscode-typescript\a1f96df8b23d1affac48\tscancellation-c5c1e941f078bbe6e437.tmp* --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation --useNodeIpc 0 94 9872 "C:\Program Files\Microsoft VS Code\Code.exe" --ms-enable-electron-run-as-node "c:/Program Files/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/typingsInstaller.js" --globalTypingsCacheLocation C:/Users/kecsk/AppData/Local/Microsoft/TypeScript/4.6 --enableTelemetry --typesMapLocation "c:/Program Files/Microsoft VS Code/resources/app/extensions/node_modules/typescript/lib/typesMap.json" --validateDefaultNpmLocation 0 121 22200 "C:\Program Files\Microsoft VS Code\Code.exe" --ms-enable-electron-run-as-node --max-old-space-size=3072 "c:\Program Files\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js" --serverMode partialSemantic --useInferredProjectPerProjectRoot --disableAutomaticTypingAcquisition --cancellationPipeName C:\Users\kecsk\AppData\Local\Temp\vscode-typescript\a1f96df8b23d1affac48\tscancellation-4b1f8abb5201e1af6356.tmp* --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation --useNodeIpc 0 101 16984 shared-process 0 81 14868 fileWatcher 0 76 18272 ptyHost 0 69 14368 C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe 0 6 24380 console-window-host (Windows internal process) 0 126 19692 gpu-process 0 38 20580 utility-network-service 0 88 21564 issue-reporter 0 26 22972 crashpad-handler 0 221 23236 window (audio_cache.ts - bot - Visual Studio Code) ```Workspace Info
``` | Window (audio_cache.ts - bot - Visual Studio Code) | Folder (bot): 48 files | File types: ts(20) json(3) opus(2) dockerignore(1) gitignore(1) m4a(1) | Conf files: dockerfile(1) package.json(1); ```Extensions: none