Фикс: бэкграунд звонки — аудио, имя на CallKit, deactivation order, UUID race

This commit is contained in:
2026-04-06 00:18:37 +05:00
parent d65624ad35
commit 55cb120db3
32 changed files with 1548 additions and 688 deletions

View File

@@ -243,11 +243,14 @@ final class ProtocolManager: @unchecked Sendable {
/// Keeps the process alive during active calls so WebSocket survives brief background.
func beginCallBackgroundTask() {
guard callBackgroundTask == .invalid else { return }
let remaining = UIApplication.shared.backgroundTimeRemaining
Self.logger.info("📞 Background task starting — remaining=\(remaining, privacy: .public)s wsState=\(String(describing: self.connectionState), privacy: .public)")
callBackgroundTask = UIApplication.shared.beginBackgroundTask(withName: "RosettaCall") { [weak self] in
// Don't end the call here CallKit keeps the process alive for active calls.
// This background task only buys time for WebSocket reconnection.
// Killing the call on expiry was causing premature call termination
// during keyExchange phase (~30s before Desktop could respond).
Self.logger.info("📞 Background task EXPIRED — OS reclaiming")
self?.endCallBackgroundTask()
}
Self.logger.info("📞 Background task started for call")