Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Gecko Bug 1457129] Correct WebRTC getStats WPT to wait for remote stats before comparing #13942

Merged
merged 1 commit into from
Nov 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions webrtc/RTCPeerConnection-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,19 @@ function createDataChannelPair(
});
}

// Wait for RTP and RTCP stats to arrive
async function waitForRtpAndRtcpStats(pc) {
while (true) {
const report = await pc.getStats();
const stats = [...report.values()].filter(({type}) => type.endsWith("bound-rtp"));
// Each RTP and RTCP stat has a reference
// to the matching stat in the other direction
if (stats.length && stats.every(({localId, remoteId}) => localId || remoteId)) {
break;
}
}
}

// Wait for a single message event and return
// a promise that resolve when the event fires
function awaitMessage(channel) {
Expand Down
10 changes: 10 additions & 0 deletions webrtc/RTCPeerConnection-track-stats.https.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!doctype html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>RTCPeerConnection.prototype.getStats</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
Expand All @@ -12,6 +13,7 @@
// The following helper functions are called from RTCPeerConnection-helper.js:
// doSignalingHandshake
// getUserMediaTracksAndStreams
// waitForRtpAndRtcpStats

// The following helper functions are called from RTCStats-helper.js
// (depends on dictionary-helper.js):
Expand Down Expand Up @@ -504,6 +506,10 @@
await doSignalingHandshake(caller, callee);
await onIceConnectionStateCompleted(caller);

// Wait until RTCP has arrived so that it can not arrive between
// the two get stats calls.
await waitForRtpAndRtcpStats(caller);

let senderReport = await sender.getStats();
let trackReport = await caller.getStats(sender.track);

Expand Down Expand Up @@ -532,6 +538,10 @@
await onIceConnectionStateCompleted(caller);
let receiver = caller.getReceivers()[0];

// Wait until RTCP has arrived so that it can not arrive between
// the two get stats calls.
await waitForRtpAndRtcpStats(caller);

let receiverReport = await receiver.getStats();
let trackReport = await caller.getStats(receiver.track);

Expand Down