Skip to content

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

@kirsle

Description

@kirsle

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions