Consumer ConnectionStateChange not getting called on Safari

Hi Team,

I am having problems while consuming the stream on Safari browser, the usecase is basically one to many broadcasting. The producer’s stream is a simulcast stream with three different encodings. Consumers get this stream when they are on google chrome browser. But when the consumers are on safari browser deviceRecvTransport.on(connectionstatechange) never gets called. I am not sure what i am doing wrong. Below is the code snippet of consumer’s side.

Safari Browser Version – 13.0.4
MacOS - 10.13.6

Thanks in Advance
Amit M

Extremely hard to help. Check ICE connection changes in server side for those transports, enable ICE and DTLS logs in server, etc.

Hi,

I just checked the ICE connection changes and DTLS changes of the transport on server, It is clearly visible the ice connection changes from connectedcompleted and also DTLS changes to connectingconnected.

I am not sure why the recvTransport.on(‘connectionstatechange’) on mediasoup client is not getting called. Also when i produce from same safari browser connectionstatechange listener gets called on sendTransport. is this issue due to not producing any tracks on consumer’s transport on safari browser?

Any help here is much appreciated.

  • If you don’t produce() anything in a sendTransport, the sendTransport will not even start ICE+DTLS connection.
  • If you don’t consume() anything in a recvTransport, the recvTransport will not even start ICE+DTLS connection.

That’s how a PeerConnection works.

Yes, That’s the point. If the ice state and dtls states are getting changed on the server correctly, does it not mean the transport.consume() method has already been called on the client side?

I am sure that i am consuming the video/audio producers. Also If i do not check the connectionstatechange but have a setTimeout in place to render the remote mediastream of the producer in video tag after a few seconds calling the recvTransport.consume(), i am able to see the stream of the producer.

Honestly I don’t know how to help. I’ve tested it locally in the mediasoup-demo app and it works fine in Safari:

I just enabled mediasoup client logs in my client application. I am attaching the screenshot of logs from chrome and safari for ice connection state changes.

Chrome Browser logs, where after consume() being called, descriptions are set and icestate change happened successfully.

Safari Browser logs, where after consume() being called, descriptions are set but icestate change never happened.

You are not specifying which Safari version. Does the online mediasoup-demo work for you?

Safari Browser Version – 13.0.4
MacOS - 10.13.6

Yes, i tested the demo app hosted on https://demo.mediasoup.org, It works perfectly fine.
My only concern is that, the server side transport’s connection state change is visible. But the clients side connection state changes are not happening at all. I do not even know what to debug here, cause we call the mediasoup client api and the api manages the peerconnection.

I would request you to suggest me something over here.

But I shown you above that the event is fired in Safari side using the demo.

Yes, i totally agree to what you had shown. As of now i am using mediasoup-client version 3.2.0. I will switch to the latest version and will see if that works for me.

Thanks alot for all the quick responses you give us on the forum. I will get back to you after testing with latest mediasoup-client.

BTW I’ve Safari version 13.1 (14609.1.20.111.8) in OSX Mojave.

I suggest forking the mediasoup-demo, adding those event listeners and see (which is what I did).

Hi,

I updated the safari browser from 13.0.4 to 13.1
Now the connectionstatechange is getting called. Seems like the issue is with safari version 13.0.4

Thanks for your kind replies.

1 Like

Hi,

Just an update here… Safari has a different kind of auto-play policy than chrome. If we just want to subscribe to a stream without producing audio/video. The stream would not playback by itself. Therefore it is necessary to call getusermedia and allow the access atleast to mic, by giving permission to mic the stream starts to play.