adapter icon indicating copy to clipboard operation
adapter copied to clipboard

shimAddIceCandidateNullOrEmpty fails on Safari 17.0

Open thewildtree opened this issue 1 year ago • 3 comments

  • [x] I have provided steps to reproduce (e.g. a link to a jsfiddle)
  • [x] I have provided browser name, version and adapter.js version
  • [x] This issue only happens when adapter.js is used

Versions affected

Browser name including version (e.g. Chrome 64.0.3282.119)

Safari 17.0 (19616.1.27.111.16)

adapter.js (e.g. 6.1.0)

All versions >=8.0.0

Description

The shimAddIceCandidateNullOrEmpty step fails on Safari. This particular check breaks (len==0): https://github.com/webrtcHacks/adapter/blob/28c9f9471cb3df75cbb978c6f840e3315731790f/release/adapter.js#L1480-L1482

Causing this API to not be replaced correctly. This breaks the empty-candidate scenario, causing an error to be thrown.

Steps to reproduce

  1. Insert https://webrtc.github.io/adapter/adapter-latest.js into your site (via
  2. Insert debugger breakpoint at line mentioned above
  3. See shim failing to be correctly applied.

We encountered this bug when testing https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/tree/main/net/webrtc/gstwebrtc-api on Safari, where we depend on the empty-candidate scenario to work correctly.

Note: when pausing with the debugger and refreshing right after, it sometimes actually passes that check and the shim works correctly, once in 20 tries I'd say. Might be a Safari bug for all it's worth.

Expected results

The addIceCandidate is correctly modified to have Safari handle the empty candidate scenario fine.

Actual results

addIceCandidate is not modified, causing Safari to throw an error when encountering an empty candidate string.

thewildtree avatar Sep 29 '23 16:09 thewildtree

Also tested on Safari on iOS 17 - same thing happens.

thewildtree avatar Sep 29 '23 16:09 thewildtree

@youennf that seems like a regression?

fippo avatar Sep 29 '23 16:09 fippo

To maybe speed things up - this is almost certainly a Safari bug.

As it is right now, window.RTCPeerConnection.prototype.addIceCandidate has length: 0, name: "addIceCandidate".

When I add a 3s delay before calling shimAddIceCandidateNullOrEmpty, about 80% of the time a different function appears with length: 3, name: "withCallback" and the shim is correctly applied. It's inconsistent though, no matter how long the delay is, sometimes the signature is just incorrect anyway.

Any ideas on how to proceed with this?

thewildtree avatar Oct 30 '23 15:10 thewildtree