Closed Bug 828235 Opened 12 years ago Closed 12 years ago

PeerConnection.localDescription is not correct

Categories

(Core :: WebRTC, defect, P2)

x86
Windows Vista
defect

Tracking

()

RESOLVED INVALID

People

(Reporter: bossiel, Assigned: abr)

Details

(Whiteboard: [WebRTC] [blocking-webrtc-])

Attachments

(1 file)

Attached file test_webrtc.html
User Agent: Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11

Steps to reproduce:

Using FF WebRTC implementation in SIP JS stack but the same issue should happen with any other scenario. I'm just calling PeerConnection::setLocalDescription(sdp) then PeerConnection.localDescription.sdp


Actual results:

The SDP value passed to "setLocalDescription" and the on retrieved from the property "localDescription" are different.
I'm using FF Nightly 21.0a1 (2013-01-08) on Windows Vista and 8.

According to http://www.w3.org/TR/webrtc/: 

The localDescription attribute must return the RTCSessionDescription that was most recently passed to setLocalDescription(), plus any local candidates that have been generated by the ICE Agent since then.
A null object will be returned if the local description has not yet been set.

Attached a HTML file to reproduce the issue: open it then click on "Test answer" button.
Assignee: nobody → adam
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P2
Whiteboard: [WebRTC] [blocking-webrtc-]
Attachment #699683 - Attachment mime type: text/plain → text/html
Reading through the test, the sequence of commands that seems to be producing the output in question read as follows:

> console.info("setLocalDescription:" + desc.sdp);
> o_pc.setLocalDescription(desc);
> console.info("PeerConnection.localDescription:" + (o_pc.localDescription ? o_pc.localDescription.sdp : "null"));

The problem is that the content script is not waiting for setLocalDescription to succeed or fail. Until that happens, the localDescription will not be set.

Imagine, for example, that you're in the middle of a session. The "pc.localDescription" attribute will be set to a valid block of SDP. Then, for whatever reason, the content script calls:

> pc.setLocalDescription({type:"offer",sdp:"Twas brillig, and the slithy toves did gyre and gimble in the wabe: All mimsy were the borogoves, and the mome raths outgrabe."});

Certainly, the pc.localDescription flag isn't updated immediately to reflect this nonsense. The description needs to go through validation for syntactic correctness, semantic validity, and a host of other checks. These checks happen asynchronously. In the example I gave, the error callback (if any) will be invoked, and the localDescription remains unchanged. On the other hand, if the sdp passed in is valid and takes effect, it does so at the same time as the success callback is invoked.

I believe you will find that the following code produces the expected result:

> console.info("setLocalDescription:" + desc.sdp);
> o_pc.setLocalDescription(desc, function() {
>   console.info("PeerConnection.localDescription:" + (o_pc.localDescription ? o_pc.localDescription.sdp : "null"));
> });

You should also include an error callback to detect failures. If my memory serves, the spec will soon require scripts to provide both callbacks in all circumstances.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: