The Story of Stylo: Replacing Firefox's CSS engine with Rust
summary
Stylo is an 85,000-line Rust style engine that ships into Firefox and replaces a 160,000-line C++ system; the integration uses bi-directional FFI boundaries, bindgen-generated bindings, and a GCC static-analysis plugin to enforce thread-safety. Parallelism uses Rayon and a work-queue cascade; surprises include enum size blowup, arc pointer overhead, heavy vendoring of crates, and lack of fallible allocation on Windows. Results: shipped code, fewer fuzzer bugs, and measurable performance wins.
AI-written summary · about
chapters (18)
- 0:00Firefox (Gecko)
- 0:33Gecko's old style system
- 0:52Gecko's new style system (Stylo)
- 1:10What is a style system?
- 5:10Cascading in parallel
- 6:01Awkward history
- 7:10Enter Servo
- 10:04Integrating Stylo: Rust APIs
- 12:03Integrating Stylo: C++ APIs
- 14:57FFI choices: Functions
- 16:39FFI choices: Types
- 17:53Idiomatic FFI from Rust
- 21:46Parallel challenges
- 22:18Parallel style system hazards
- 24:49Pain points: memory usage
- 29:13Pain points: compile times
- 29:40Pain points: fallible allocation
- 31:43A conversation in #servo (cont.)








