Skip to main content

Module constellation

Module constellation 

Source
Expand description

The Constellation, Servo’s Grand Central Station

The constellation tracks all information kept globally by the browser engine, which includes:

  • The set of all EventLoop objects. Each event loop is the constellation’s view of a script thread. The constellation interacts with a script thread by message-passing.

  • The set of all Pipeline objects. Each pipeline gives the constellation’s view of a Window, with its script thread and layout. Pipelines may share script threads.

  • The set of all BrowsingContext objects. Each browsing context gives the constellation’s view of a WindowProxy. Each browsing context stores an independent session history, created by navigation. The session history can be traversed, for example by the back and forwards UI, so each session history maintains a list of past and future pipelines, as well as the current active pipeline.

There are two kinds of browsing context: top-level ones (for example tabs in a browser UI), and nested ones (typically caused by iframe elements). Browsing contexts have a hierarchy (typically caused by iframes containing iframes), giving rise to a forest whose roots are top-level browsing context. The logical relationship between these types is:

+------------+                      +------------+                 +---------+
|  Browsing  | ------parent?------> |  Pipeline  | --event_loop--> |  Event  |
|  Context   | ------current------> |            |                 |  Loop   |
|            | ------prev*--------> |            | <---pipeline*-- |         |
|            | ------next*--------> |            |                 +---------+
|            |                      |            |
|            | <-top_level--------- |            |
|            | <-browsing_context-- |            |
+------------+                      +------------+

The constellation also maintains channels to other parts of Servo, including:

  • The script thread.
  • The Paint subsystem, which runs in the same thread as the Servo instance.
  • The font cache, image cache, and resource manager, which load and cache shared fonts, images, or other resources.
  • The service worker manager.
  • The devtools and webdriver servers.

The constellation passes messages between the threads, and updates its state to track the evolving state of the browsing context tree.

The constellation acts as a logger, tracking any warn! messages from threads, and converting any error! or panic! into a crash report.

Since there is only one constellation, and its responsibilities include crash reporting, it is very important that it does not panic.

It’s also important that the constellation not deadlock. In particular, we need to be careful that we don’t introduce any cycles in the can-block-on relation. Blocking is typically introduced by receiver.recv(), which blocks waiting for the sender to send some data. Servo tries to achieve deadlock-freedom by using the following can-block-on relation:

  • Constellation can block on Paint
  • Constellation can block on embedder
  • Script can block on anything (other than script)
  • Blocking is transitive (if T1 can block on T2 and T2 can block on T3 then T1 can block on T3)
  • Nothing can block on itself!

There is a complexity intoduced by IPC channels, since they do not support non-blocking send. This means that as well as receiver.recv() blocking, sender.send(data) can also block when the IPC buffer is full. For this reason it is very important that all IPC receivers where we depend on non-blocking send use a router to route IPC messages to an mpsc channel. The reason why that solves the problem is that under the hood, the router uses a dedicated thread to forward messages, and:

  • Anything (other than a routing thread) can block on a routing thread

See https://github.com/servo/servo/issues/14704

Structs§

BrowsingContextGroup 🔒
A browsing context group.
Constellation
The Constellation itself. In the servo browser, there is one constellation, which maintains all of the browser global data. In embedded applications, there may be more than one constellation, which are independent of each other.
InitialConstellationState
State needed to construct a constellation.
MessagePortInfo 🔒
Info related to a message-port tracked by the constellation.
PendingApprovalNavigation 🔒
ScreenshotReadinessRequest 🔒
WebRenderWGPU 🔒
WebRender related objects required by WebGPU threads

Enums§

ExitPipelineMode 🔒
When we are exiting a pipeline, we can either force exiting or not. A normal exit waits for Paint to update its state before exiting, and delegates layout exit to script. A forced exit does not notify Paint, and exits layout without involving script.
ScreenshotRequestState 🔒
When a ScreenshotReadinessRequest is received from the renderer, the Constellation go through a variety of states to process them. This data structure represents those states.
TransferState 🔒
The state used by MessagePortInfo to represent the various states the port can be in.

Constants§

WARNINGS_BUFFER_SIZE 🔒
The number of warnings to include in each crash report.

Type Aliases§

PendingApprovalNavigations 🔒