I have severe UI hang issues whenever my sync worker is running. The app experiences:
Screen navigation freezes Scroll lag and stuttering Unresponsive UI during data synchronization
The root cause is Realm database read/write operations blocking the main thread during a sync process that involves 99+ sequential database operations. Environment
- iOS: 16.0+ (issue more prominent on iOS 26)
- Swift: 5.x
- Framework: SwiftUI
- RealmSwift: 20.0.0
Current Behavior
class WorkManager {
func syncChanges() async {
await uploadData() // Uploads local data to server
await downloadData() // 51 sync operations with extensive DB reads/writes
}
}
During this sync:
- User cannot scroll smoothly
- Navigation transitions freeze
- App appears hung/unresponsive
- UI becomes usable only after sync completes