-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Electron: Enable renderer process reuse #120431
Comments
CC @deepak1556 |
@rzhao271 anytime a window either gets reloaded, closed or workspace changed within the window, the same code gets triggered to handle this because anyone in the window can participate on this event to either veto it from happening or doing some task (even long running). The events are
I think we can easily use these events to kill processes when the The watcher is actually a IPC Client and it looks like the dispose method will kill the process. I think the extension host already has code to participate in the shutdown so that extensions can properly get deactivated: vscode/src/vs/workbench/services/extensions/electron-browser/localProcessExtensionHost.ts Line 130 in 94c9ea4
A couple of things we have to make sure:
Would you be interested in providing a PR for this work to help out on this task? |
It looks like |
Deepak mentioned that I can look for places that call
The following places use
Before doing any optimizations (this issue), we should double-check that all the native modules we use are context-aware. I'll create a separate issue for
Deepak provided two scenarios to consider, which are reloading a window, and switching the current workspace. Are there any other cases that could involve a process being reused? If we implement a reset signal so that instead of killing + relaunching the window, the window state is simply reset, a part we would have to be careful about would be ensuring the old state doesn't leak into the new one. |
@bpasero in what situations does the shared process get reloaded ? Ignoring the case where we want to restart the process when it crashed. |
Yes, that is a good way to find out what child processes we spawn from a renderer.
Fyi that
Yes, I would suggest to do a pass over our When I did that last time, I only found the
At least for VSCode workbench windows, these 2 are the same. They both go through the same code and will trigger
I do not think that keeping the script context alive is an option currently, simply because we currently have no means of cleaning up all the state on shutdown. So far we get a free cleanup because the context changes everytime we call #35109 is related where we discussed the concept of doing a workspace change without a
Never. We have no support to reconnect to the shared process currently. |
That is correct and there will be a context change on reload. Based on the lifecycle hooks you have mentioned in #120431 (comment) , they are sufficient to have child processes restart in the process reuse model as well, we don't have to treat the process reuse mode as a different state. |
@bpasero So this issue is essentially reviving #35109? I would also like to confirm what is meant by there being "lots of work involved currently", because I currently only see two blockers before we consider implementing some workspace reuse optimizations:
|
We should keep the workspace reuse idea tracked separately, this issue I would like us to track only the work required to enable
For that the blockers:
|
Agree on #120431 (comment). Some comments:
To clarify: are you suggesting to push this to insiders/stable even before Electron 12 and even before we moved away from
I think they automatically get restarted because we always spawn them from the workbench when it starts. So the task at hand would be to ensure that the processes a renderer spawns properly terminate as part of the workbench shutdown (which is an event that happens anytime a window is closed, reloaded or when the workspace changes). |
yup that is correct, since electron 11 already supports process reuse. I think this should be experimented on current main branch. |
@deepak1556 oh sorry, nevermind. I confused myself here with the idea to enable |
Some notes based on offline discussions:
Currently, the largest regression is the fact that child processes spawned from the workbench are not restarting on reloads. Right now with the process reuse flag enabled, we have the following:
|
Are you saying there is a process swap on reloads ?
native-watchdog is not context-aware, the module has global states that will conflict when used from multiple contexts. spdlog should not be used in renderer after #120159, how did you confirm spdlog usage ? |
Isn't
Can you clarify how you found these dependencies, from my memory:
That is something to follow up and is unexpected. After all, when the workbench starts we always spawn new processes for file watcher and extension host because we do not support to reconnect to existing processes. |
This seems to trigger electron/electron#30153 in selfhost where suddenly colorization and any node.js IPC communication stops to work. |
Closing this in favour of the general work item to update to Electron 16 where this will be the default. |
I'm wondering where the testplan item for this issue is, and/or whether we need a new one? @bpasero |
I think @deepak1556 covered that as part of the E16 and E17 test plan items previously. |
Yup its covered in previous milestone testing #141268. This feature has already gotten plenty of coverage, does not require additional testing. |
We currently have process reuse disabled in
main.js
, but considering how the native modules we use are now context-aware, we can start looking more into enabling process reuse.There are other processes to look into, but for now, I would like to concentrate just on the extensionHost and watcherService. For those, I'm wondering
The text was updated successfully, but these errors were encountered: