Skip to content

Instantly share code, notes, and snippets.

@gabrielluong
Forked from gregtatum/actor-multiprocess.md
Created October 18, 2017 17:51
Show Gist options
  • Save gabrielluong/34de428884e76cc4d4bd47b6e8d24ce3 to your computer and use it in GitHub Desktop.
Save gabrielluong/34de428884e76cc4d4bd47b6e8d24ce3 to your computer and use it in GitHub Desktop.
WIP

Understanding how DevTools multiprocess architecture works.

 ________________________________________________________________________________________
|                                   Parent process                                       |
|----------------------------------------------------------------------------------------|
|  DebuggerServer (devtools/server/main.js)                                              |
|  \                                                                                     |
|    - Globally Scope Actors                                                             |
|      - PreferenceActor                                                                 |
|      - HeapSnapshotActor                                                               |
|      - etc.                                                                            |
|    - DebuggerServer.connectToChild() -> loads devtools/server/child.js in content      |
|    - DebuggerServer.connectToWorker() -> loads devtools/server/worker.js in worker     |
|                                                                                        |
|                                         ^                                              |  
|                                         |                                              |
|------------------- LocalDebuggerTransport handles messages by passing -----------------|
|                            deeply frozen objects by reference                          |
|                                         |                                              |
|                                         v                                              |
|  DevTools Toolbox                                                                      |
|  DevTools client panel code                                                            |
|  Actor Fronts                                                                          |
|  \                                                                                     |
|    - The fronts (clients) communicate via various transport adaptors to server code    |
|      (see devtools/shared/transport/transport.js for specific mechanisms.) The         |
|      transport mechanism varies but includes Message Managers, freezing packets and    |
|      passing by reference, or other internal communication methods.                    |
|                                                                                        |
 ----------------------------------------------------------------------------------------
  ^                                    ^
  |                                    |
  |        ChildDebuggerTransport handles Message Manager communication
  |                                    |
  |                                    v
  |     _________________________________________________________________________________
  |    |                      Content process(es) - 1 or more                            |
  |    |---------------------------------------------------------------------------------|
  |    |  Multiple tabs can live in a single content process, and multiple content       |
  |    |  processes can be created. This is left up to the browser. Each content         |
  |    |  process gets loaded with a DebuggerServer.                                     |
  |    |                                                                                 |
  |    |  (devtools/server/child.js loads another copy of devtools/server/main.js)       |
  |    |  DebuggerServer                                                                 |
  |    |  \                                                                              |
  |    |    - Runs DebuggerServer.connectToParent() to complete the connection.          |
  |    |    - Creates an ActorPool for the entire content process. This pool contains    |
  |    |      a set of TabActor instances. Other TabActors like the InspectorActor are   | <-probably not accurate yet
  |    |      created that have a lifetime of that individual tab.                       |
  |    |                                                                                 |
  |    |      e.g.                                                                       |
  |    |      - TabActor                                                                 |
  |    |        - InspectorActor                                                         |
  |    |        - WebConsoleActor                                                        |
  |    |        - etc.                                                                   |
  |    |                                                                                 |
  |     --------------------------------------------------------------------------------- 
  |
 WorkerDebuggerTransport handles postMessage communication
  |
  v
 ________________________________________________________________________________________
|                                 Worker process(es)                                     |
|----------------------------------------------------------------------------------------|
| (devtools/server/worker.js loads another copy of devtools/server/main.js)              |
| DebuggerServer                                                                         |
 ----------------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment