Bug 209594 - Unplugging headphones causes remote media to fail/freeze in iOS 13.4
Summary: Unplugging headphones causes remote media to fail/freeze in iOS 13.4
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: Safari 13
Hardware: iPhone / iPad iOS 13
: P2 Major
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-03-26 05:55 PDT by daginge
Modified: 2020-12-08 02:19 PST (History)
10 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description daginge 2020-03-26 05:55:09 PDT
Unplugging headphones while in a call will break the remote media stream, causing the video to freeze to freeze and no audio output.

Steps to reproduce:
0. Plug in headphones, I'm using an iPad Pro running 13.4
1. Go to https://webrtc.github.io/samples/src/content/peerconnection/pc1/
2. Start a call and verify you can see yourself twice
3. Unplug headphones
4. Verify that remote video has now frozen. If you isolate sound you will also hear that audio disappeared.

Impact:
A lot of users are already quite confused with audio issues, and can sometimes plug/unplug headphones. Since this causes the far end's media to disappear the call will fail when they do so. To make matters worse, THEIR audio/video stream is still transmitting.

Possible workaround:
It seems at least tearing down the peerconnection and starting a new one fixes it. I'll try to see if a simple restart will do.
Comment 1 daginge 2020-03-26 06:02:24 PDT
Strangely, while Confrere and Basic Peer Connection Demo breaks every time for me, the restart ICE demo does not: https://webrtc.github.io/samples/src/content/peerconnection/restart-ice/. Could this be because of the muted property and autoplay?
Comment 2 daginge 2020-03-26 06:08:56 PDT
Confirmed. If the video elements muted property is true, the remote video does not fail when unplugging the headphones. Smells like autoplay.
Comment 3 daginge 2020-03-26 06:15:36 PDT
Found a better workaround.

videoElem.addEventListener("pause", () => { videoElem.play() })
Comment 4 Radar WebKit Bug Importer 2020-03-26 10:25:35 PDT
<rdar://problem/60924958>
Comment 5 youenn fablet 2020-12-08 02:19:33 PST
Until we try to improve our heuristics, there are some alternatives that might help:
1. Make sure to call play() for each video element as part of click a event. This will remove the autoplay restrictions. Suspend/resume should then work fine.

2. Register a pause event handler. When pause is set and play rejects, mute the media elements and call play. This should allow seeing the video tracks. Add some UI to ask users to play audio/unmute audio. User will click, you can then unmute the elements/call play on all elements.

3. For multi party calls where capture is not on, you might want to keep a buffer of html media elements. On click event, call play on all of these media elements. They do not need to be set to a given src. When you have some media stream to attach, set srcObject and you should be good.