Expand description
Shared memory between an app and the processes it draws through: the ring an app writes its frames into, and the images, fonts and large patch batches it hands over once.
The app creates every buffer, so its pages are charged to the app: an app cannot push its memory onto the service.
The buffers themselves are tilo_shm’s: a sealed memfd on Linux, unlinked POSIX shared
memory on macOS. On Linux the service maps a buffer read-only only after checking its seals:
- every buffer is sealed against shrinking, so a mapping the service reads
can never turn into
SIGBUSunder it, and against growing and further sealing, so its size is the size the service checked; - an image or font is also sealed against writes: it is immutable once registered, so what was validated is what is drawn.
The ring stays writable for the app. The service never trusts what it
read from the ring twice: a frame is decoded into the service’s own
memory in one pass (crate::scene::decode), and only that copy is
validated and drawn.
Other Unix systems (macOS) cannot seal memory: there an immutable buffer is copied once into
the reader’s own memory. The writable ring and SharedMemory need seals, so they stay
Linux’s.
Structs§
- Mapping
- Bytes read from a memory file or regular file, truncated to the length the caller vouched for.
- Ring
Writer - The app’s side of the ring: a writable mapping and the records the service has not finished with yet.
- Shared
Memory - A writable shared memfd: a buffer the service without a GPU draws into
and the app attaches as
wl_shm. Sealed against shrinking, so the compositor’s mapping of it never faults.
Functions§
- sealed_
blob - An immutable buffer holding
bytes: what an app registers an image’s pixels or a font’s bytes in, and hands a large patch batch or a module over in. A memfd sealed against writes and resizing on Linux, unlinked shared memory elsewhere, a pagefile-backed section on Windows;Mapping::map_sealedreads any of them.
Type Aliases§
- Sealed
- A buffer the system made and sealed: a file descriptor on Unix, and on Windows a section’s handle, which a packet carries as it is.