Frame Rate Control
Setting Preferred Frame Rate
Control the rendering frame rate to balance performance and visual quality:Frame Rate Guidelines
- 30 FPS: Battery-efficient, good for simple animations
- 60 FPS: Standard smooth animations (recommended default)
- 120 FPS: ProMotion displays, very smooth but higher battery usage
Resource Management
File Loading
Cache and reuse Rive files rather than loading them repeatedly:Model Reuse
ReuseRiveModel instances when showing the same animation multiple times:
Memory Management
Release resources when views disappear:Rendering Optimization
Layout Scale Factor
Adjust the layout scale factor for better performance on lower-end devices:Fit and Alignment
Choose appropriate fit modes:Animation Optimization
Pause When Not Visible
Pause animations when they’re not on screen:Loop Control
Limit loops for complex animations:State Machine Efficiency
Use state machines efficiently:Data Binding Performance
Batch Updates
When using data binding, batch property updates:Stream Management
Clean up value streams when no longer needed:View Optimization
Avoid Excessive View Updates
Appropriate View Sizing
Set explicit frame sizes to avoid layout recalculations:Profiling and Debugging
Monitor Frame Rate
Use Xcode Instruments to profile:- Open Xcode Instruments
- Select Time Profiler or Core Animation
- Record while running your animation
- Look for bottlenecks in the call stack
Check Memory Usage
Performance Metrics
Monitor key metrics:- Frame rate consistency (should match preferred FPS)
- Memory usage (watch for leaks)
- CPU usage (should be reasonable for device)
- Battery impact (test on device, not simulator)
Best Practices Summary
- Frame Rate: Use 60 FPS as default, adjust based on device and complexity
- Caching: Cache
RiveFileandRiveModelinstances when reusing animations - Visibility: Pause animations when not visible
- Layout Scale: Use automatic or reduce for lower-end devices
- Batch Updates: Group property updates and manual advances
- Resource Cleanup: Let ARC handle cleanup, but cancel tasks/streams explicitly
- Explicit Sizing: Set explicit frame sizes for better layout performance
- Loop Control: Limit infinite loops for complex animations
- Profile Regularly: Use Instruments to identify bottlenecks
- Test on Device: Simulator performance doesn’t match real devices
Common Performance Issues
Stuttering Animation
- Reduce frame rate
- Simplify animation complexity in Rive editor
- Check for main thread blocking
- Reduce layout scale factor
High Memory Usage
- Clear file cache when memory is low
- Limit number of concurrent animations
- Release strong references to unused models
Battery Drain
- Lower frame rate (30 FPS instead of 120)
- Pause animations when app is backgrounded
- Use
.oneShotinstead of.loopwhere appropriate
Platform Considerations
iOS Devices
- Newer devices (iPhone 13+): 120 FPS is fine
- Mid-range devices (iPhone X-12): Stick to 60 FPS
- Older devices (iPhone 8 and earlier): Consider 30 FPS
iPad
- iPad Pro: Can handle 120 FPS
- Standard iPad: 60 FPS recommended
Simulator
Always test performance on real devices - simulator performance is not representative.See Also
- RiveViewModel - ViewModel configuration
- Audio Control - Managing audio playback