Is it possible to access the chrome://webrtc-internals/ variables through an API in JavaScript?

I couldn't find any information about how to access the logged variables in chrome://webrtc-internals/ on google. There is not even a description of the graphs available there.
I am specifically interested in packetsLost, googCurrentDelayMs, and googNacksSent.

The reason behind wanting access to webrtc-internals
I am currently developing a video streaming application on Google Chrome that works peer-to-peer. This application uses peerjs to share the stream with other peers, utilizing Google's WebRTC technology as its foundation. To enhance the performance of my application, it would be crucial for me to monitor significant delays. As I can track these delays through logs in chrome://webrtc-internals/, I was interested in finding out if I could retrieve this data using JavaScript.

My assumption is that there isn't an API available for the chrome://webrtc-internals/ menu.

Answer №1

I managed to solve this issue by delving into various Google community threads (thread 1, thread2):

var peerjs = new Peer(...); // initializing PeerJS
var connections = peerjs.connections;

The 'connections' variable is an object:

Object {2e1c5694-e6ef-e1b2-22d5-84a3807961d4: Array[3]}
    2e1c5694-e6ef-e1b2-22d5-84a3807961d4: Array[3]
        0: DataConnection
        1: MediaConnection
        2: MediaConnection
        length: 3
    __proto__: Array[0]
__proto__: Object

You can inspect any of these connection objects:

var rtcPeerConn = connectionObject.pc; // RTCPeerConnection

rtcPeerConn.getStats(function callback(connStats){
    var rtcStatsReports = connStats.result(); // an array of available status reports
    // Each status report object contains multiple variables, like googCurrentDelayMs.
    // You'll need to iterate through the objects and check their names to find the desired report.
    rtcStatsReports[7].names(); // returns all available variables for that report

    var googCurrentDelayMs = rtcStatsReports[7].stat('googCurrentDelayMs');
    console.log(googCurrentDelayMs); // finally - googCurrentDelayMs :-)
})

Answer №2

After conducting extensive research, I was able to successfully retrieve data from the PC using the Twilio SDK.

var rtcPeerConn =Twilio.Device.activeConnection();
rtcPeerConn.options.mediaStreamFactory.protocol.pc.getStats(function callback(report) {
                var rtcStatsReports = report.result();
                for (var i=0; i<rtcStatsReports.length; i++) {
                    var statNames = rtcStatsReports[i].names();
                    // filtering ICE stats
                    if (statNames.indexOf("transportId") > -1) {
                        var logs = "";
                        for (var j=0; j<statNames.length; j++) {
                            var statName = statNames[j];
                            var statValue = rtcStatsReports[i].stat(statName);
                            logs = logs + statName + ": " + statValue + ", ";
                        }
                        console.log(logs);
                    }
                }
            });

//Calculate error rate: Packetlost / packetsent

var rtcPeerConn =Twilio.Device.activeConnection();
rtcPeerConn.options.mediaStreamFactory.protocol.pc.getStats(function callback(report) {
                var error, pcksent;
                var rtcStatsReports = report.result();
                for (var i=0; i<rtcStatsReports.length; i++) {
                    var statNames = rtcStatsReports[i].names();
                    // filtering ICE stats
                    if (statNames.indexOf("packetsSent") > -1) {
                        var logs = "";
                        for (var j=0; j<statNames.length; j++) {
                            var statName = statNames[j];
                            var statValue = rtcStatsReports[i].stat(statName);
                            if(statName=="packetsLost")
                              error= statValue;
                            if(statName =="packetsSent")
                              pcksent = statValue;
                            logs = logs +"n:" +statName + ": " + statValue + ", ";
                        }
                        console.log(error/pcksent);
                    }
                }

            });

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Customize Your Lightbox Fields with DHXScheduler

In my JSP application for exam timetabling, I have integrated DHXScheduler and customized the lightbox to display additional information about exams using my own fields. The EventsManager class is responsible for managing events by saving, creating, and r ...

The Process of Developing Applications

As a newcomer to web development, I have a solid understanding of HTML and CSS, and am learning JavaScript. When considering creating a web app, would it be better for me to focus on writing the functionality in JavaScript first before integrating it int ...

Issue with jquery .click function not triggering after CSS adjustment

In the process of creating a fun game where two players take turns drawing on a grid by clicking <td> elements. Currently, I have implemented the functionality to toggle the background color of a <td> element from black to white and vice versa ...

Sped up object outpacing the mouse pointer

