Overview
Helios supports two rendering paths:
- DOM path - Screenshots HTML/CSS/SVG via Playwright
- Canvas path - Direct frame encoding via WebCodecs (faster)
For canvas-heavy compositions (Three.js, Pixi.js, raw Canvas API), the canvas path provides significantly better performance through hardware-accelerated encoding.
Automatic path detection
Helios automatically selects the rendering path:
The renderer inspects the composition and selects the optimal strategy.
Canvas rendering path
The canvas path encodes frames directly from a canvas element using the WebCodecs API.
How it works
- Frame capture - Renderer calls your draw function
- Canvas export - Pixels extracted via
canvas.toBlob() or ImageBitmap
- Hardware encoding -
VideoEncoder compresses frame (GPU-accelerated)
- FFmpeg muxing - Frames piped to FFmpeg for MP4 container
Basic setup
Three.js optimization
Basic Three.js composition
Use static scene graph
Disable auto-clear for layers
Reuse geometries and materials
Use instancing for repeated objects
Optimize shadow maps
Pixi.js rendering
Pixi.js is a 2D WebGL rendering library optimized for sprites and 2D graphics.
GPU acceleration setup
GPU acceleration is critical for rendering performance.
Browser configuration
When using @helios-project/renderer, GPU acceleration is enabled by default:
Verifying GPU acceleration
Use Helios.diagnose() to check WebGL support:
For renderer diagnostics:
Hardware encoder selection
WebCodecs automatically selects hardware encoders when available:
The renderer will fall back to software encoding if hardware acceleration is unavailable.
WebGL best practices
Canvas resolution
Match canvas resolution to export resolution:
Avoid using CSS to scale canvas. This wastes GPU resources rendering at high resolution, then downscaling.
Texture management
Dispose unused textures
Use compressed textures
Limit texture size
Avoid per-frame allocations
Frame timing patterns
Helios provides frame-accurate timing. Use currentFrame or currentTime for animations.
Linear interpolation
Keyframe-based animation
Debugging canvas renders
Visual debugging
Render in headed mode to see what’s happening:
Export canvas for inspection
Next steps