Bug 239882

Summary: SDP transceivers bug sending tracks asynchronously between peers
Product: WebKit Reporter: matías lópez <mlopez>
Component: WebRTCAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Major CC: webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: Safari 15   
Hardware: iPhone / iPad   
OS: iOS 15   

matías lópez
Reported 2022-04-28 18:45:10 PDT
> More info in this repo: https://github.com/videsk/safari-webrtc-bug The context is when trying to send tracks between peers async. That means sending tracks from peer 1 and when complete the signaling process to "stable", sending the tracks to peer 2. ``` new => have-local-offer => stable => have-remote-offer => stable ``` The bug only happens when peer 1 is any browser in any OS except iOS and the second one Safari/Firefox/Chrome on iOS, and send tracks async. >>> How to reproduce it 1. Get user media with audio and video 2. Create RTCPeerconnection on both peers following the perfect negotiation (https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Perfect_negotiation). 3. Execute "peer1.addTrack(track, cameraStream);" 4. Wait to receive the tracks of peer1 on peer2 5. Add mute/unmute listener to both track "track.addEventListener('mute', event => console.log(event.track.kind, 'muted', event));" and "track.addEventListener('unmute', event => console.log(event.track.kind, 'unmuted', event));" 6. Execute "peer2.addTrack(track, stream);" 7. Expect receive tracks **muted** Point 7 is where weird things happen. You will receive the tracks as muted, only before transceivers exchange and the direction of RTCRtpSender and RTCRtpReceiver will be "recvonly". After transceivers, the tracks will be changed to unmuted, and both transceivers `RTCRtpTransceiver` will change direction value to "sendrecv", but the tracks are still empty (no audio, no video). A human-readable example is the case when Alice calls Bob. Previous to Bob answering the call we show a preview of Alice's camera, when Bob answer we send the Bob tracks. That use case could be complex if you don't create a new RTCPeerconnection on Alice and Bob, that means starting the signaling process again, which is inefficient.
Attachments
Radar WebKit Bug Importer
Comment 1 2022-05-05 18:46:13 PDT
youenn fablet
Comment 2 2022-05-06 00:55:42 PDT
(In reply to mlopez from comment #0) > > More info in this repo: https://github.com/videsk/safari-webrtc-bug > > The context is when trying to send tracks between peers async. That means > sending tracks from peer 1 and when complete the signaling process to > "stable", sending the tracks to peer 2. > > ``` > new => have-local-offer => stable => have-remote-offer => stable > ``` > > The bug only happens when peer 1 is any browser in any OS except iOS and the > second one Safari/Firefox/Chrome on iOS, and send tracks async. > > > >>> How to reproduce it > > 1. Get user media with audio and video > > 2. Create RTCPeerconnection on both peers following the perfect negotiation > (https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/ > Perfect_negotiation). Perfect negotiation is a technique, which can be implemented in various ways. Do you have a live example where this can be reproed? Or the exact javascript you use on both side to implement perfect negotiation? For instance, a single page fiddle https://jsfiddle.net/wo7mny9p/ works fine for me on both macOS and iOS. Are you saying the above fiddle run one one side on iOS and on the other side on maCOS would not work? Could you provide a sysdiagnose (youenn@apple.com)?
matías lópez
Comment 3 2022-05-06 10:08:17 PDT
I tested with the same code in fiddle but forked to Codesandbox for easier debugging on iOS. Also, I extract the transceivers on SDP. https://codesandbox.io/s/webkit-transceivers-bug-vd87mv?file=/main.js Here is a video on iOS 15.2 (Real device): https://youtube.com/shorts/NwxbHWc_iO8?feature=share Tests on macOS and iOS simulators: - iOS 15 (fails): https://drive.google.com/file/d/14vIYJaAXZURsYYyP2gRBYjfkGfM87llo/view?usp=sharing - iOS 15.2 (fails): https://drive.google.com/file/d/1s66CHvu10rdjULueHpHoKWpEyi5kTvVW/view?usp=sharing - macOS Monterrey Safari 15 (fails): https://drive.google.com/file/d/1ZZbwB5_NL71uIty9C8XoBxAQMWy1q_Or/view?usp=sharing - macOS Big Sur Safari 14 (works): https://drive.google.com/file/d/1Q1-iV38iW8is4IIx2Eb_iS4vik8J6JWl/view?usp=sharing
youenn fablet
Comment 4 2022-05-11 05:55:08 PDT
Trying locally on macOS 12.3, this works for me. Can you try it there or with Safari Tech Preview?
matías lópez
Comment 5 2022-05-18 20:36:50 PDT
Works in Safari Tech Preview 15.4 (Webkit 16614.1.11.6)!
Note You need to log in before you can comment on or make changes to this bug.