azure-sdk-for-ios
azure-sdk-for-ios copied to clipboard
[BUG] First RemoteVideoStreamDelegate and RemoteParticipantDelegate state event is unreliable
Describe the bug
When implementing the RemoteVideoStreamDelegate
or RemoteParticipantDelegate
to listen for changes to state
, the emitted events are unreliable. When the a remote participant first shuts off their video, the participant's NotAvailable
video state change is emitted with an id
of -1
instead of the original id. The remote video stream itself does not emit a NotAvailable
event the first time. After the remote participants toggles on/off their video several times, it eventually becomes reliable (all events fire and id
is correct).
This can cause apps to get stuck trying to display the wrong video stream, because no event was fired to indicate the stream is no longer available.
Exception or Stack Trace
Example of logs printed when call is active and remote participant toggles their video. See code snippet for how these are printed.
Note how the first NotAvailable
event has the wrong id
, and the stream itself never emits a NotAvailable
event. Also note how NotAvailable
double-fires from the participant for streams 109 and 110.
ACS Calling iOS participant's stream 105 (hash -2119168352) state changed to Available
ACS Calling iOS remote video stream 105 or 105 (hash -2119168352) state changed to Started
ACS Calling iOS participant's stream 105 (hash -2119168352) state changed to Started
ACS Calling iOS remote video stream 105 or 105 (hash -2119168352) state changed to Stopping
ACS Calling iOS participant's stream 105 (hash -2119168352) state changed to Stopping
ACS Calling iOS participant's stream 105 (hash -2119168352) state changed to Stopped
ACS Calling iOS participant's stream -1 (hash -2119168352) state changed to NotAvailable
ACS Calling iOS participant's stream 109 (hash -2118265456) state changed to Available
ACS Calling iOS remote video stream 109 or 109 (hash -2118265456) state changed to Stopped
ACS Calling iOS participant's stream 109 (hash -2118265456) state changed to NotAvailable
ACS Calling iOS remote video stream 109 or 109 (hash -2118265456) state changed to NotAvailable
ACS Calling iOS participant's stream 109 (hash -2118265456) state changed to NotAvailable
ACS Calling iOS participant's stream 110 (hash -2119665024) state changed to Available
ACS Calling iOS remote video stream 110 or 110 (hash -2119665024) state changed to Stopped
ACS Calling iOS participant's stream 110 (hash -2119665024) state changed to NotAvailable
ACS Calling iOS remote video stream 110 or 110 (hash -2119665024) state changed to NotAvailable
ACS Calling iOS participant's stream 110 (hash -2119665024) state changed to NotAvailable
ACS Calling iOS participant's stream 111 (hash -2118161344) state changed to Available
ACS Calling iOS remote video stream 111 or 111 (hash -2118161344) state changed to Stopped
ACS Calling iOS participant's stream 111 (hash -2118161344) state changed to Stopped
ACS Calling iOS remote video stream 111 or 111 (hash -2118161344) state changed to NotAvailable
ACS Calling iOS participant's stream 111 (hash -2118161344) state changed to NotAvailable
To Reproduce
- Implement
RemoteVideoStreamDelegate
andRemoteParticipantDelegate
. - Assign the delegates accordingly.
- Log state change events when they fire.
- Have the remote participant turn their video on and off.
Code Snippet
Participant delegate:
class MyParticipantDelegate: NSObject, RemoteParticipantDelegate {
func remoteParticipant(_ remoteParticipant: RemoteParticipant, didChangeVideoStreamState args: VideoStreamStateChangedEventArgs) {
os_log(.info, "ACS Calling iOS participant's stream %d (hash %d) state changed to %@", args.stream.id, args.stream.hash, args.stream.state.description)
guard let stream = args.stream as? RemoteVideoStream else {
return
}
// Set up delegate when new streams are added.
if stream.state == .available {
// in real code, we'd need to save a reference to the delegate because of weak reference
stream.delegate = MyRemoteVideoStreamDelegate()
}
}
}
Stream delegate:
class MyRemoteVideoStreamDelegate: NSObject, RemoteVideoStreamDelegate {
func remoteVideoStream(_ remoteVideoStream: RemoteVideoStream, didChangeState args: VideoStreamStateChangedEventArgs) {
os_log(.info, "ACS Calling iOS remote video stream %d or %d (hash %d) state changed to %@", args.stream.id, remoteVideoStream.id, args.stream.hash, args.stream.state.description)
}
}
Expected behavior
id
should never be -1
Screenshots
N/A
Setup (please complete the following information):
- iOS: 16.5
- Xcode: 14.3.1
- AzureCommunicationCalling: 2.4.1
Additional context
N/A
Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- [x] Bug Description Added
- [x] Repro Steps Added
- [x] Setup information Added