webrtc / KITE

KITE is a test engine designed to test WebRTC interoperability across browsers
Apache License 2.0
468 stars 126 forks source link

computePacketLoss appear when I try to get WebRTC Stats via getStats ? #98

Closed valdrinnz closed 4 years ago

valdrinnz commented 4 years ago

I have written below scripts and I get this computePacketLoss:

GetStatsStep: `const {TestUtils, TestStep, Status, KiteTestError} = require('kite-common');

class GetStatsStep extends TestStep { constructor(kiteBaseTest) { super(); this.driver = kiteBaseTest.driver; this.statsCollectionTime = kiteBaseTest.statsCollectionTime; this.statsCollectionInterval = kiteBaseTest.statsCollectionInterval; this.selectedStats = kiteBaseTest.selectedStats; this.page = kiteBaseTest.page; this.peerConnections = kiteBaseTest.peerConnections;

// Test reporter if you want to add attachment(s)
this.testReporter = kiteBaseTest.reporter;

}

stepDescription() { return 'Getting WebRTC stats via getStats'; }

async step() { try { let rawStats = await this.page.getStats(this); let summaryStats = TestUtils.extractJson(rawStats, 'both'); // // Data this.testReporter.textAttachment(this.report, 'GetStatsRaw', JSON.stringify(rawStats, null, 4), "json"); this.testReporter.textAttachment(this.report, 'GetStatsSummary', JSON.stringify(summaryStats, null, 4), "json"); } catch (error) { console.log(error); throw new KiteTestError(Status.BROKEN, "Failed to getStats"); } } }

module.exports = GetStatsStep;`

In my web app console peerConnections are appearing here: image

In main page: `const getPeerConnectionScript = function() { return "window.peerConnections = peerConnections[0];";

async getStats(stepInfo) { await stepInfo.driver.executeScript(getPeerConnectionScript()); let stats = await TestUtils.getStats(stepInfo, 'kite', stepInfo.peerConnections[0]); return stats; } }`

config file: "getStats" : { "enabled": true, "statsCollectionTime": 2, "statsCollectionInterval": 1, "peerConnections": ["window.peerConnections[0];"], "selectedStats": [ "inbound-rtp", "outbound-rtp", "candidate-pair" , "ontrack"] },

testScript: if (this.getStats) { let getStatsStep = new GetStatsStep(this); await getStatsStep.execute(this); }

In my console there is this message: image

In allure report: image

How is possible to fix computePacketLoss ?

namvuCosmo commented 4 years ago

Hello,

I'm sorry but we currently don't have the capacity to maintain our JS libraries. But thanks for your post, we will investigate this in the future.

valdrinnz commented 4 years ago

Hello, namvu

Thank you for your response, already fixed it. In mainpage, I changed getPeerConnectionScript function: `const getPeerConnectionScript = function() { return "window.pc = [];"

And now WebRTC Stats are coming.

namvuCosmo commented 4 years ago

Cool!

So initially the window.peerConnections was a map, not an [ ], I guess if you put window.peerConnections[0].peerConnection instead of window.peerConnections[0] it might have worked as well.

valdrinnz commented 4 years ago

Yes that works too.