General Principles
Minimize Re-renders
Avoid unnecessary canvas re-renders by using proper state management:Use Worklets for Animations
Reanimated worklets run on the UI thread for smooth animations:Path Optimization
Mark Paths as Volatile
For paths that change frequently:Simplify Complex Paths
Use path simplification for better performance:Reuse Path Objects
Image Optimization
Use Appropriate Image Formats
- PNG for images with transparency
- JPEG for photos without transparency
- WebP for best compression
Preload Images
Use Image Sampling Options
Control image quality vs performance:Layer and Effect Optimization
Minimize Layers
Layers create offscreen buffers - use them sparingly:Cache Complex Effects
UseuseMemo for expensive shader or filter creation:
Font and Text Optimization
Preload Fonts
Use TextBlob for Static Text
For text that doesn’t change:Rendering Optimization
Use mode="continuous" Wisely
Only use continuous rendering when necessary:
Batch Updates
Group related drawing operations:Memory Management
Dispose of Resources
Manually dispose of large objects when done:Avoid Memory Leaks in Animations
Profiling and Debugging
Enable Debug Mode
Use React DevTools Profiler
Identify unnecessary re-renders in your component tree.Measure Frame Times
Platform-Specific Optimizations
Android
- Enable hardware acceleration in AndroidManifest.xml
- Use
androidWarmupprop to pre-initialize Skia
iOS
- Leverage Metal backend (enabled by default)
- Use P3 color space for wider color gamut:
Best Practices Checklist
- ✅ Use Reanimated worklets for animations
- ✅ Minimize layer usage
- ✅ Preload images and fonts
- ✅ Reuse path objects
- ✅ Mark frequently changing paths as volatile
- ✅ Use
useMemofor expensive operations - ✅ Avoid creating new objects in render methods
- ✅ Profile your app regularly
- ✅ Simplify complex paths
- ✅ Use appropriate image formats and sampling
- ✅ Batch drawing operations
- ✅ Clean up resources in useEffect cleanup