Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safari and iPads require Promise-based API for WebRTC #25

Open
kirsle opened this issue Aug 31, 2023 · 0 comments
Open

Safari and iPads require Promise-based API for WebRTC #25

kirsle opened this issue Aug 31, 2023 · 0 comments

Comments

@kirsle
Copy link

kirsle commented Aug 31, 2023

I'm posting this here in hopes it'll be useful to others. This project seems old and not updated anymore.

I built a chat room and referenced this code, and it worked fine in Firefox/Chromium on everything except for iPads or Safari browsers. I've made some progress in resolving why.

The most important change needed is that Safari only supports the modern Promise-based syntax for the WebRTC APIs whereas this project is using callbacks.

e.g.: instead of setLocalDescription(desc, onSuccess, onFailure) change those to setLocalDescription(desc).then(onSuccess).catch(onFailure) and Safari makes more progress.

Symptoms I noticed (my logic was closely inspired by this webrtc demo's, so this is probably true of this project still too):

  • When the offerer begins to connect, it should send SDP messages first and then send candidates.
  • However, iPad was sending candidates first and never SDP messages.
  • The recipient of those candidates (Firefox) would throw an error that candidates can't be added with no remoteDescription set.

The culprit was: the sendOffer() and then setLocalDescription logic was failing on Safari and the SDP message was not being sent. Firefox and Chrome supported the legacy APIs and worked OK, but Safari, being later to the WebRTC bandwagon, only opted to support the Promise-based APIs.

I also found this web page to be a valuable resource: https://webrtchacks.com/guide-to-safari-webrtc/

An important aspect of iPad is they seem to not support send-only or receive-only channels: it needs to be a bidirectional video call. I think this webrtc demo should be doing that OK: on the initial offer the iPad needs to attach their own local video channel to the call to begin with, and receive video from the answerer and then all works OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant