MetalFx performance and SSR characteristics
mainPerformance
- Shared Context: Uses a single shared WebGL context across all mounted instances.
- Single Loop: A single
requestAnimationFrameloop drives all instances. - Visibility Optimization: Uses
IntersectionObserverto pause per-instance copies when offscreen. If all instances are offscreen, the GL render loop is skipped. - Resource Management: The GL context, program, and buffer are released automatically when the last instance unmounts.
Server-Side Rendering (SSR)
MetalFx is SSR-safe. It renders a transparent placeholder during SSR and only mounts the WebGL pipeline after client-side hydration, preventing flashes of broken effects or SSR errors.