Bug 1457129 - Correct WebRTC getStats WPT to wait for remote stats before comparing r=jib

If care is not taken to wait for remote stats on senders and receivers, then the contents
of the stats reports will not be stable. Waiting for this stability should fix our
intermittent failures checking that RTCRtpSender/Receiver.getStats() returns the
same dictionaries that RTCPeerConnection.getStats(sender/receiver.track) does.

Differential Revision: https://phabricator.services.mozilla.com/D5804

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nico Grunbaum 2018-11-01 22:04:14 +00:00
Родитель 3986ef8afc
Коммит 45e7971579
3 изменённых файлов: 29 добавлений и 4 удалений

Просмотреть файл

@ -405074,7 +405074,9 @@
"webrtc/RTCPeerConnection-track-stats.https.html": [
[
"/webrtc/RTCPeerConnection-track-stats.https.html",
{}
{
"timeout": "long"
}
]
],
"webrtc/RTCPeerConnection-transceivers.https.html": [
@ -657645,7 +657647,7 @@
"support"
],
"tools/wptrunner/wptrunner/testrunner.py": [
"7e386b881d4c83a93d2543b7e5b9afd01623a5bc",
"90f7e4615e078840f9804f791422f9f2f3464a72",
"support"
],
"tools/wptrunner/wptrunner/tests/__init__.py": [
@ -663673,7 +663675,7 @@
"testharness"
],
"webrtc/RTCPeerConnection-helper.js": [
"27ff1873790cfc4f71a07e1735ec4389ee330a18",
"1d740f00d1a8fab386bc7fdae2b94faa52824e70",
"support"
],
"webrtc/RTCPeerConnection-iceConnectionState.html": [
@ -663757,7 +663759,7 @@
"testharness"
],
"webrtc/RTCPeerConnection-track-stats.https.html": [
"682e7e57e465ccde77c3d8887ce80cb5ea01bf54",
"4b610b474a61a291798ff8258fb5edc423d44cb7",
"testharness"
],
"webrtc/RTCPeerConnection-transceivers.https.html": [

Просмотреть файл

@ -281,6 +281,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) {

Просмотреть файл

@ -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>
@ -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):
@ -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);
@ -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);