I'm currently developing a drag and drop minigame, but I've encountered an issue with the touch functionality. The draggable function (using only cursor) works flawlessly, however, when I tried to implement touch support for mobile and tablet use ...

Tips on safeguarding your templates while working with SailsJS and AngularJS

I am currently working on a web application using SailsJS and AngularJS. My project requires session management to track user login status. I came across this helpful tutorial and implemented an index.ejs view located in the /view folder. Within the index. ...

Are there any instances where CSS is overlooking certain HTML elements?

In the following HTML code snippet, the presence of the element with class ChildBar is optional: <div class="Parent"> <div class="ChildFoo"></div> <div class="ChildBar"></div> <!-- May ...

Experiencing a bug in the production build of my application involving Webpack, React, postCSS, and potentially other JavaScript code not injecting correctly

I've encountered an issue with my webpack.prod.config when building my assets, which may also be related to the JS Babel configuration. While I can successfully get it to work in the development build by inline CSS, the problem arises when attempting ...

Performing height calculations in JavaScript is necessary to recalculate them whenever there is a

A JavaScript function is used to calculate the height of an iframe element and the document height, then determine if the iframe is on or off based on its height and display properties. The issue arises when changing pages— if the height is less than the ...

Having trouble getting the convert-multiple-files npm package to function properly on an Elastic Beanstalk environment running Amazon Linux

Following a successful deployment, I encountered an issue with my file conversion script when attempting to convert files as outlined in the documentation. The script works flawlessly on both a local Windows 10 machine and Ubuntu 20.04 LTS. const { conv ...

The Node.js server seems to be continuously loading without producing any output

I've been struggling with getting my server to function properly. Whenever I send post data, the page just keeps loading and doesn't display any results. Here is a snippet of my Node.js file: var http = require('http'); var url = requi ...

JavaScript format nested data structure

For my latest project, I am working on a blog using Strapi combined with Nuxt. To fetch the categories and articles data for my blog, I send a JSON object from my front-end application using Axios. { "data": [ { "id": 1, ...

When using Magento, pasting the same link into the browser produces a different outcome than clicking on window.location - specifically when trying to add items to the

I'm in the process of setting up a Magento category page that allows users to add configurable products directly from the category page, which is not the standard operation for Magento. After putting in a lot of effort, I have almost completed the ta ...

Is there a way to implement retry functionality with a delay in RxJs without resorting to the outdated retryWhen method?

I'd like to implement a retry mechanism for an observable chain with a delay of 2 seconds. While researching, I found some solutions using retryWhen. However, it appears that retryWhen is deprecated and I prefer not to use it. The retry with delay s ...

JavaScript for switching between grid layouts

I have organized 3 DIVs using a grid layout. There is a Navigation bar with an on-click event attached to it. When a button on the nav-bar is clicked, I want the JavaScript function to display the corresponding grid associated with that button. Currently, ...

Utilizing jQuery UI autocomplete with AJAX and JSON data sources

I've been facing an issue with the jQuery UI autocomplete feature, and despite extensive research, I have only managed to partially resolve it. The code below is what I'm currently using to make it work: $("#term").autocomplete({ source: fun ...

Video is not visible in safari browser initially, but becomes visible only after scrolling for a little while

Having issues with a video not displaying correctly in Safari? The problem is that the video only becomes visible after scrolling the browser window. Want to see an example of this issue in action? Click here and select the red bag. Check out the code sni ...

Miscalculation occurred when attempting to add or subtract values from various inputs

My goal is to calculate the sum and rest of two different values after adding or subtracting. For instance, I have a Total variable = 500, along with two input fields - one for MXN and the other for USD. Additionally, there is a USD variable set at 17.5. T ...

Is there a way for me to gain access to the ng-repeat scope?

I have a scenario where my ng-repeat generates different elements and I need to perform certain operations, such as creating variables, within the scope of the ng-repeat. Is there a way to access the specific ng-repeat scope? How can I achieve something ...

The removeEventListener method in JavaScript fails to function properly

On my website, I have a unique feature where clicking an image will display it in a lightbox. Upon the second click, the mouse movement is tracked to move the image accordingly. This functionality is working as intended, but now I'm faced with the cha ...

Tips for accessing the current state/value in a third-party event handler?

Consider the following scenario: function MapControl() { const [countries, setCountries] = useContext(CountriesContext) useEffect( () => { ThirdPartyApi.OnSelectCountry((country) => { setCountries([...countries, country]) }) }) ...