Skip to main content
LibIPC provides the inter-process communication (IPC) infrastructure that powers Ladybird’s multi-process architecture. It enables type-safe, high-performance message passing between the UI process, WebContent renderers, ImageDecoder, and RequestServer.

Overview

Ladybird uses a multi-process architecture for security and stability:
  • UI Process: Main browser UI and coordination
  • WebContent Process: Per-tab web rendering (sandboxed)
  • ImageDecoder Process: Image decoding (isolated)
  • RequestServer Process: Network requests (isolated)
LibIPC connects these processes with:
  • Type-safe message definitions
  • Automatic serialization/deserialization
  • Asynchronous and synchronous messaging
  • Integration with Core::EventLoop
IPC in Ladybird is based on message passing over Unix domain sockets (or named pipes on Windows), making it portable and efficient.

IPC concepts

Endpoints

An endpoint defines the interface for IPC communication. Each process typically has a client endpoint and a server endpoint:
  • Client Endpoint: Messages the client can send
  • Server Endpoint: Messages the server can send

Messages

Messages are strongly-typed and defined in .ipc files:

Connection

IPC::Connection

The core class for IPC communication:

Creating connections

Message passing

Synchronous requests

Wait for response from remote process:
Synchronous IPC can block the event loop. Use sparingly and only when necessary. Prefer asynchronous messages when possible.

Asynchronous messages

Fire-and-forget messaging:

Receiving messages

Implement message handlers in endpoint stub:

Transport layer

IPC::Transport

Abstracts the underlying communication mechanism:

Platform implementations

  • TransportSocket: Unix domain sockets (Linux, macOS, BSD)
  • TransportSocketWindows: Named pipes (Windows)

Encoder and Decoder

IPC::Encoder

Serialize data for transmission:

IPC::Decoder

Deserialize received data:

Custom type serialization

Implement encode and decode for custom types:

File descriptor passing

LibIPC supports passing file descriptors between processes:

IPC::File

Wrapper for file descriptors in IPC:
File descriptor passing enables zero-copy data sharing between processes, which is crucial for performance when transferring large bitmaps or shared memory.

Server patterns

SingleServer

Simple single-client server:

MultiServer

Handle multiple concurrent clients:

Integration with event loop

IPC connections integrate with Core::EventLoop for async I/O:

Error handling

Code generation

IPC definitions in .ipc files are processed by the IPC compiler:

Type safety

Compile-time checking of message types and parameters

Automatic serialization

No manual encoding/decoding needed for messages

Async by default

Non-blocking I/O integrated with event loop

Cross-process

Secure isolation between browser components

Source location

  • Repository: ~/workspace/source/Libraries/LibIPC/
  • Key headers: Connection.h, Encoder.h, Decoder.h, Transport.h, File.h
  • Transport implementations: TransportSocket.cpp, TransportSocketWindows.cpp
LibIPC is designed for local inter-process communication within a single system. For network protocols, use LibHTTP or implement custom protocols over LibCore sockets.