Outgoing audio lost after a fast reconnect while the call stays "connected"

Đang mở
#1,615 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
dart, flutter

Hướng nghiên cứu

Start with the reconnect and publisher connection paths named in packages/stream_video/lib/src/call/call.dart, call/session/call_session.dart, webrtc/peer_connection.dart, and ws/ws.dart. Trace how offline renegotiation, peer connection state checks, SFU socket closes, and SFU errors interact during fast reconnects; the report identifies all five gaps and reproduction logs. Reproduce with repeated 10–20 second network outages in a two participant audio call, then verify outgoing audio recovers and reconnect errors trigger the appropriate recovery.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

After a ~10–20 s network drop, stream_video 1.7.2 reports the call reconnected while the publisher peer connection is not actually sending. Others can't hear the user for several seconds at best; in both of our captured runs the user's outgoing audio never came back before the call was dropped. Throughout, CallStatus is connected and the mic shows on.

Environment

Item Value
stream_video / stream_video_flutter 1.7.2, git ref 2ec78303dbc6fe8043e104b4cd378d56b2159a4e (no reconnect changes on main since)
stream_webrtc_flutter 4.0.1
Platform iOS on a mobile network, CallKit, ADM-level mute (stopTrackOnMute: false)
Call audio only, 2 participants
Join options camera and mic disabled on join, mic enabled right after via setMicrophoneEnabled
CallPreferences reconnectTimeout and networkAvailabilityTimeout set to 30 s

Impact

  • Local user: CallStatus is connected and the mic shows on, but the other participant hears nothing. Incoming audio works.
  • Other participants: the user is shown as unmuted; the SFU still lists their audio track as published.
  • Recovery: none in either run. Run 1: publisher stuck in ICE checking until a later network stall ended the call. Run 2: the SFU closed the signaling socket and removed the participant, and the call was dropped 75 s after the outage began.
  • It reproduces with the mic on during the outage, and with the mic off during the outage and turned on afterwards.

Run 1: publisher stuck in checking

SFU session 30d15c56-3a33-4a48-ae82-830d4bb6711d, two ~20 s outages in the same call. Both were fast reconnects; the second differs only in that a stale publisher negotiation from the offline retry loop succeeded after the network returned.

Step Outage 1 (audio recovered) Outage 2 (audio stayed dead)
Network lost 20:53:50 20:54:40
Publisher ICE restarted while offline (_tryRestartIce, isReconnecting: false) 20:53:59 20:54:50
Publisher renegotiation retries while offline, each failing SetPublisher on DNS ~8 ~210 in 6 s
Last retry's SetPublisher timed out after 10 s (20:54:11) succeeded at 20:54:59.27, answer applied
Network back 20:54:11 20:54:57
Fast reconnect: SFU join reconnected: true, audio still listed as published 20:54:12 20:55:00
Fast reconnect: ICE restart + publisher renegotiation answer 20:54:13.98 20:55:03.23
[join] connected 20:54:14.31 20:55:03.25
Peer connections reach connected both (20:54:12.5, 20:54:14.5) one only (subscriber), 20:55:06.75
publisherConnectionCheck (15 s later) Connected — OK Checking — OK (20:55:20)
SFU error none participantMediaTransportFailure: publisher PC: connection failed, strategy rejoin (20:55:20.245)
SDK reaction none needed rejected rejoin (reconnect in progress: fast); a network-triggered fast reconnect had started 24 ms earlier
Outcome audio works no outgoing audio; call left at 20:55:50 with ReconnectionFailed after a further network stall

Run 2: SFU closes the socket, SDK ignores it

SFU session 4372aadf-fa79-49e0-bda8-bdc878c4635c, one ~12 s outage. The mic was muted before the outage (21:46:25) and turned on again after the reconnect. The network also switched from cellular to Wi-Fi during the reconnect.

Time Event
21:46:36 Network lost, fast reconnect started (waits for network)
21:46:44 Publisher ICE restarted while offline (isReconnecting: false)
21:46:44 → 21:46:48.7 152 publisher renegotiations, each failing SetPublisher on DNS; the last one sent 70 ms before the network returned
21:46:50.00 Fast reconnect begins (setReconnecting(true))
21:46:50.04 The stale SetPublisher from the offline loop succeeds; its answer is applied during the fast reconnect
21:46:51.97 Network changes from cellular to Wi-Fi
21:46:53.18 Fast reconnect's own publisher renegotiation answered
21:46:53.19 [join] connected
21:46:53.44 First peer connection connected
21:46:55.6 → 21:46:58.6 User unmutes and speaks; UpdateMuteStates and trackPublished succeed, the other participant hears nothing
21:47:01.29 Second peer connection connected, 8 s after [join] connected
21:47:08 publisherConnectionCheck: Connected — OK
21:47:20.79 SFU closes the signaling WebSocket with 1001 closing. The SDK logs SfuSocketDisconnected and does nothing: 1001 counts as an intentional closure
21:47:20 → 21:47:35 Call still connected with no signaling channel
21:47:35.78 Both peer connections go ICE disconnected
21:47:35.9 Coordinator call.session_participant_left for this user
21:47:38.5 ICE restart triggers a fast reconnect; WS recreated, join request sent
21:47:38.80 SFU: participantNotFound, strategy rejoin, socket closed 1008 participant 10931 not found. SDK: skipping reconnect (join in progress)
21:47:38 → 21:48:08 Fast reconnect keeps waiting for a JoinResponse that will never come
21:48:08.74 fastReconnect failed: TimeoutException after 0:00:30; reconnect window exceeded, call left with ReconnectionFailed

