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

Sandbox: explore how to support direct helper process to renderer communication #131798

Closed
bpasero opened this issue Aug 27, 2021 · 5 comments
Closed
Assignees
Labels
sandbox Running VSCode in a node-free environment

Comments

@bpasero
Copy link
Member

bpasero commented Aug 27, 2021

Allow direct communication between a helper process and the renderer.

image

Some raw ideas

  • what if Electron would provide an API similar to BrowserWindow.loadUrl but UtilityProcess.loadUrl to create such a child process
  • Electron should delegate this to Chrome and reuse the ability Chrome has to spawn utility processes like GPU and Network
  • Utility process has node.js integration enabled and direct communication support to a renderer (either via electron IPC or message ports)
@bpasero bpasero added the sandbox Running VSCode in a node-free environment label Aug 27, 2021
@bpasero bpasero changed the title Explore how to support node.js processes from Electron that can talk directly to a BrowserWindow (to convert shared process into a node.js process) Sandbox: explore how to support direct helper process to renderer communication Aug 27, 2021
@Tyriar
Copy link
Member

Tyriar commented Aug 27, 2021

@deepak1556 any update on this? Do we have an upstream issue we can link?

@deepak1556
Copy link
Collaborator

deepak1556 commented Apr 27, 2022

Prototype demonstrating communication between Node integration enabled chromium service process and sandbox renderer is complete.

Link: https://streamable.com/tqozwr

Current state of API:

// Main Process
interface ProcessOptions {
 displayName?: string | undefined;
 execArgv?: string[] | undefined;
 env?: NodeJS.ProcessEnv | undefined;
}

interface MessageEvent {
  data: any;
}

class UtilityProcess extends NodeJS.EventEmitter {

 constructor(modulePath: string, args?: string[] | undefined, options?: ProcessOptions);

 readonly pid?: number | undefined;

 /*
  * Pending Implementation
 postMessage(channel: string, message: any, transfer?: Electron.MessagePortMain[]): void;
  */

 kill(signal: number): boolean;

 /*
  * Pending Implementation
 on(event: 'message', listener: (event: MessageEvent) => void): this;
  */
 
 on(event: 'exit', listener: (code: number) => void): this;

 on(event: 'spawn', listener: (void) => void): this;
}

// Service Process
interface MessageEvent {
 data: any;
 ports: MessagePortMain[];
}

interface Process extends NodeJS.EventEmitter {

 on(channel: string, listener: (event: MessageEvent) => void): this;

 /*
  * Pending Implementation
 send(message: any);
  */
}

@deepak1556
Copy link
Collaborator

deepak1556 commented Apr 27, 2022

Next Steps in order:

@deepak1556 deepak1556 modified the milestones: April 2022, May 2022 Apr 27, 2022
@safasofuoglu
Copy link

Will this work enable shareable non-copy buffers, rather than one-way ownership transfer?

@deepak1556
Copy link
Collaborator

Exploration is complete and extension host has adopted this behind a setting. Next steps continued in #154007

@github-actions github-actions bot locked and limited conversation to collaborators Aug 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
sandbox Running VSCode in a node-free environment
Projects
None yet
Development

No branches or pull requests

4 participants