Skip to content

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

Closed

Description

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)

Activity

  1. 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[/+] on Aug 27, 2021
  2. Tyriar commented on Aug 27, 2021

    @Tyriar
    Contributor

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

  3. deepak1556 commented on Apr 27, 2022

    @deepak1556
    Collaborator

    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);
      */
    }
  4. deepak1556 commented on Apr 27, 2022

    @deepak1556
    Collaborator

    Next Steps in order:

  5. safasofuoglu commented on Apr 27, 2022

    @safasofuoglu

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

  6. removed this from the June 2022 milestone on Jun 30, 2022
  7. deepak1556 commented on Jul 5, 2022

    @deepak1556
    Collaborator

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

  8. locked and limited conversation to collaborators on Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

sandboxRunning VSCode in a node-free environment

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions