aptabase-swift
aptabase-swift copied to clipboard
Flush sync causes app to hang
Performance issue
Sentry.io reports app hanging for over 2000ms when flushSync() is triggered.
This code in aptabseClient.swift seems to be called on the main thread, and semaphore.wait()
locks the main thread.
@objc private func flushSync() {
let semaphore = DispatchSemaphore(value: 0)
Task {
await self.flush()
semaphore.signal()
}
semaphore.wait()
}
Potential fix
I'm not quite sure why semaphore.wait()
is used here. My best guess is that I will prevent a new flushSync if the latest hasn't finished executing. I've added a timer pause variable to mimic the wait but with out locking the main thread.