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)
- 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: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
Implementencode and decode for custom types:
File descriptor passing
LibIPC supports passing file descriptors between processes:IPC::File
Wrapper for file descriptors in IPC: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.