Skip to content
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

Process explorer: update name for service worker process #137427

Open
deepak1556 opened this issue Nov 18, 2021 · 9 comments
Open

Process explorer: update name for service worker process #137427

deepak1556 opened this issue Nov 18, 2021 · 9 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug electron Issues and items related to Electron help wanted Issues identified as good community contribution opportunities upstream Issue identified as 'upstream' component related (exists outside of VS Code) workbench-diagnostics General VS Code built-in diagnostic issues

Comments

@deepak1556
Copy link
Contributor

Steps to Reproduce:

  1. Open any webview, ex: open an extension page
  2. Open process explorer
  3. There will now be a window process with no associated title, it can be mistaken for workbench

Inspecting the window via remote debugging, the following are the location information

"vscode-webview://extensioneditor/service-worker.js?id=bd03d4e0-fea8-4a03-8b…de-resource.vscode-webview.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app"

Service workers are also spawned as renderer processes so it would be good to differentiate them in the explorer.

Screen Shot 2021-11-18 at 18 13 38

@deepak1556 deepak1556 changed the title Process explorer: fix name for service worker process Process explorer: update name for service worker process Nov 18, 2021
@bpasero bpasero added the workbench-diagnostics General VS Code built-in diagnostic issues label Nov 18, 2021
@bpasero
Copy link
Member

bpasero commented Nov 18, 2021

Yes, 💯 . I was wrongly assuming we had leaking windows when running integration tests because I saw many many windows appearing that were actually webviews.

@bpasero bpasero added this to the November 2021 milestone Nov 18, 2021
@bpasero bpasero self-assigned this Nov 18, 2021
@bpasero bpasero added the help wanted Issues identified as good community contribution opportunities label Nov 18, 2021
@Tyriar
Copy link
Member

Tyriar commented Nov 18, 2021

@deepak1556 @bpasero is there anything in the command line that I can use to determine it's a service worker in a way that won't break later?

service worker:

"/Users/daimms/dev/Microsoft/vscode/.build/electron/Code - OSS.app/Contents/Frameworks/Code - OSS Helper (Renderer).app/Contents/MacOS/Code - OSS Helper (Renderer) --type=renderer --disable-color-correct-rendering --field-trial-handle=1718379636,4839957752083809804,9678658336852867050,131072 --disable-features=CookiesWithoutSameSiteMustBeSecure,SameSiteByDefaultCookies,SpareRendererForSitePerProcess,WindowCaptureMacV2 --lang=en-GB --standard-schemes=vscode-webview,vscode-file --secure-schemes=vscode-webview,vscode-file --bypasscsp-schemes --cors-schemes=vscode-webview,vscode-file --fetch-schemes=vscode-webview,vscode-file --service-worker-schemes=vscode-webview --streaming-schemes --app-path=/Users/daimms/dev/Microsoft/vscode --enable-sandbox --num-raster-threads=4 --enable-zero-copy --enable-gpu-memory-buffer-compositor-resources --enable-main-frame-before-activation --renderer-client-id=10 --no-v8-untrusted-code-mitigations --shared-files --vscode-window-config=vscode:7c3d8904-b26f-4e78-b3e6-ad1a70789c7a --seatbelt-client=100"

real window:

"/Users/daimms/dev/Microsoft/vscode/.build/electron/Code - OSS.app/Contents/Frameworks/Code - OSS Helper (Renderer).app/Contents/MacOS/Code - OSS Helper (Renderer) --type=renderer --disable-color-correct-rendering --field-trial-handle=1718379636,4839957752083809804,9678658336852867050,131072 --disable-features=CookiesWithoutSameSiteMustBeSecure,SameSiteByDefaultCookies,SpareRendererForSitePerProcess,WindowCaptureMacV2 --lang=en-GB --standard-schemes=vscode-webview,vscode-file --secure-schemes=vscode-webview,vscode-file --bypasscsp-schemes --cors-schemes=vscode-webview,vscode-file --fetch-schemes=vscode-webview,vscode-file --service-worker-schemes=vscode-webview --streaming-schemes --app-path=/Users/daimms/dev/Microsoft/vscode --no-sandbox --no-zygote --num-raster-threads=4 --enable-zero-copy --enable-gpu-memory-buffer-compositor-resources --enable-main-frame-before-activation --renderer-client-id=5 --no-v8-untrusted-code-mitigations --shared-files --vscode-window-config=vscode:7c3d8904-b26f-4e78-b3e6-ad1a70789c7a"

