Rebuilding Prime Video UI with Rust and WebAssembly
a year ago
- #WebAssembly
- #UI Development
- #Rust
- Prime Video rebuilt its UI for living room devices using Rust and WebAssembly, transitioning from a dual tech stack of React/JavaScript and Rust/WebAssembly to a unified Rust-based solution.
- Living room devices (set-top boxes, gaming consoles, streaming sticks, TVs) present unique challenges like performance variability, hardware differences, and difficulties in updating native code.
- The new architecture features a Rust UI SDK with composables, signals, and effects, enabling high-performance UI development with features like layout animations and instant page transitions.
- The low-level engine uses an Entity Component System (ECS) to manage complexity, with systems updating components for rendering, layout, and resource management.
- Developer productivity remained high despite the shift from JavaScript/TypeScript to Rust, thanks to familiar patterns and macros in the UI SDK.
- Performance improvements were significant, with input latency reduced from 247ms to 33ms on low-end devices.
- Challenges included WebAssembly's evolving ecosystem, the difficulty of writing panic-free code, and the need for developer education on Rust's error handling.
- The Bytecode Alliance supports their use of WebAssembly and WebAssembly System Interface (WASI) in production.