Root cause

Five gaps combine. Paths are under packages/stream_video/lib/src/ at 2ec78303.

  1. ICE restarts and renegotiation run while waiting for the network.
    • _reconnect waits for the network before running a strategy (call/call.dart:2521), and only fastReconnect marks the peer connections as reconnecting (call/session/call_session.dart:488-489).
    • _tryRestartIce (webrtc/peer_connection.dart:143) and _onRenegotiationNeeded (webrtc/peer_connection.dart:556) are guarded only by that flag, so they fire on disconnected/failed while offline.
    • Each publisher negotiation fails SetPublisher (call/session/call_session.dart:1187) and rolls back; the pending ICE restart re-fires negotiationneeded, giving a tight loop (150–210 offers in 4–6 s, each with new ICE credentials and a burst of trickle requests).
    • The last request can complete after the network returns, even after the fast reconnect has started (run 2), so the SFU applies an ICE-restart offer outside the reconnect and the fast reconnect then renegotiates again on top of it.
  2. A fast reconnect reports connected before media is up. fastReconnect restarts ICE and renegotiates the publisher (call/session/call_session.dart:565-571), then _join sets the call connected (call/call.dart:1880). Nothing waits for either peer connection to reach connected: 3 s (run 1, never) and 8 s (run 2) after [join] connected, media was still not flowing.
  3. No recovery for a publisher stuck in checking.
    • startPublisherConnectionCheck (call/session/call_session.dart:619-677) handles only ICE new and signaling have-local-offer; any other state is logged as OK, including checking 17 s after the last answer (run 1).
    • The SFU does detect the failure and asks for a rejoin, but _reconnect drops it while another reconnect holds the lock (call/call.dart:2406). It is only kept as _isRejoinPending for when the current attempt fails (call/call.dart:2445); if that attempt "succeeds" on signaling, the stuck publisher stays.
  4. An SFU-initiated 1001 close is ignored. StreamWebSocketCloseCode.isIntentionalClosure treats goingAway (1001) like normalClosure (ws/ws.dart:49-50), so the SfuSocketDisconnected handler skips reconnecting (call/call.dart:2302-2306). That fits a client-side close, but here the SFU closed the socket (manuallyClosed: false) and the call sat without signaling until the SFU removed the participant 15 s later (run 2).
  5. A fast reconnect ignores an SFU error and waits 30 s. start() races the join response against SfuErrorEvent (call/session/call_session.dart:329-333), but fastReconnect waits only for SfuJoinResponseEvent with a 30 s limit (call/session/call_session.dart:543). On participantNotFound the SFU replies at once and closes the socket, yet the attempt runs the full 30 s; the rejoin the SFU asked for is deferred (call/call.dart:2397) and, with a 30 s reconnectTimeout, never runs (call/call.dart:2489).

Why the publisher's ICE stalled after the double negotiation, and why the SFU closed the socket at 21:47:20 in run 2, need the SFU's side of the two sessions above. On the client, the final answers and the SFU's publisher candidates arrived and were applied.

Steps to reproduce

Intermittent: it depends on the last offline SetPublisher completing after the network returns. Two or three outages in a row raise the odds.

  1. Join a 2-person audio call on a phone (reproduced on iOS; the code path is shared across platforms). Turn the mic on, or leave it off and turn it on after step 2.
  2. Turn mobile data / Wi-Fi off for 10–20 s, then back on. Wait for the call to show connected.
  3. Repeat step 2 once or twice.
  4. Speak: the other participant hears nothing although the call shows connected and the mic on.
  5. With verbose SDK logs, confirm: [negotiate] #setPublisher; failed repeated while offline, a [setRemoteAnswer] #publisher right before or during [fastReconnect], then either [publisherConnectionCheck] … Checking — OK (run 1) or [Sfu-WS] [onClose] closeCode: 1001 with no reconnect (run 2).
Ngôn ngữ chính
Dart
Star
79
Fork
55
Merge trung bình
2 ngày 12 giờ
Pull request đã merge (30 ngày)
142

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của GetStream/stream-video-flutter

Tất cả issue của GetStream/stream-video-flutter

Issue tương tự

Thêm issue về Dart

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.