@Tyriar Tyriar added the bug Issue identified by VS Code Team member as probable bug label Nov 18, 2021
@bpasero
Copy link
Member

bpasero commented Nov 20, 2021

Yeah this is really not easy to get right at the moment. It seems to me that a iframe (we no longer use webview) inherits the properties of the window it is in besides explicitly enabling sandbox.

For the shared process I use a hack to tell shared process from normal window apart:

disableBlinkFeatures: 'Auxclick' // do NOT change, allows us to identify this window as shared-process in the process explorer

@deepak1556 is there any way to impact the options that are used for these processes so that we can maybe do something similar?

To clarify, we only really have the entire command line in hand when trying to figure out what the process is:

function findName(cmd: string): string {

@bpasero bpasero added this to ✨ New in Electron Integration Nov 20, 2021
@deepak1556
Copy link
Contributor Author

Let me check on what parent process command lines are inherited by the out of process worker processes and see if we can control them.

For the shared process or workbench window, I would recommend to add custom command line arg that vscode can control to help distinguish via for ex:

webPreference: {
  additionalArguments: ['--shared-process']
}

@bpasero
Copy link
Member

bpasero commented Nov 21, 2021

Yeah I can adopt that for the shared process. I just checked and when I pass additionalArguments to the workbench window, the same argument is received by the out of process worker.

@Tyriar
Copy link
Member

Tyriar commented Nov 22, 2021

I don't think I can action this yet since window kind doesn't exist on the service worker processes? lmk

@bpasero
Copy link
Member

bpasero commented Nov 22, 2021

From my testing everything I put on the workbench window is inherited to the out of process iframe (that is what we are talking about here right?). I think we need some kind of hook to set command line arguments on those to tell them apart.

PS: the only difference is the sandbox enablement, but as we figured out is not a good hint when the workbench window is sandboxed.

@Tyriar
Copy link
Member

Tyriar commented Nov 22, 2021

If there's a way to map the PID to a friendly title on another proc that would work as well, that's how the window names come into the proc explorer:

// Map window process pids to titles, annotate process names with this when rendering to distinguish between them
ipcRenderer.on('vscode:windowsInfoResponse', (event: unknown, windows: any[]) => {
this.mapPidToWindowTitle = new Map<number, string>();
windows.forEach(window => this.mapPidToWindowTitle.set(window.pid, window.title));
});

Alternatively, I could just show any window without a title returned above as "service-worker", but that feels like it will probably fall apart in the future.

@deepak1556
Copy link
Contributor Author

This requires some plumbing work in the runtime, currently chromium doesn't differentiate the shared worker or service worker which are launched similar to other renderer process via command line arguments, there is lot of internal tracking involved which is what the Task Manager in chrome relies to identify and map these process PID to the correct type.

I will try to add a simple command line arguments to these worker renderers that would let us differentiate them in our process explorer, --renderer-type=service-worker, --renderer-type=shared-worker.

@bpasero bpasero removed their assignment Nov 23, 2021
@bpasero bpasero moved this from ✨ New to 🗂 Backlog in Electron Integration Dec 7, 2021
@bpasero bpasero moved this from 🗂 Backlog to ✔️ Done / Deferred in Electron Integration Jan 6, 2022
@Tyriar Tyriar modified the milestones: January 2022, February 2022 Jan 27, 2022
@deepak1556 deepak1556 modified the milestones: February 2022, Backlog Feb 24, 2022
@deepak1556 deepak1556 removed this from the Backlog milestone Dec 13, 2022
@deepak1556 deepak1556 added the upstream Issue identified as 'upstream' component related (exists outside of VS Code) label Dec 13, 2022
@deepak1556 deepak1556 added the electron Issues and items related to Electron label Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug electron Issues and items related to Electron help wanted Issues identified as good community contribution opportunities upstream Issue identified as 'upstream' component related (exists outside of VS Code) workbench-diagnostics General VS Code built-in diagnostic issues
Projects
Archived in project
Electron Integration
  
✔️ Done / Deferred
Development

No branches or pull requests

3 participants