adapter: RTCPeerConnection.getStats(mediaStreamTrack, callback) does not work correct

Browsers and versions affected Chrome

Description I call RTCPeerConnection.getStats(mediaStreamTrack, callback) and I expect to get result in the callback. But my callback will be called without arguments. Because of this code:

      // When spec-style getStats is supported, return those when called with
      // either no arguments or the selector argument is null.
      if (origGetStats.length === 0 && (arguments.length === 0 ||
          typeof arguments[0] !== 'function')) {
        return origGetStats.apply(this, []);
      }

As we can see the comment contradicts the code.
or the selector argument is null. and typeof arguments[0] !== 'function'

p.s. I can do a merge request if you confirm it as a bug. Steps to reproduce Just call the RTCPeerConnection.getStats(mediaStreamTrack, callback) and see the empty arguments inside the callback.

Expected results Stats as an argument inside the callback

Actual results There are no any arguments (because of return origGetStats.apply(this, []);)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (4 by maintainers)

Commits related to this issue

Most upvoted comments

or just use the promise version 😃

The optional selector is the second argument, not the first. https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/peerconnection/RTCPeerConnection.idl?q=RTCPeerConnection.idl&sq=package:chromium&dr&l=108

Try with signature getStats(callback, mediaStreamTrack).