Closed Bug 834153 Opened 11 years ago Closed 11 years ago

Queue CreateAnswer in PC.js

Categories

(Core :: WebRTC: Signaling, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla21

People

(Reporter: ekr, Assigned: abr)

Details

(Whiteboard: [webrtc][blocking-webrtc+][qa-])

Attachments

(2 files, 4 obsolete files)

Currently, PeerConnection.js examines remoteDescription which transitively
calls PCImpl::remotedescription

  createAnswer: function(onSuccess, onError, constraints, provisional) {
    if (!this.remoteDescription) {
      throw new Error("setRemoteDescription not called");
    }

    if (this.remoteDescription.type != "offer") {
      throw new Error("No outstanding offer");
    }

    if (!constraints) {
      constraints = {};
    }

  ...

    // TODO: Implement provisional answer.
    this._queueOrRun({
      func: this._pc.createAnswer,
      args: [constraints],
      wait: true
    });


There is a race condition here because SetRemoteDescription is queued
pending SIPCC and ICE readiness but the check of this.remoteDescription
is not queued. If you lose the aces, then either:

(a) the ICE state check in GetRemoteDescription fails
(b) An empty string is returned at which point this exception is
thrown.

Either one causes problems.
Assignee: nobody → adam
Status: NEW → ASSIGNED
Whiteboard: [webrtc][blocking-webrtc+]
Attached patch Queue CreateAnswer State Checks (obsolete) — Splinter Review
Attached patch Queue CreateAnswer State Checks (obsolete) — Splinter Review
Attachment #705892 - Attachment is obsolete: true
Attachment #705894 - Flags: review?(ekr)
Comment on attachment 705894 [details] [diff] [review]
Queue CreateAnswer State Checks

Review of attachment 705894 [details] [diff] [review]:
-----------------------------------------------------------------

lgtm but hold off on committing till I hjave tested it in the case that fails.
Attachment #705894 - Flags: review?(ekr) → review+
Attached patch Queue CreateAnswer State Checks (obsolete) — Splinter Review
Attachment #705894 - Attachment is obsolete: true
Comment on attachment 705919 [details] [diff] [review]
Queue CreateAnswer State Checks

Rebasing on m-i tip. Carrying forward r+ from ekr
Attachment #705919 - Flags: review+
Attached patch Mochi testSplinter Review
Attachment #705950 - Flags: review?(ekr)
Comment on attachment 705950 [details] [diff] [review]
Mochi test

Review of attachment 705950 [details] [diff] [review]:
-----------------------------------------------------------------

lgtm but with proposed nits.

::: dom/media/tests/mochitest/test_peerConnection_bug834153.html
@@ +16,5 @@
> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=834153">Queue CreateAnswer in PeerConnection.js</a>
> +<p id="display"></p>
> +<pre id="test">
> +<script class="testbody" type="application/javascript">
> +function croak(msg) {

Could this be moved into pc.js or some other common code.

@@ +29,5 @@
> +  ok(pc1, "pc1 is non-null");
> +
> +  pc1.createOffer(
> +    function(d) {
> +      pc2 = new mozRTCPeerConnection();

Shouldn't there be a var somewhere? this is being hoisted into global scope.
Attachment #705950 - Flags: review?(ekr) → review+
Attached patch Queue CreateAnswer State Checks (obsolete) — Splinter Review
Attachment #705919 - Attachment is obsolete: true
Comment on attachment 706172 [details] [diff] [review]
Queue CreateAnswer State Checks

Review of attachment 706172 [details] [diff] [review]:
-----------------------------------------------------------------

The problem with Adam's initial patch was that we were cranking executeNext out of non-callback events (e.g.. pc.onaddstream).

This means that if you, for instance, call setRemoteDescription() and createAnswer(), then createAnswer() can get invoked on PCImpl out of pc.onaddstream(), which you don't want.
Attachment #706172 - Flags: review?(rjesup)
Attachment #706172 - Flags: review?(adam)
Attachment #706172 - Attachment is obsolete: true
Attachment #706172 - Flags: review?(rjesup)
Attachment #706172 - Flags: review?(adam)
Comment on attachment 706240 [details] [diff] [review]
Queue CreateAnswer State Checks, remove extraneous _executeNext calls

This patch removes some additional extraneous calls to _executeNext, on top of the ones EKR already identified as problematic. The changes pass mochi locally, although I haven't formulated any specific test cases to test the kinds of sequencing that would make this problem show up.

Given the relative urgency of landing this patch, I'd be inclined to push rigorous sequencing testing off onto another bug.
Attachment #706240 - Flags: review?(rjesup)
Attachment #706240 - Flags: review?(ekr)
Comment on attachment 706240 [details] [diff] [review]
Queue CreateAnswer State Checks, remove extraneous _executeNext calls

Review of attachment 706240 [details] [diff] [review]:
-----------------------------------------------------------------

lgtm
Attachment #706240 - Flags: review?(ekr) → review+
Attachment #706240 - Flags: review?(rjesup) → review+
Attachment #705950 - Flags: checkin+
Attachment #706240 - Flags: checkin+
https://hg.mozilla.org/mozilla-central/rev/e4e3590aa1da
https://hg.mozilla.org/mozilla-central/rev/5a2c4f450e07
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla21
Whiteboard: [webrtc][blocking-webrtc+] → [webrtc][blocking-webrtc+][qa-]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: