Skip to main content

Performance Optimization

1. Choose the Right Processing Mode

Video Mode (FBProcessModeVideo)
  • Suitable for real-time video streams and live streaming scenarios
  • Better performance and faster processing speed
  • Recommended for camera preview, video calls, and similar scenarios
Image Mode (FBProcessModeImage)
  • Suitable for single image processing
  • Higher quality and better effects
  • Recommended for photo editing and image beautification scenarios

2. Parameter Adjustment Recommendations

Beauty Parameter Adjustment Principles
  • Start with smaller values to avoid over-beautification
  • Recommend reducing parameter values in real-time scenarios for smooth performance
  • Static images can have appropriately higher parameter values
  • Adjust parameter ranges based on user groups and scenarios
Recommended Parameter Ranges

3. Memory Optimization

Use ARC for Memory Management
Release Resources Timely

Architecture Design

1. Singleton Pattern for Engine Management

2. Asynchronous Image Processing

Error Handling

1. Comprehensive Error Handling Mechanism

2. Retry Mechanism

Lifecycle Management

The beauty engine is a singleton and is automatically released when the app ends. Manual management is not required. However, stopping beauty processing when leaving a page/ViewController can save resources.

1. NSViewController Lifecycle Handling

2. Application Lifecycle Handling

Performance Monitoring

1. Performance Metrics Monitoring

2. Memory Usage Monitoring

Configuration Management

1. Beauty Configuration Management

macOS-Specific Optimizations

1. Multi-Display Support

2. Window Management

3. System Performance Monitoring

Testing Recommendations

1. Unit Testing

2. Performance Testing

Summary

Following these best practices can help you:
  1. Improve Performance: Through memory management, multi-threading, and image optimization
  2. Improve User Experience: Through progressive loading and smooth transitions
  3. Improve Code Quality: Through modular design and error handling
  4. Ensure Stability: Through comprehensive testing strategies
  5. macOS Optimization: Through multi-display support and window management
Remember to adjust these practices based on specific needs and continuously monitor application performance. The macOS platform has more memory and stronger processing capabilities compared to iOS, allowing support for higher quality beauty effects.