Skip to content

Commit

Permalink
Bug 1555016 [wpt PR 17046] - webrtc wpt: avoid race conditions, a=tes…
Browse files Browse the repository at this point in the history
…tonly

Automatic update from web-platform-tests
webrtc wpt: avoid race conditions

Avoids race conditions by first setting the remote description before setting the local description.
ICE will only start checking (and generating candidates) after SLD.
Also avoids the case that candidates arrive before a remote description is set since its always set first.

BUG=960718

Change-Id: I38e69f625c8aba82711422812fc9634af647d056
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1632470
Commit-Queue: Philipp Hancke <philipp.hancke@googlemail.com>
Reviewed-by: Harald Alvestrand <hta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663871}

--

wp5At-commits: cad28d27af3f3a927ce181ddd1d23b557faabcfc
wpt-pr: 17046
  • Loading branch information
fippo authored and jgraham committed Jun 19, 2019
1 parent e396924 commit d075414
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions testing/web-platform/tests/webrtc/RTCPeerConnection-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,25 +222,29 @@ function coupleIceCandidates(pc1, pc2) {
}

// Helper function for doing one round of offer/answer exchange
// between two local peer connections
// between two local peer connections.
// Calls setRemoteDescription(offer/answer) before
// setLocalDescription(offer/answer) to ensure the remote description
// is set and candidates can be added before the local peer connection
// starts generating candidates and ICE checks.
async function doSignalingHandshake(localPc, remotePc, options={}) {
let offer = await localPc.createOffer();
// Modify offer if callback has been provided
if (options.modifyOffer) {
offer = await options.modifyOffer(offer);
}

// Apply offer
await localPc.setLocalDescription(offer);
// Apply offer.
await remotePc.setRemoteDescription(offer);
await localPc.setLocalDescription(offer);

let answer = await remotePc.createAnswer();
// Modify answer if callback has been provided
if (options.modifyAnswer) {
answer = await options.modifyAnswer(answer);
}

// Apply answer. Note: localPc should enter stable state first.
// Apply answer.
await localPc.setRemoteDescription(answer);
await remotePc.setLocalDescription(answer);
}
Expand Down

0 comments on commit d075414

Please sign in to comment.