Unity3dAsyncAwaitUtil icon indicating copy to clipboard operation
Unity3dAsyncAwaitUtil copied to clipboard

Integration problem with Unity WebRTC

Open yrucrem opened this issue 5 years ago • 0 comments
trafficstars

Hello everyone!

I am having trouble using await with a method from the Unity WebRTC implementation (I am using version 2.2.0-preview). Most methods which are supposed to be called in a coroutine seem to be working fine, but RTCPeerConnection.CreateAnswer() returns null when I use await.

What I am doing is roughly this:

// WebRTC.Initialize() is already called
// The remoteDescription comes from my signaling server

this.localConnection = new RTCPeerConnection(ref rtcConfig);
await localConnection.SetRemoteDescription(ref remoteDescription);

var answerOptions = new RTCAnswerOptions { iceRestart = false };
var answer = await localConnection.CreateAnswer(ref answerOptions);

// After this answer == null

When I call CreateAnswer() inside a Coroutine, I get a RTCSessionDescription description as expected.

var answerOptions = new RTCAnswerOptions { iceRestart = false };
var answer = localConnection.CreateAnswer(ref answerOptions);

yield return answer;

// After the yield, anser is *not* null and contains a session description in answer.Desc

The return value of RTCPeerConnection.CreateAnswer is a RTCSessionDescriptionAsyncOperation.

Do I need a special Awaiter here that is not covered by IEnumeratorAwaitExtensions?

Any tipps and hints in the right direction would be greatly appreciated!

Thanks in advance for any insights you could provide on this issue and best regards, Patrick

yrucrem avatar Oct 30 '20 21:10 yrucrem