Overview
WebContent is responsible for:- Running the LibWeb HTML/CSS engine
- Executing JavaScript code via LibJS
- Receiving input events from the Browser process
- Painting web content into shared bitmaps
- Managing page lifecycle and navigation
Each tab gets its own dedicated WebContent process for improved stability and security isolation.
Architecture
The WebContent process operates in a sandboxed environment and communicates with other processes through IPC (Inter-Process Communication).Key components
ConnectionFromClient
Implements the IPC protocol between the Browser and WebContent processes. Handles messages for:- Loading URLs and HTML content
- Input events (keyboard, mouse, touch)
- Viewport updates and rendering
- DevTools integration
- DOM inspection and manipulation
Services/WebContent/ConnectionFromClient.h:35
PageHost
Manages multiplePageClient instances within a single WebContent process. Each page corresponds to a browsing context.
Services/WebContent/PageHost.h:19
PageClient
Hosts the LibWeb engine’s mainWeb::Page object and handles:
- Document lifecycle management
- Painting and rendering
- Script execution coordination
- Event dispatching
Process spawning
WebContent processes are spawned on-demand by the Browser process:To spawn a WebContent process, connect to the socket at
/tmp/session/%sid/portal/webcontent, where %sid is your login session ID.Security and sandboxing
WebContent processes run with strict security constraints:- Unprivileged user: Runs as a separate user from the desktop user
- System call restrictions: Limited via
pledge()mechanism - Filesystem access: Restricted via
unveil()mechanism - Network isolation: Can only communicate through RequestServer
Configuration options
WebContent accepts various command-line options:| Option | Description |
|---|---|
--request-server-socket | File descriptor for RequestServer connection |
--image-decoder-socket | File descriptor for ImageDecoder connection |
--test-mode | Enable test mode for automated testing |
--expose-experimental-interfaces | Expose experimental Web IDL interfaces |
--expose-internals-object | Expose internal testing APIs |
--force-cpu-painting | Disable GPU acceleration for painting |
--headless | Run without graphical interface |
--disable-site-isolation | Disable site isolation security feature |
Console client
WebContent provides console integration throughWebContentConsoleClient, enabling:
- JavaScript console API (
console.log,console.error, etc.) - DevTools console interaction
- Script execution from the browser UI
WebDriver integration
WebContent supports browser automation through WebDriver:- Connects to external WebDriver server via
WebDriverConnection - Implements W3C WebDriver protocol commands
- Enables automated testing and browser control
Services/WebContent/WebDriverConnection.h
Rendering pipeline
The rendering process follows these steps:- Parse HTML: Convert markup into DOM tree
- Apply CSS: Calculate styles and build render tree
- Layout: Compute element positions and dimensions
- Paint: Render content to backing store (CPU or GPU)
- Present: Share bitmap with Browser process for display
Resource loading
All network resources are loaded through the RequestServer:Services/WebContent/main.cpp:260
Image decoding
Images are decoded in separate ImageDecoder processes:- Each image gets a fresh decoder process
- Strongly sandboxed for security
- Supports PNG, JPEG, BMP, ICO, GIF, and more
Performance considerations
- Garbage collection: JavaScript heap is managed by LibJS
- Memory isolation: Each tab’s memory is isolated from others
- Process recycling: Processes are terminated when tabs close
- Shared resources: Font data and some caches are shared across processes
Related processes
- Browser: Main UI process that spawns WebContent
- RequestServer: Handles network requests on behalf of WebContent
- ImageDecoder: Decodes images in isolated processes
- WebDriver: Automation server for testing