Repository: vscode
Issue: vscode window freezes for a few seconds whenever it gets back focus
Labels: bug,windows,under-discussion

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->
<!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ -->
<!-- 🕮 Read our guide about submitting issues: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions -->
<!-- 🔎 Search existing issues to avoid creating duplicates. -->
<!-- 🧪 Test using the latest Insiders build to see if your issue has already been fixed: https://code.visualstudio.com/insiders/ -->
<!-- 💡 Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. -->
<!-- 🔧 Launch with `code --disable-extensions` to check. -->
Does this issue occur when all extensions are disabled?: Yes/No

<!-- 🪓 If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. -->
<!-- 📣 Issues caused by an extension need to be reported directly to the extension publisher. The 'Help > Report Issue' dialog can assist with this. -->
- VS Code Version: 
Version: 1.84.2 (user setup)
Commit: 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e
Date: 2023-11-09T10:51:52.184Z
Electron: 25.9.2
ElectronBuildId: 24603566
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.19045
- OS Version: 
Windows 10.0.19045.3636

Steps to Reproduce:
So far this only happens to one of my projects

1. switch to another window
2. switch back
3. the window freezes for a few seconds and the CPU usage raises.

I used Process Explorer from Sysinternals to collect some stacktraces of the top CPU-using thread. But as i don't have vscode debug symbols, these may not help

top thread, sample 1
```
ntdll.dll!NtdllDialogWndProc_W+0x100
Code.exe!v8::MicrotasksScope::PerformCheckpoint+0x1c7201
Code.exe!v8::MicrotasksScope::PerformCheckpoint+0x1cd75a
Code.exe!v8::MicrotasksScope::PerformCheckpoint+0x1b8f00
Code.exe!v8_inspector::String16::String16+0x24e58d
0x0000000000000000
Code.exe!v8_inspector::String16::String16+0x28713c
0x0000000000000000
Code.exe!v8_inspector::String16::String16+0x28713c
0x0000000000000000
Code.exe!v8_inspector::String16::String16+0x28713c
0x0000000000000000
Code.exe!v8_inspector::String16::String16+0x28713c
0x0000000000000000
```

top thread, sample 2
```
ntdll.dll!NtdllDialogWndProc_W+0x100
Code.exe!v8_inspector::String16::String16+0x45dc5e
Code.exe!v8_inspector::String16::String16+0x393e10
Code.exe!v8_inspector::String16::String16+0x45eafd
Code.exe!v8_inspector::String16::String16+0x464fe5
Code.exe!GetHandleVerifier+0xf4f5
Code.exe!uv_os_getpid+0x2d438
Code.exe!uv_mutex_destroy+0x119774
Code.exe!v8::metrics::LongTaskStats::LongTaskStats+0x67727
Code.exe!v8::metrics::LongTaskStats::LongTaskStats+0x6851e
Code.exe!v8::metrics::LongTaskStats::LongTaskStats+0x64910
Code.exe!v8::metrics::LongTaskStats::LongTaskStats+0x64a3f
Code.exe!std::Cr::vector<v8::CpuProfileDeoptFrame,std::Cr::allocator<v8::CpuProfileDeoptFrame> >::vector<v8::CpuProfileDeoptFrame,std::Cr::allocator<v8::CpuProfileDeoptFrame> >+0xeb57
Code.exe!v8_inspector::String16::String16+0x7ba1f2
KERNEL32.DLL!BaseThreadInitThunk+0x14
ntdll.dll!RtlUserThreadStart+0x21
```

top thread, sample 3
```
ntdll.dll!NtdllDialogWndProc_W+0x100
Code.exe!v8::MicrotasksScope::PerformCheckpoint+0x1c71c2
Code.exe!v8::MicrotasksScope::PerformCheckpoint+0x1cd75a
Code.exe!v8::MicrotasksScope::PerformCheckpoint+0x1b8f00
Code.exe!v8_inspector::String16::String16+0x235d5f
0x0000000000000000
```

2nd top thread, sample 1
```
ntdll.dll!NtdllDialogWndProc_W+0x100
Code.exe!v8_inspector::String16::String16+0x3a6d54
Code.exe!uv_stream_set_blocking+0x12524
Code.exe!uv_version_string+0xb0a1
Code.exe!uv_version_string+0xaca8
Code.exe!uv_timer_set_repeat+0x246993
KERNEL32.DLL!BaseThreadInitThunk+0x14
ntdll.dll!RtlUserThreadStart+0x21
```

2nd top thread, sample 2
```
ntdll.dll!NtdllDialogWndProc_W+0x100
ntdll.dll!RtlTryAcquireSRWLockExclusive+0x6
Code.exe!v8_inspector::String16::String16+0x59b4dc
Code.exe!v8_inspector::String16::String16+0x599633
Code.exe!uv_version_string+0xaff1
Code.exe!uv_version_string+0xaca8
Code.exe!uv_timer_set_repeat+0x246993
KERNEL32.DLL!BaseThreadInitThunk+0x14
ntdll.dll!RtlUserThreadStart+0x21
```

List of threads:
![image](https://github.com/microsoft/vscode/assets/2098590/950890e8-487b-4787-9dc9-3f181acc6c53)