Occasionally our WebRTC page running on Safari/iOS 15.5 will do ICE-gathering and find 4+ IPv6 or private-IPv4 candidates (which aren't useful for our service) but then will find a relay candidate and pass it to our onicecandidate, where we log it, yet immediately afterwards the localDescription of the peer object will not contain the final, usable candidate. Our telephony server doesn't support receiving one candidate at a time, so we need to send the localDescription, and we'd strongly prefer to do that as soon as there is a usable candidate. I would expect that every candidate would be inserted into the pendingLocalDescription before being passed into onicecandidate, but I couldn't find any discussion of this at https://w3c.github.io/webrtc-pc/#dom-peerconnection-localdescription I'm filing this bug because I suspect you will agree that pendingLocalDescription should be updated first. Also, there seems to be a race condition because we do not see this behavior every time.
We update the descriptions just before firing the icecandidate event. Do you have more information on how I could reproduce this?
I've observed the problem once in logs for a session by one of our engineers in Germany using home wifi, and he's had success many other times, so replication seems difficult. In the problem session, there were 2+ IPv6 and 2+ private-IPv4 host candidates before the relay was found. The relay appeared about a second after ice-gathering began.
<rdar://problem/97051379>