-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Avoid sending all terminal data to all renderer processes #133895
Comments
I would actually think there is more to it: #131798 asks for a way to allow for an isolated communication channel to a window and @deepak1556 made an exploration to use web workers to have multiple isolated |
Kind of sounds like this is a duplicate of #131798, the plan eventually is for the shared process to only establish the connection and then it gets skipped via a direct renderer <-> node channel. We haven't heard much of an issue about this so I'd rather wait and make the proper fix when #131798 is ready. |
@Tyriar yeah I will explore this for the file watcher in October, @deepak1556 explored this and figured out a seamingly working solution that involves web workers with node integration. Example code is at https://gist.github.com/deepak1556/884d729f284880bf6d05302102742b1f Basic flow:
|
@bpasero I think that's still a temporary solution though, we want to avoid as many process jumps as possible even if they're on a different thread. |
@Tyriar I think @deepak1556 should clarify, my understanding was that this is THE solution. |
@Tyriar @meganrogge if you want to play with the shared process worker support for terminals, I just pushed a first version of it and adopted for file watchers. On a high level:
On a low level:
Alternatively, if this service is not useful for terminals because you have rolled your own process architecture, I would still think that you can do this:
The worker is created from |
@bpasero process isolation also prevents crashes in node-pty from taking down the shared process, don't really want to lose that even though I'm not aware of any more that can happen. |
Yeah I understand, that is not something the file watching worker is concerned about because it does nothing else then the message transfer between child process and the message port. Nevertheless, there could be 1 web worker that forks the PTY agent to avoid that the shared process main thread is busy handling terminal IO. |
Btw I am not 100% sure this is true. When a window opens, a pair of |
This will be fixed as part of #175335 |
Fixed! |
From my understanding of how
ILocalPtyService
works, it looks to me that all process data reaches all renderer processes due to theIPtyService.onProcessData
event. So if there is a spammy terminal in one VS Code window, that output will reach all VS Code windows, and then it is theLocalTerminalService
that drops in the VS Code window side the output not meant for one of its terminals (using the?
operators).I have run into a similar situation where I need to launch extension host processes, but I am only interested in the stdout/stderr/etc. for the process associated to the current window, so I have added something called
onDynamic*
events to shared process services such that only a specific window can listen to a specific event. You can find an example inIExtensionHostStarter
. Any method that begins withonDynamic
will be considered a dynamic event and will be propagated correctly to the shared process side. I think the limitation is that a single argument can be passed in, due to how the channel-serverlisten
works.cc @bpasero
The text was updated successfully, but these errors were encountered: