muaz-khan / RTCMultiConnection

RTCMultiConnection is a WebRTC JavaScript library for peer-to-peer applications (screen sharing, audio/video conferencing, file sharing, media streaming etc.)
https://muazkhan.com:9001/
MIT License
2.57k stars 1.37k forks source link

not working on iOS 14 #961

Open ossipoff opened 4 years ago

ossipoff commented 4 years ago

It seems Apple has made some changes in iOS 14 that are not playing nice with RTCMultiConnection.

I have tested all the demos at https://rtcmulticonnection.herokuapp.com/demos/, but none of them are working.

Not entirely sure what the problem is, it doesn't seem like any errors are logged to the console, but the local video stream is never shown and is not sent to the recipient either.

Local audio stream seems to be working, also remote audio and video streams are displayed on the iOS 14 device.

It doesn't seem to be a general problem with getUserMedia or something like that, the following getUserMedia example is working fine: https://webrtc.github.io/samples/src/content/getusermedia/gum/

ricardogobbosouza commented 4 years ago

+1 Same problem

gh264367 commented 4 years ago

I have run into the same problem. It is happening with a number of webrtc type applications. Does any one know of a solution to this problem?

gh264367 commented 4 years ago

Here is something that I found on iOS 14:

Important changes to iOS 14 networking affecting relayed sessions

With iOS 14, Apple introduces local network privacy.

Beginning in iOS 14, the operating system will prompt the user for permission when an application attempts to subscribe to clients on the same local network in a relayed session.

If your application uses a relayed session, it is encouraged to add a descriptive custom usage string to inform the user why the application needs access to their local area network. The Video API uses the local network to discover and connect to video participants on your same network where possible.

If the user does not accept the permission, the attempt to subscribe will fail. After the permission is rejected, any future attempts to subscribe to clients on the same network will also fail unless the user changes the permission in Settings. Unfortunately, iOS does not provide an API for an application to determine if the user has accepted or rejected this permission.

Hopefully this information will help solve for a solution. If someone has one, please post it.

chai2 commented 4 years ago

+1 - having the same problem. I'm able to stream to users but unable to switch cameras on iOS. Any insights how does one go about it?

gh264367 commented 4 years ago

Chai2, are you still able to stream to users using iOS 14? If so, how are you doing it? Can you post something or we can reach out to one another. I have the ability to switch cameras on iPads and iPhones figured out.

chai2 commented 4 years ago

@gh264367 - I just realized I'm on 13.7 and can stream. Let me update to 14.0.1 and see if it still works.

chai2 commented 4 years ago

Nope, just tested it out. And, all I see is a blank screen.

ossipoff commented 4 years ago

@gh264367 I also found a note regarding the ios 14 issue here https://tokbox.com/developer/sdks/ios/release-notes.html it seems as though it is related to peer-to-peer connections. We are using xirsys for stun and turn. I have tried to use turn servers only, but still have the same issue.

gh264367 commented 4 years ago

This seems to be a permission thing with iOS 14 on the local network of the device, from researching for peer to peer in webrtc. Some how you have to ask permission within Safari to connect to the local network of the device.

ossipoff commented 4 years ago

I have done some searching and testing, and found an example of webrtc that actually works on ios 14: https://apprtc.appspot.com/

I found it in the bottom of this list of samples: https://webrtc.github.io/samples/

the source code for it is here: https://github.com/webrtc/apprtc/

it will take some time to rummage through all the source and find out what makes this one work compared to rtcmulticonnection. I probably won't have the time for it in the near future

chai2 commented 4 years ago

Thanks, @ossipoff. I just tried and it works as expected. I will keep looking at where in this repo need to be patched.

chai2 commented 4 years ago

More information if anyone is interested - It's confirmed - related to Local network permissions.

WebRTC - https://bugs.chromium.org/p/webrtc/issues/detail?id=11859 Details info - https://developer.apple.com/videos/play/wwdc2020/10110/

danielehrhardt commented 4 years ago

Same Problem here.

talshimoni commented 4 years ago

Same Problem after upgrade to ios 14

before, on ios 13, project work perfect

altezza04 commented 4 years ago

Twillio is aware of the issues as well, it's seem best to avoid local network at all for ios14 device

https://support.twilio.com/hc/en-us/articles/360053909533-Important-Changes-in-iOS-14-for-Twilio-Video-P2P-Rooms

ossipoff commented 4 years ago

@altezza04 do you have an idea of how to avoid the local network in rtcmulticonnection? I have tried only using turn servers, but that didn't work. I am no expert in webrtc, but I guess it has to do with the way it is handling ICE candidates

altezza04 commented 4 years ago

@altezza04 do you have an idea of how to avoid the local network in rtcmulticonnection? I have tried only using turn servers, but that didn't work. I am no expert in webrtc, but I guess it has to do with the way it is handling ICE candidates

no idea actually, may need some way to forcing a relayed connection in Peer-to-Peer Rooms to avoid using the local network.

fmangat commented 4 years ago

Any solutions so far?

fmangat commented 4 years ago

GUYS, I found the solution to it

fmangat commented 4 years ago

the problem is in getRMCMediaElement function.

comment out

mediaElement.srcObject = stream;

this line and it will work. the reason might be is that you cant create more than 1 media element with local stream

fmangat commented 4 years ago

maybe someone can come with a much cleaner approach

ossipoff commented 4 years ago

@fmangat , that sounds great! I will try it out

ossipoff commented 4 years ago

I found that setting the autoCreateMediaElement property to false on the connection object also works

rezashnia1234 commented 3 years ago

I have the same problem.