Understanding Editor Performance
AppFlowy Editor’s performance depends on several factors:- Document Size: Number of nodes in the document
- Rendering Complexity: Custom block components and styling
- Transaction Frequency: How often changes are made
- Selection Updates: Cursor movement and selection changes
- Network Operations: For collaborative editing
Document Structure Optimization
Use Efficient Node Types
Choose the right node types for your content:Minimize Node Depth
Flat document structures perform better:Lazy Loading for Large Documents
For very large documents, load content progressively:Transaction Optimization
Batch Multiple Operations
Combine multiple changes into a single transaction:Use In-Memory Updates
For temporary changes, use in-memory updates:Debounce Rapid Changes
Debounce rapid updates like auto-save:Rendering Optimization
Use Const Widgets
Useconst constructors where possible:
Optimize Custom Block Components
Use RepaintBoundary
Isolate expensive widgets from rebuilds:Selection Performance
Throttle Selection Updates
Memory Management
Dispose Resources Properly
Limit Undo History
Network Performance
Compress Transaction Data
For collaborative editing, compress transaction data:Delta Synchronization
Send only changes, not entire documents:Monitoring Performance
Use Performance Overlay
Profile Your App
Measure Transaction Time
Best Practices
- Batch Operations: Combine multiple changes into single transactions
- Debounce Updates: Delay non-critical updates like auto-save
- Lazy Load: Load large documents progressively
- Optimize Rendering: Use const widgets and RepaintBoundary
- Limit History: Set reasonable undo/redo limits
- Dispose Resources: Always dispose EditorState and listeners
- Profile Regularly: Use Flutter DevTools to identify bottlenecks
- Monitor Memory: Watch for memory leaks in long-running sessions
Performance Checklist
- Transactions are batched when possible
- Rapid updates are debounced or throttled
- Large documents use lazy loading
- Custom components use const constructors
- RepaintBoundary wraps expensive widgets
- Undo history has size limits
- EditorState is properly disposed
- Network data is compressed
- Performance is profiled in production mode
- Memory usage is monitored