Skip to content

Truly independent web browser

Documentation: Describe workers as threads of WebContent

Andreas Kling7a32248e15a3
diff --git a/Documentation/CrashReports.md b/Documentation/CrashReports.md
index aa33fa1e7d4..f00ca6a8c89 100644
--- a/Documentation/CrashReports.md
+++ b/Documentation/CrashReports.md
@@ -1,11 +1,10 @@
# Crash reports
On macOS and Linux, Ladybird saves local text reports when the browser or a
-helper process crashes: WebContent, WebWorker, RequestServer, ImageDecoder,
-Compositor, MediaServer, AudioServer and VideoDecoderServer. A dedicated worker
-runs on a thread of its owner's WebContent process, so its crash is a
-WebContent crash and is reported as one; WebWorker reports come from shared
-workers. Reports are stored in
+helper process crashes: WebContent, RequestServer, ImageDecoder, Compositor,
+MediaServer, AudioServer and VideoDecoderServer. A worker runs on a thread of a
+WebContent process, so its crash is a WebContent crash and is reported as one.
+Reports are stored in
`~/Library/Application Support/Ladybird/CrashReports/` on macOS and
`~/.local/share/Ladybird/CrashReports/` on Linux, or under
`$XDG_DATA_HOME/Ladybird/CrashReports/` if that variable is set.
diff --git a/Documentation/ProcessArchitecture.md b/Documentation/ProcessArchitecture.md
index 208044cebca..6e3f8e9944f 100644
--- a/Documentation/ProcessArchitecture.md
+++ b/Documentation/ProcessArchitecture.md
@@ -5,22 +5,18 @@ Ladybird uses a multi-process architecture to improve stability and security in
## Process overview
```
- Browser
- |
- +----------+----------+--------+-------+----------------+
- | | | | |
- Compositor WebContent WebWorker RequestServer ImageDecoder
- (renderer) (renderer) (per site) (per site)
- | |
- +-----------+ |
- | | |
- WebRTCClient +----+-----+
- |
- +--------+--------+
- | |
- MediaServer AudioServer
- |
- VideoDecoderServer
+ Browser
+ |
+ +----------+-------------+-------+----------------+
+ | | | |
+ Compositor WebContent RequestServer ImageDecoder
+ (renderer) (per site) (per site)
+ |
+ +-----------+-----------+
+ | | |
+ WebRTCClient MediaServer AudioServer
+ |
+ VideoDecoderServer
```
**RequestServer** and **ImageDecoder** are shared by the renderers of a site, while the processes below the renderers each work for a single renderer. **Browser** launches all of them, because the sandboxes keep the others from spawning anything. It then connects them directly to each other, so that a renderer talks to its **RequestServer** or **ImageDecoder** without going through **Browser**.
@@ -30,7 +26,6 @@ Ladybird uses a multi-process architecture to improve stability and security in
| **Browser** | One | By the user |
| **Compositor** | One | At startup, and again if it crashes |
| **WebContent** | One per set of documents that must share a process, see [site isolation](#site-isolation) | When a document needs one, with a spare kept ready for the next tab |
-| **WebWorker** | One per worker | When a page or worker starts a worker |
| **RequestServer** | One per browsing session and top-level site, plus one per session with no site | The default session's one with no site at startup, the others on first use |
| **ImageDecoder** | One per browsing session and site, or one for a single process | When a renderer first has an image to decode |
| **MediaServer** | One per renderer | When the renderer first needs one |
@@ -60,9 +55,7 @@ This process hosts the main HTML/CSS engine (**LibWeb**) and runs JavaScript (**
A process holds one page for each tab it has documents in.
-### Process: WebWorker
-
-This process runs a single dedicated or shared worker. A worker runs in a process of its own, so a top-level site may only run so many of them at once.
+Web workers run in this process too, each on a thread of its own with its own JavaScript VM and heap. A dedicated worker runs in the process of its owner. A shared worker runs in the process of the document that starts it, and that process stays alive without pages for as long as it runs a shared worker, as the worker's other owners can be in other processes. A shared worker that may not share a process with its owner, as the owner is cross-origin isolated, gets a **WebContent** process without a page.
### Process: RequestServer
@@ -108,7 +101,7 @@ A renderer that needs a helper it does not have yet asks **Browser** for a conne
## Sandboxing
-Every process in the table above except **Browser** applies a sandbox to itself early in its startup, unless **Browser** was started with `--disable-sandbox`. Each one's sandbox allows only what that process needs, and can be found in the `Sandbox` files in its directory under `Services`. **WebContent** and **WebWorker** share theirs, in `Services/RendererSandbox.h`.
+Every process in the table above except **Browser** applies a sandbox to itself early in its startup, unless **Browser** was started with `--disable-sandbox`. Each one's sandbox allows only what that process needs, and can be found in the `Sandbox` files in its directory under `Services`. The one of **WebContent** is in `Services/RendererSandbox.h`.
On Linux, sandboxes are built from seccomp and Landlock. On macOS, they use the Seatbelt sandbox. Windows has no sandbox yet.
@@ -138,7 +131,7 @@ LibWeb
Web::DOM::Document The active document of a navigable, the root of the DOM tree
```
-In the **Browser** process, each kind of view derives from `WebView::ViewImplementation`, which shows a tab. A tab's documents may be spread over several processes, so a view reaches each of them through a `WebView::WebContentPage`, and each process through its `WebView::WebContentClient`. `WebView::WebWorkerClient` does the same for a **WebWorker** process.
+In the **Browser** process, each kind of view derives from `WebView::ViewImplementation`, which shows a tab. A tab's documents may be spread over several processes, so a view reaches each of them through a `WebView::WebContentPage`, and each process through its `WebView::WebContentClient`. `WebView::WebWorkerClient` does the same for a worker on a thread of a **WebContent** process.
`WebView::CanonicalTraversable`, `WebView::CanonicalNavigable` and `WebView::CanonicalDocument` are the record that **Browser** keeps of a tab's navigables and documents, whichever processes host them.
diff --git a/Documentation/StatsLog.md b/Documentation/StatsLog.md
index 6c0b0ce4c4b..3613c239035 100644
--- a/Documentation/StatsLog.md
+++ b/Documentation/StatsLog.md
@@ -24,7 +24,7 @@ Every record has these fields:
| --- | --- |
| `type` | `sample` or `event` |
| `time_ns` | Integer nanoseconds from `CLOCK_MONOTONIC`, shared across processes on a host |
-| `process` | `Ladybird`, `WebDriver`, `WebContent`, `WebWorker`, `RequestServer`, `Compositor`, `ImageDecoder`, `AudioServer`, `MediaServer`, or `VideoDecoderServer` |
+| `process` | `Ladybird`, `WebDriver`, `WebContent`, `RequestServer`, `Compositor`, `ImageDecoder`, `AudioServer`, `MediaServer`, or `VideoDecoderServer` |
| `pid` | Integer operating system process ID |
For example:
@@ -81,9 +81,9 @@ Unsupported values are omitted, rather than reported as zero.
| `rendering.paints` | Main event loop's paint counter |
| `rendering.update_duration_us` | Main event loop's rendering update time counter, in microseconds |
-GC values belong to the main VM heap in WebContent and WebWorker. The logger never reads GC state
-from another thread, so the heaps of dedicated workers, which run on threads of their owner's
-WebContent process, are not sampled; their memory and CPU time show in the process values. Live sizes and completed durations
+GC values belong to the main VM heap in WebContent. The logger never reads GC state from another
+thread, so the heaps of workers, which run on threads of a WebContent process, are not sampled;
+their memory and CPU time show in the process values. Live sizes and completed durations
start at zero until the first sweep finishes. Heap block bytes exclude the reserved address range,
unused type-isolated chunks, weak blocks, and blocks retained for reuse or awaiting background
decommit. They are not a measurement of resident memory or committed memory. No heap walk is
@@ -117,7 +117,7 @@ form `namespace:local`, preserving their exact values in floating-point JSON con
| `load` | WebContent | Same fields as `DOMContentLoaded` |
| `frame` | Compositor | `page_id` (integer), `changed` (boolean), `damage_x`, `damage_y`, `damage_width`, `damage_height` (integer device pixels) |
| `rendering_pending` | WebContent | `page_id` (integer), `navigable_id` (cross-process ID string), `pending` (boolean), `reasons` (object of integer counts) |
-| `gc` | WebContent or WebWorker | `collection`, `duration_ns`, `pause_duration_ns`, `sweep_duration_ns`, `bytes_before`, `bytes_after`, `live_cell_bytes`, `live_external_bytes` (integers) |
+| `gc` | WebContent | `collection`, `duration_ns`, `pause_duration_ns`, `sweep_duration_ns`, `bytes_before`, `bytes_after`, `live_cell_bytes`, `live_external_bytes` (integers) |
Navigation starts are recorded when the browser admits a navigation. Lifecycle markers are recorded
immediately before DOM event dispatch, excluding event handlers. Match them by `navigable_id`.
diff --git a/Documentation/TabPerformanceMonitor.md b/Documentation/TabPerformanceMonitor.md
index db044118a78..77872392de2 100644
--- a/Documentation/TabPerformanceMonitor.md
+++ b/Documentation/TabPerformanceMonitor.md
@@ -17,12 +17,11 @@ counter differencing and windowing independently of the UI and OS APIs.
* **CPU:** CPU-time deltas divided by actual monotonic elapsed time. 100% is
one logical CPU; values above 100% are expected. All live and terminated
- threads in exclusively owned WebContent and WebWorker processes contribute,
- so a dedicated worker counts under the WebContent process that hosts it.
- Registered page and embedded-frame ownership identify WebContent owners.
- Worker ownership is resolved transitively, including nested workers and
- shared workers whose owners all resolve to the same tab. Processes shared
- across tabs, unresolved owners and cyclic ownership remain unattributed.
+ threads in exclusively owned WebContent processes contribute, so a worker
+ counts under the WebContent process that hosts it. Registered page and
+ embedded-frame ownership identify WebContent owners. Processes shared across
+ tabs remain unattributed, and so does a process that runs on without pages
+ for its shared workers.
The first sample establishes a baseline. The sparkline retains ten seconds.
* **MEM:** An estimate of owned process memory, counted once per process.
macOS uses the kernel's physical-footprint ledger, including compressed
diff --git a/Libraries/LibJS/JIT/ARCHITECTURE.md b/Libraries/LibJS/JIT/ARCHITECTURE.md
index 9f41993c0ca..aebaea331c3 100644
--- a/Libraries/LibJS/JIT/ARCHITECTURE.md
+++ b/Libraries/LibJS/JIT/ARCHITECTURE.md
@@ -545,8 +545,8 @@ JIT.
Builds with the JIT run it unless the `LIBJS_JIT` environment variable says otherwise. LibJS reads
it whenever it creates a VM, in every process that runs JavaScript: `js`, `test-js`,
-`test262-runner`, and the browser's WebContent and WebWorker processes, to which the browser passes
-on every `LIBJS_` variable.
+`test262-runner`, and the browser's WebContent processes, to which the browser passes on every
+`LIBJS_` variable. Each worker on a thread of a WebContent process has a VM of its own.
`LIBJS_JIT` holds comma-separated options, applied left to right from the defaults. A value with an
unknown option, or with an option written wrong, stops the process with a message that says why.