@@ -147,8 +147,8 @@ public final class Conversation: ObservableObject, RoomDelegate {
147147 isDevice = true
148148 #endif
149149
150- // On device, use shorter wait or skip entirely
151- let waitTime : UInt64 = isDevice ? 20_000_000 : 100_000_000 // 20ms on device, 100ms on simulator
150+ // On device, use LONGER wait for room connection
151+ let waitTime : UInt64 = isDevice ? 200_000_000 : 100_000_000 // 200ms on device, 100ms on simulator
152152
153153 let waitStart = Date ( )
154154 try ? await Task . sleep ( nanoseconds: waitTime)
@@ -552,12 +552,12 @@ public final class Conversation: ObservableObject, RoomDelegate {
552552 /// Determine optimal buffer time based on agent readiness pattern
553553 /// Different agents need different buffer times for conversation processing readiness
554554 private func determineOptimalBuffer( ) async -> TimeInterval {
555- guard let room = deps? . connectionManager. room else { return 50 .0 } // Reduced default buffer
555+ guard let room = deps? . connectionManager. room else { return 200 .0 } // Default buffer
556556
557557 // Check if we have any remote participants
558558 guard !room. remoteParticipants. isEmpty else {
559559 print ( " [ElevenLabs-Timing] No remote participants found, using longer buffer " )
560- return 100 .0 // Reduced from 200ms to 100ms
560+ return 300 .0 // Longer wait if no agent detected
561561 }
562562
563563 // Check if running on simulator vs device
@@ -568,9 +568,12 @@ public final class Conversation: ObservableObject, RoomDelegate {
568568 isSimulator = false
569569 #endif
570570
571- // Use shorter buffer on device since data channel setup can be slower
572- // but we don't want to wait too long
573- let buffer : TimeInterval = isSimulator ? 150.0 : 50.0
571+ // IMPORTANT: Devices need MORE time, not less!
572+ // On device, data channel and agent initialization is slower due to:
573+ // - Network latency (cellular/wifi vs simulator's ethernet)
574+ // - CPU performance differences
575+ // - Background processes competing for resources
576+ let buffer : TimeInterval = isSimulator ? 100.0 : 250.0 // More time on device!
574577
575578 print ( " [ElevenLabs-Timing] Determined optimal buffer: \( Int ( buffer) ) ms (simulator: \( isSimulator) ) " )
576579 return buffer
0 commit comments