Driver architecture
The TimeDriver interface
All drivers implement theTimeDriver interface:
packages/core/src/drivers/TimeDriver.ts:15 for the full interface definition.
Driver selection
Helios automatically selects a driver based on configuration:Helios.ts:542:
Built-in drivers
NoopDriver
The simplest driver—does nothing. Used when you don’t need animation synchronization.- Compositions with no CSS/WAAPI animations
- Manual animation control only
- Headless calculations without rendering
packages/core/src/drivers/NoopDriver.ts:3:
DomDriver
Synchronizes CSS animations, WAAPI timelines, and media elements in the browser.- WAAPI animation seeking
- Media element (
<video>,<audio>) synchronization - Shadow DOM support
- Audio track discovery and mixing
- Stability checks (fonts, images, media)
packages/core/src/drivers/DomDriver.ts:11 for the full implementation.
- WAAPI sync
- Media sync
- Stability checks
CdpTimeDriver (Renderer)
Uses Chrome DevTools Protocol to virtualize time for deterministic server-side rendering.- Pause virtual time: Freeze the browser’s internal clock
- Sync media elements: Manually seek
<video>/<audio>to target time - Advance virtual time: Resume clock for exact frame duration
- Wait for stability: Check for async operations to complete
packages/renderer/src/drivers/CdpTimeDriver.ts:6 for implementation.
- Initialization
- Time advancement
- Media synchronization
CDP virtual time is deterministic because the browser’s event loop is paused until the time budget expires. This means
requestAnimationFrame callbacks and CSS animations all update to the exact target time before rendering continues.Media element synchronization
Data attributes
Control media playback with custom attributes:data-helios-track-id: Unique identifier for track controldata-helios-offset: When the track starts in composition time (seconds)data-helios-seek: In-point in the media file (seconds)data-helios-fade-in: Fade-in duration (seconds)data-helios-fade-out: Fade-out duration (seconds)data-helios-fade-easing: Easing function for fades
Audio track control
DomDriver.ts:461 for fade and volume logic.
Audio track discovery
DomDriver automatically discovers audio tracks:Custom drivers
Create a custom driver to integrate with non-standard time sources.Example: External clock driver
Example: MIDI timecode driver
Stability patterns
Custom stability checks
Register async operations that should block rendering:Helios.ts:876 for the stability check API.
Virtual time synchronization
When usingbindToDocumentTimeline(), Helios polls __HELIOS_VIRTUAL_TIME__:
Tickers
Drivers use tickers to manage the playback loop. Tickers are separate from drivers to allow different timing strategies.RafTicker (default)
UsesrequestAnimationFrame for smooth browser playback:
TimeoutTicker
UsessetTimeout for Node.js or non-browser environments:
ManualTicker
Manually advance time for testing:packages/core/src/drivers/ for all ticker implementations.
Best practices
Choose the right driver
- NoopDriver: Manual control, no animations
- DomDriver: CSS/WAAPI animations, media elements
- CdpTimeDriver: Server-side rendering only
Scope animations carefully
Preload media elements
Handle stability timeouts
For long-running async operations, increase the timeout:Next steps
- Learn about animations for motion control
- Explore timeline control for playback
- Understand compositions for project structure