npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

webrtc-issue-detector2

v1.6.2

Published

WebRTC diagnostic tool that detects issues with network or user devices

Downloads

6

Readme

webrtc-issue-detector

Diagnostic tool for WebRTC JS applications that analyzes WebRTC getStats() result in realtime and generates a report on possible issues.

Key features

  • Mean opinion score - calculates MOS for inbound and outbound network connections that can indicate a problem before it even appears.
  • CPU issues - indicates possible issues with encoding and decoding media streams.
  • Server issues - indicates possible server side issues.
  • Fully customizable - allows to create your own detectors or WebRTC getStats() parsers.

Installation

yarn add webrtc-issue-detector

Usage

Getting started

import WebRTCIssueDetector from 'webrtc-issue-detector';

// create it before the first instance of RTCPeerConnection is created
const webRtcIssueDetector = new WebRTCIssueDetector({
    onIssues: (issues) => issues.map((issue) => {
        console.log('Issues type:', issue.type); // eg. "network"
        console.log('Issues reason:', issue.reason); // eg. "outbound-network-throughput"
        console.log('Issues reason:', issue.statsSample); // eg. "packetLossPct: 12%, avgJitter: 230, rtt: 150"
    }),
    onNetworkScoresUpdated: (scores) => {
        console.log('Inbound network score', scores.inbound); // eg. 3.7
        console.log('Outbound network score', scores.outbound); // eg. 4.5
    }
});

// start collecting getStats() and detecting issues
webRtcIssueDetector.watchNewPeerConnections();

// stop collecting WebRTC stats and issues detection
webRtcIssueDetector.stopWatchingNewPeerConnections();

Configure

By default, WebRTCIssueDetector can be created with minimum of mandatory constructor parameters. But it's possible to override most of them.

import WebRTCIssueDetector, {
  QualityLimitationsIssueDetector,
  FramesDroppedIssueDetector,
  FramesEncodedSentIssueDetector,
  InboundNetworkIssueDetector,
  OutboundNetworkIssueDetector,
  NetworkMediaSyncIssueDetector,
  AvailableOutgoingBitrateIssueDetector,
  UnknownVideoDecoderImplementationDetector,
} from 'webrtc-issue-detector';

const widWithDefaultConstructorArgs = new WebRTCIssueDetector();

// or you can fully customize WebRTCIssueDetector with constructor arguments

const widWithCustomConstructorArgs = new WebRTCIssueDetector({
  detectors: [ // you are free to change the detectors list according to your needs
    new QualityLimitationsIssueDetector(),
    new FramesDroppedIssueDetector(),
    new FramesEncodedSentIssueDetector(),
    new InboundNetworkIssueDetector(),
    new OutboundNetworkIssueDetector(),
    new NetworkMediaSyncIssueDetector(),
    new AvailableOutgoingBitrateIssueDetector(),
    new UnknownVideoDecoderImplementationDetector(),
  ],
  getStatsInterval: 10_000, // set custom stats parsing interval
  onIssues: (payload: IssueDetectorResult) => {
    // your custom callback for detected issues handling
  },
  onNetworkScoresUpdated: (payload: NetworkScores) => {
    // your custom callback for networks score updates handling
  },
  ignoreSSRCList: [
    // in case you need to skip some ssrc from parsing, add its numbers to the array
  ],
});

Detectors

AvailableOutgoingBitrateIssueDetector

Detects issues with outgoing network connection.

const exampleIssue = {
    type: 'network',
    reason: 'outbound-network-throughput',
    statsSample: {
      availableOutgoingBitrate: 1234,
      videoStreamsTotalBitrate: 1234,
      audioStreamsTotalTargetBitrate: 1234,
    },
}

FramesDroppedIssueDetector

Detects issues with decoder.

const exampleIssue = {
    type: 'cpu',
    reason: 'decoder-cpu-throttling',
    statsSample: {
      deltaFramesDropped: 100,
      deltaFramesReceived: 1000,
      deltaFramesDecoded: 900,
      framesDroppedPct: 10,
    },
    ssrc: 1234,
}

FramesEncodedSentIssueDetector

Detects issues with outbound network throughput.

const exampleIssue = {
    type: 'network',
    reason: 'outbound-network-throughput',
    statsSample: {
      deltaFramesSent: 900,
      deltaFramesEncoded: 1000,
      missedFramesPct: 10,
    },
    ssrc: 1234,
}

InboundNetworkIssueDetector

Detects issues with inbound network connection.

const exampleIssue = {
    type: 'network',
    reason: 'inbound-network-quality' | 'inbound-network-media-latency' | 'network-media-sync-failure',
    iceCandidate: 'ice-candidate-id',
    statsSample: {
      rtt: 1234,
      packetLossPct: 1234,
      avgJitter: 1234,
      avgJitterBufferDelay: 1234,
    },
}

Also can detect server side issues if there is high RTT and jitter is ok.

const exampleIssue = {
    type: 'server',
    reason: 'server-issue',
    iceCandidate: 'ice-candidate-id',
      statsSample: {
        rtt: 1234,
        packetLossPct: 1234,
        avgJitter: 1234,
        avgJitterBufferDelay: 1234,
      },
}

NetworkMediaSyncIssueDetector

Detects issues with audio synchronization.

const exampleIssue = {
    type: 'network',
    reason: 'network-media-sync-failure',
    ssrc: 1234,
    statsSample: {
      correctedSamplesPct: 15,
    },
}

OutboundNetworkIssueDetector

Detects issues with outbound network connection.

const exampleIssue = {
    type: 'network',
    reason: 'outbound-network-quality' | 'outbound-network-media-latency',
    iceCandidate: 'ice-candidate-id',
    statsSample: {
      rtt: 1234,
      avgJitter: 1234,
      packetLossPct: 1234,
    },
}

QualityLimitationsIssueDetector

Detects issues with encoder and outbound network. Based on native qualityLimitationReason.

const exampleIssue = {
    type: 'cpu',
    reason: 'encoder-cpu-throttling',
    ssrc: 1234,
    statsSample: {
      qualityLimitationReason: 'cpu',
    },
}
const exampleIssue = {
    type: 'network',
    reason: 'outbound-network-throughput',
    ssrc: 1234,
    statsSample: {
      qualityLimitationReason: 'bandwidth',
    },
}

VideoCodecMismatchDetector

Detects issues with decoding stream.

const exampleIssue = {
    type: 'stream',
    reason: 'unknown-video-decoder',
    ssrc: 1234,
    trackIdentifier: 'some-track-id',
    statsSample: {
      mimeType: 'video/vp9',
      decoderImplementation: 'unknown'
    },
}

Roadmap

  • [ ] Adaptive getStats() call interval based on last getStats() execution time
  • [ ] Structured issue debug
  • [ ] Issues detector for user devices permissions

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT