New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 639766 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Last visit > 30 days ago
Closed: Sep 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

WebRTC stats Bug - inside a callback function

Reported by giuliota...@gmail.com, Aug 22 2016

Issue description

Chrome Version       : 52.0.2743.116 (Official Build) (64-bit)
URLs (if applicable) : https://webrtc.github.io/samples/src/content/peerconnection/pc1/

The function inside a peerConnection (in the example below is "pc1") that gives stats about the webRTC call seems to not work normally.
It is impossible to have stats inside a callback function. 

What steps will reproduce the problem?
(1) Go to this link https://webrtc.github.io/samples/src/content/peerconnection/pc1/ and start a call.
(1) Open the console.
(2) Declare these variables: "let RTCStatsReports, elem;".
(3) Run this code 

pc1.getStats(res => { 
  RTCStatsReports = res.result();
  for (elem of RTCStatsReports) {
    if (elem.id === 'bweforvideo') {
      console.log('found the right element');
      elem.stat("googActualEncBitrate", function(res){
        console.log('Result A: ', res); //This line is never printed
      });
      break;
    }
  }
});

And I never see the result of "console.log('Result A: ', res);" 

(4) But if I run this code the result is printed

elem.stat("googActualEncBitrate", function(res){
  console.log('Result B: ', res); //This line is never printed
});


What is the expected result?
Some value from the chrome://webrtc-internals/ stats like "300000".

What happens instead?
The callback inside "elem.stat" is never fired.


 
Screen Shot 2016-08-22 at 10.30.23.png
555 KB View Download
Components: Blink>WebRTC>Tools
Cc: tkonch...@chromium.org
Labels: Needs-Feedback
Tested the same on mac 10.11.6 chrome version 52.0.2743.116 and canary - None of the results A or B is displayed instead an error is displayed as shown in the screenshot.

Could you please let us know if i am missing something in reproducing the issue.
Screen Shot 2016-08-24 at 2.25.57 PM.png
930 KB View Download
I think you forgot to press the "call" button, before pasting the code.

N.B.
You have to press
1 - Start button
2 - Call button
3 - Paste the code
Project Member

Comment 4 by sheriffbot@chromium.org, Aug 31 2016

Labels: -Needs-Feedback Needs-Review
Owner: tkonch...@chromium.org
Thank you for providing more feedback. Adding requester "tkonchada@chromium.org" for another review and adding "Needs-Review" label for tracking.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Status: WontFix (was: Unconfirmed)
giuliotani29@ where have you gotten information on that RTCStatsReport.stat() method should accept a 2nd parameter?

Just request the stat directly:
pc1.getStats(res => { 
  RTCStatsReports = res.result();
  for (elem of RTCStatsReports) {
    if (elem.id === 'bweforvideo') {
      console.log('found the right element');
      console.log(elem.stat("googActualEncBitrate"))
      break;
    }
  }
});


jansson@ thanks you!
I found an example on the web were RTCStatsReport.stat() takes a 2nd parameter.

I was not able to find an official documentation. Do you know if there is an official documentation?

Sign in to add a comment