Unity-Technologies / Unity-Technologies/com.unity.webrtc
[BUG] Ice candidates sent before Answer/Offer
@karasusan is already working on this.
Since Mar 24, 2021.
- Dominant language
- Assembly
- Stars
- 852
- Forks
- 238
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I am trying to implement WebRTC communication between my web implementation (JavaScript) and Unity, but I encounter a problem.
Sometimes, when I try to send an offer or an answer on Unity side, it sends Ice candidate before sending the offer or the answer.
I'll take the answer as an example:
- I do SetRemoteDescription
- I do CreateAnswer
- I do SetLocalDescription
- Some Ice candidates are sent
- I send the answer through signaling server
I don't know why, but before the end of SetLocalDescription coroutine, Ice candidates are send through OnIceCandidate callback of PeerConnection, creating an error on my web side (No remote description error, because the answer hasn't been received).
For information, I've got no problem on a web <-> web communication, neither on Unity <-> Unity communication, only web <-> Unity
Here is a snippet of my Unity code when it receives an offer and it needs to create an answer, maybe there is something I do wrong (I've removed all the error verifications to simplify, but I've verified and there is no error that appear):
private IEnumerator CreateAnswer(string _sdp)
{
RTCSessionDescription sessionDesc = new RTCSessionDescription
{
type = RTCSdpType.Offer,
sdp = _sdp
};
RTCSetSessionDescriptionAsyncOperation remoteDescOp = peerConnection.SetRemoteDescription(ref sessionDesc);
yield return remoteDescOp;
RTCSessionDescriptionAsyncOperation answerOp = peerConnection.CreateAnswer(ref answerOptions);
yield return answerOp;
RTCSessionDescription desc = answerOp.Desc;
RTCSetSessionDescriptionAsyncOperation localDescOp = peerConnection.SetLocalDescription(ref desc);
yield return localDescOp; // Ice candidates have been sent before the end of localDescOp
SignalingServer.Send(desc.sdp);
}
Thank you,
Kevin
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.