Closed davidzech closed 3 years ago
It seems like https://github.com/microsoft/vscode/blob/f74e473238aca7b79c08be761d99a0232838ca4c/src/vs/workbench/contrib/terminal/node/terminalProcess.ts#L276 is taking a long time.
Benchmarking this call, it takes on average 800ms. It doesn't make sense, but this seems to be a Node.js x macOS beta
type of issue.
I have been having this issue as well with the insiders build of vscode
@deepak1556 do you know why an exec
call would be blocking the thread?
Some further notes for reference:
to be
async() => { this._updateProcessCwd(); }
Seems to fix the terminal from being blocked. It's still a bandaid over the underlying problem, which is child_process.exec()
taking a long time to execute on macOS Big Sur Beta.
Edit: I was wrong, still exhibits the behavior, weird.
+1 I have this issue either and it happened after updating to macOS 11 (Big Sur) beta. I am currently on beta 9 and the issue still exists.
UPDATE: I have the lag even if I am typing or running commands and its so annoying.
Version: 1.50.0
Commit: 93c2f0fbf16c5a4b10e4d5f89737d9c2c25488a3
Date: 2020-10-07T06:00:00.397Z (6 days ago)
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Darwin x64 20.1.0
+1 I have this issue either and it happened after updating to macOS 11 (Big Sur) beta. I am currently on beta 9 and the issue still exists.
Version: 1.50.0 Commit: 93c2f0fbf16c5a4b10e4d5f89737d9c2c25488a3 Date: 2020-10-07T06:00:00.397Z (6 days ago) Electron: 9.2.1 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Darwin x64 20.1.0
It also occurred with me after updating to Big Sur Beta, I think it is about the beta.
Some further insights:
I have done some debugging with lldb
, and have narrowed it down to fork()
being the bottleneck here.
Edit:
You can observe calls with
sudo dtruss -p <window_pid> -t fork -e
@davidzech Don't you think this might be a bug from the macOS kernel then?
+1 for having this issue; only remember seeing this issue after upgrading to Big Sur. Happy to run some debugging if anyone has any ideas.
Thanks.
@Adam2Marsh Have you built locally? To my surprise, I ran my tests on master
and tag 1.50.1
and I do not experience this lag at all, yet is persistent in both Stable and Insider public releases.
An useful bisection perhaps.
See
Edit 2: VSCodium also doesn't exhibit this behavior for me.
@davidzech +1 Agree, I built Code-OSS[master branch] with macOS 11.0.1[build = 20B5012d] and I see no problem with input-lag with integrated terminal. Only for local build. Public version of vscode still has that problem tho.
Thanks for narrowing down the issue @davidzech , we do use a custom electron build for the stable and insiders while we use https://electronjs.org/ releases for the OSS build. But I don't see any patches around the child_process code path.
Can you run the test on following electron builds, you can extract and run the electron binary, toggle developer tools from the View menu
@deepak1556
I've done some quick-test, by swapping Electron binaries on latest stable release vscode, both custom electron | oss electron. The issue still remains.
Also I bulit vscode-darwin[oss package] and swapped electron binaries with custom electron version, there is no issue at all. Which might indicates it is not the problem of electron[perhaps?]
It might be a useful information[or not really] that Commit information of current stable version of release is d2e414d9e4239a252d1ab117bd7067f125afd80a. So I reverted source of vscode to that commit and built code-oss, there was no problem at all.
Also I bulit vscode-darwin[oss package] and swapped electron binaries with custom electron version, there is no issue at all. Which might indicates it is not the problem of electron[perhaps?]
Interesting, then this might indicate the problem is with a packaged app vs running out of sources. @davidzech are you aware of any entitlement changes in big sur that would impact this ?
@deepak1556 I am not aware of anything intentional, but I can confirm that stripping code signature from Code Helper (Renderer)
makes the problem go away.
You can test with codesign --remove-signature /Applications/Visual\ Studio\ Code.app/Contents/Frameworks/Code\ Helper\ \(Renderer\).app
So unfortunately, it looks like my guess from https://github.com/microsoft/vscode/issues/107103#issuecomment-696454728 looks to be accurate.
I don't think there is much to debug on electron or vscode end, would like to report this issue to apple. What is best way to do it ?
Last os update resolves the issue for me
OS: macOS Big Sur 11.0.1 20B5022a x86_64 Kernel: 20.1.0 VSCode: 1.51
I cannot confirm this, installed the latest beta yesterday. The terminal had been laggish until I stripped the signature.
The issue persists with the latest macOS 11.0.1 RC2 released today. Stripping the signature helped though.
This looks similar to a problem we found: https://github.com/electron/electron/issues/26143
It seems to an Electron bug since it's reproducible when using child_process.spawn in the renderer process but not in main
This may be an Electron bug since we had these problems on Big Sur when on release.
I am on macOS Big Sur 11.0.1. In addition to the terminal freezing, every time I switched back to the code editor from the terminal, the code editor would also freeze.
Having the same issue on VSCode as well. Upgraded to Big Sur from Catalina last night and started having the freezing issue instantly.
@jaikens19 Same issue here.
@paulfsheridan @davidzech suggested running this in terminal: codesign --remove-signature /Applications/Visual\ Studio\ Code.app/Contents/Frameworks/Code\ Helper\ \(Renderer\).app
it ended up fixing the issue for me.
Same issue, thought there was something wrong with my laptop. On top of the delay in the terminal, i'm experiencing delay while typing and backspacing continuously both in terminal and while working on any files.
I am experiencing the same
@jaikens19, unfortunately, had no luck with this. Thanks though.
@paulfsheridan @davidzech suggested running this in terminal:
codesign --remove-signature /Applications/Visual\ Studio\ Code.app/Contents/Frameworks/Code\ Helper\ \(Renderer\).app
it ended up fixing the issue for me.
This worked for me.
@paulfsheridan @davidzech suggested running this in terminal:
codesign --remove-signature /Applications/Visual\ Studio\ Code.app/Contents/Frameworks/Code\ Helper\ \(Renderer\).app
it ended up fixing the issue for me.
I can confirm this worked for me as well!
@paulfsheridan @davidzech suggested running this in terminal:
codesign --remove-signature /Applications/Visual\ Studio\ Code.app/Contents/Frameworks/Code\ Helper\ \(Renderer\).app
it ended up fixing the issue for me.
This also worked for me, thanks!
Above fix works for me as well. Don't forget to relaunch vscode.
@paulfsheridan @davidzech suggested running this in terminal:
codesign --remove-signature /Applications/Visual\ Studio\ Code.app/Contents/Frameworks/Code\ Helper\ \(Renderer\).app
it ended up fixing the issue for me.
This fix seems to work for me as well.
@paulfsheridan @davidzech suggested running this in terminal:
codesign --remove-signature /Applications/Visual\ Studio\ Code.app/Contents/Frameworks/Code\ Helper\ \(Renderer\).app
it ended up fixing the issue for me.
This workaround worked for me too ;)
Has anybody checked if this is related to Apple's recent usage of OSCP to check the validity of developer certificates when launching an executable? According to that blog post, this should only happen once for each executable, so I guess this is something else. Also, maybe I'm mixing up signatures and certificates here?
@lenaschimmel: yea, I looked at that, and it appears to be unrelated. it happens even if wifi/ethernet are off, and it's only reproducible in the electron renderer process, not the main process
Are there any drawbacks to removing the signature as suggested? Perhaps related to future updates?
You’re just removing the signature from the original app. Signatures are meant to prove the app came from a certain developer. If you know that this app you downloaded is legit, then there is no danger in removing the signature. I GUESS
⚠️⚠️⚠️⚠️.
I'm having this issue in Big Sur and removing signature as suggested above "fixes" it.
I am affected also by this.
I ran the command codesign --remove-signature /Applications/Visual\ Studio\ Code.app/Contents/Frameworks/Code\ Helper\ \(Renderer\).app
and am still experiencing lagging in terminal. On macOs 11.0.1.
I ran the command
codesign --remove-signature /Applications/Visual\ Studio\ Code.app/Contents/Frameworks/Code\ Helper\ \(Renderer\).app
and am still experiencing lagging in terminal. On macOs 11.0.1.
Did you relaunch VS Code?
I ran the command
codesign --remove-signature /Applications/Visual\ Studio\ Code.app/Contents/Frameworks/Code\ Helper\ \(Renderer\).app
and am still experiencing lagging in terminal. On macOs 11.0.1.Did you relaunch VS Code?
Don't hurt me but it worked after I relaunched lol.
I ran the command
codesign --remove-signature /Applications/Visual\ Studio\ Code.app/Contents/Frameworks/Code\ Helper\ \(Renderer\).app
and am still experiencing lagging in terminal. On macOs 11.0.1.
It's lagging as it was, and now Little Snitch tells me that VSCode is not signed and it's probably a malware.
Could you share with me how can is sign it again? Re-Installing the app didn't change much.
On macOS 11.0.1, fork()
seems to physically copy all JIT memory regions (no-copy-on-write). On previous OS, these regions weren't accessible at all in the forked process, sort of explaining the "regression".
You can test by making a lot of mmap()
calls with MAP_JIT
, and then calling fork()
in a playground project. (make sure you have com.apple.security.cs.allow-jit
entitlement)
It would be nice if libuv
used posix_spawn
instead.
Aha that would also explain why the issue is not seen for child processes forked from browser process as reported by @marcello3d in the electron issue. The reason being until recently https://github.com/electron/electron/pull/26331 we have been using a different memory allocator on the browser process that doesn't MAP_JIT
regions allocated, hence fork didn't have JIT regions to copy over. If this is true, @marcello3d you should see this issue in browser process with nightly release of electron https://www.electronjs.org/releases/nightly, can you confirm ?
It would be nice if libuv used posix_spawn instead.
@davidzech there seems to be an active issue about using posix_spawn
for a different scenario on all platforms https://github.com/libuv/libuv/issues/2133 , lets continue the discussion in the electron thread https://github.com/electron/electron/issues/26143 so that the team can drive the effort to make the change atleast on macOS to circumvent this issue.
@deepak1556 Yes, I just confirmed that the problem exists in the browser process (electron "main") with the latest nightly.
thanks for confirming!
This started happening for me when I upgraded to macOS Big Sur 11.0.1. Here's the vscode version info.
Version: 1.51.1
Commit: e5a624b788d92b8d34d1392e4c4d9789406efe8f
Date: 2020-11-11T01:11:34.018Z (1 wk ago)
Electron: 9.3.3
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Darwin x64 20.1.0
Steps to Reproduce:
Spam random keys until lag is experiencedPress enter, then continuously type (anything) for about 2 seconds.Does this issue occur when all extensions are disabled?: Yes
This occurs on a public beta build of macOS 11. I've confirmed the same issue on two different MacBook Pro's on the same OS version, and same VS Code version.
Attached is a performance profile. You can see the spike in the integrated terminal response time at around 23000ms - 24000ms
Profile-20200826T124154.json.zip