webrtc-internals: sort stats by encodingIndex and type [chromium/src : main]

0 views
Skip to first unread message

Philipp Hancke (Gerrit)

unread,
Sep 22, 2025, 9:20:58 AM (4 days ago) Sep 22
to Henrik Boström, chromium...@chromium.org
Attention needed from Henrik Boström

Philipp Hancke added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Philipp Hancke . resolved

easier and more consistent.

Open in Gerrit

Related details

Attention is currently required from:
  • Henrik Boström
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Id8f6fb2b27a2a97802debc12cea2b6bd74579d91
Gerrit-Change-Number: 6973537
Gerrit-PatchSet: 1
Gerrit-Owner: Philipp Hancke <philipp...@googlemail.com>
Gerrit-Reviewer: Henrik Boström <hb...@chromium.org>
Gerrit-Attention: Henrik Boström <hb...@chromium.org>
Gerrit-Comment-Date: Mon, 22 Sep 2025 13:20:41 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Henrik Boström (Gerrit)

unread,
Sep 22, 2025, 9:58:32 AM (4 days ago) Sep 22
to Philipp Hancke, Harald Alvestrand, chromium...@chromium.org
Attention needed from Harald Alvestrand and Philipp Hancke

Henrik Boström added 1 comment

File content/browser/webrtc/resources/webrtc_internals.js
Line 377, Patchset 1 (Latest): }));
Henrik Boström . unresolved

Omg, so little code... TL;DR you need to avoid NaN otherwise I think this will be good.

But `stats1.encodingIndex - stats2.encodingIndex` can be `-2` or `NaN` while `localeCompare` in the range `-1` to `1`. I feel like things could get wrong here?

For example if we want the order:

  • All outbound-rtps, in encodingIndex order
  • All inbound-rtps
  • Everyhing else

It's a problem if the inbound-rtp and foo stats produced NaN because the encodingIndex part of the expression is `NaN` and `NaN + localeCompare` is `NaN` rather than -1 or 1.

It's also a problem if one outbound-rtp that doesn't have encodingIndex (e.g. audio) and one outbound-rtp that does have an encodingIndex is, again, NaN. This comparison needs to be either -1 or 1 to avoid us "mixing" singlecast and simulcast streams e.g.

  • encodingIndex 0
  • random audio outbound RTP
  • encodingIndex 1
  • etc

I think this comparison needs to be robust enough that the first part of the expression is never NaN, and in this case the expression should be entirely evaluated based on whether or not the types are matching.

Open in Gerrit

Related details

Attention is currently required from:
  • Harald Alvestrand
  • Philipp Hancke
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id8f6fb2b27a2a97802debc12cea2b6bd74579d91
    Gerrit-Change-Number: 6973537
    Gerrit-PatchSet: 1
    Gerrit-Owner: Philipp Hancke <philipp...@googlemail.com>
    Gerrit-Reviewer: Harald Alvestrand <h...@chromium.org>
    Gerrit-Reviewer: Henrik Boström <hb...@chromium.org>
    Gerrit-Attention: Philipp Hancke <philipp...@googlemail.com>
    Gerrit-Attention: Harald Alvestrand <h...@chromium.org>
    Gerrit-Comment-Date: Mon, 22 Sep 2025 13:58:20 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Philipp Hancke (Gerrit)

    unread,
    Sep 22, 2025, 11:42:39 AM (4 days ago) Sep 22
    to Harald Alvestrand, Henrik Boström, chromium...@chromium.org
    Attention needed from Harald Alvestrand and Henrik Boström

    Philipp Hancke added 1 comment

    File content/browser/webrtc/resources/webrtc_internals.js
    Henrik Boström . unresolved

    Omg, so little code... TL;DR you need to avoid NaN otherwise I think this will be good.

    But `stats1.encodingIndex - stats2.encodingIndex` can be `-2` or `NaN` while `localeCompare` in the range `-1` to `1`. I feel like things could get wrong here?

    For example if we want the order:

    • All outbound-rtps, in encodingIndex order
    • All inbound-rtps
    • Everyhing else

    It's a problem if the inbound-rtp and foo stats produced NaN because the encodingIndex part of the expression is `NaN` and `NaN + localeCompare` is `NaN` rather than -1 or 1.

    It's also a problem if one outbound-rtp that doesn't have encodingIndex (e.g. audio) and one outbound-rtp that does have an encodingIndex is, again, NaN. This comparison needs to be either -1 or 1 to avoid us "mixing" singlecast and simulcast streams e.g.

    • encodingIndex 0
    • random audio outbound RTP
    • encodingIndex 1
    • etc

    I think this comparison needs to be robust enough that the first part of the expression is never NaN, and in this case the expression should be entirely evaluated based on whether or not the types are matching.

    Philipp Hancke

    the order very much depends on your personal preferences. I care a lot more about ICE than RTP, why would you get the front row?

    Lets sort by encodingIndex if available, type otherwise. Quoting MDN, remember that "(a, b) => a - b sorts numbers in ascending order"

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Harald Alvestrand
    • Henrik Boström
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id8f6fb2b27a2a97802debc12cea2b6bd74579d91
    Gerrit-Change-Number: 6973537
    Gerrit-PatchSet: 2
    Gerrit-Owner: Philipp Hancke <philipp...@googlemail.com>
    Gerrit-Reviewer: Harald Alvestrand <h...@chromium.org>
    Gerrit-Reviewer: Henrik Boström <hb...@chromium.org>
    Gerrit-Attention: Henrik Boström <hb...@chromium.org>
    Gerrit-Attention: Harald Alvestrand <h...@chromium.org>
    Gerrit-Comment-Date: Mon, 22 Sep 2025 15:42:22 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Henrik Boström <hb...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Henrik Boström (Gerrit)

    unread,
    Sep 23, 2025, 4:48:38 AM (3 days ago) Sep 23
    to Philipp Hancke, Harald Alvestrand, chromium...@chromium.org
    Attention needed from Harald Alvestrand and Philipp Hancke

    Henrik Boström voted and added 1 comment

    Votes added by Henrik Boström

    Code-Review+1

    1 comment

    File content/browser/webrtc/resources/webrtc_internals.js
    Henrik Boström . resolved

    Omg, so little code... TL;DR you need to avoid NaN otherwise I think this will be good.

    But `stats1.encodingIndex - stats2.encodingIndex` can be `-2` or `NaN` while `localeCompare` in the range `-1` to `1`. I feel like things could get wrong here?

    For example if we want the order:

    • All outbound-rtps, in encodingIndex order
    • All inbound-rtps
    • Everyhing else

    It's a problem if the inbound-rtp and foo stats produced NaN because the encodingIndex part of the expression is `NaN` and `NaN + localeCompare` is `NaN` rather than -1 or 1.

    It's also a problem if one outbound-rtp that doesn't have encodingIndex (e.g. audio) and one outbound-rtp that does have an encodingIndex is, again, NaN. This comparison needs to be either -1 or 1 to avoid us "mixing" singlecast and simulcast streams e.g.

    • encodingIndex 0
    • random audio outbound RTP
    • encodingIndex 1
    • etc

    I think this comparison needs to be robust enough that the first part of the expression is never NaN, and in this case the expression should be entirely evaluated based on whether or not the types are matching.

    Philipp Hancke

    the order very much depends on your personal preferences. I care a lot more about ICE than RTP, why would you get the front row?

    Lets sort by encodingIndex if available, type otherwise. Quoting MDN, remember that "(a, b) => a - b sorts numbers in ascending order"

    Henrik Boström

    That's good enough for me.

    Then the type sorting will result in:
    ```
    "candidate-pair",
    "certificate",
    "codec",
    "data-channel",
    "inbound-rtp",
    "local-candidate",
    "media-playout",
    "media-source",
    "outbound-rtp",
    "peer-connection",
    "remote-candidate",
    "remote-inbound-rtp",
    "remote-outbound-rtp",
    "transport"
    ```

    I don't think it's the best sorting but it's also not the worst, as long as they're not spread out all over the place and tend to show up in roughly the same place I'm happy. Ship it.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Harald Alvestrand
    • Philipp Hancke
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Id8f6fb2b27a2a97802debc12cea2b6bd74579d91
    Gerrit-Change-Number: 6973537
    Gerrit-PatchSet: 2
    Gerrit-Owner: Philipp Hancke <philipp...@googlemail.com>
    Gerrit-Reviewer: Harald Alvestrand <h...@chromium.org>
    Gerrit-Reviewer: Henrik Boström <hb...@chromium.org>
    Gerrit-Attention: Philipp Hancke <philipp...@googlemail.com>
    Gerrit-Attention: Harald Alvestrand <h...@chromium.org>
    Gerrit-Comment-Date: Tue, 23 Sep 2025 08:48:24 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Philipp Hancke <philipp...@googlemail.com>
    Comment-In-Reply-To: Henrik Boström <hb...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Harald Alvestrand (Gerrit)

    unread,
    Sep 25, 2025, 3:37:10 AM (yesterday) Sep 25
    to Philipp Hancke, Henrik Boström, chromium...@chromium.org
    Attention needed from Philipp Hancke

    Harald Alvestrand added 2 comments

    Patchset-level comments
    File-level comment, Patchset 2 (Latest):
    Harald Alvestrand . resolved

    I don't think you should undo hbos' sort.....

    File content/browser/webrtc/resources/webrtc_internals.js
    Line 373, Patchset 2 (Latest): // increasing order.
    Harald Alvestrand . unresolved

    suggest keeping sortStatsReport() as a function, since I suspect that we'll want to tweak this many more times. And don't undo hbos' sort (outbound < inbound < other).

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Philipp Hancke
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Id8f6fb2b27a2a97802debc12cea2b6bd74579d91
      Gerrit-Change-Number: 6973537
      Gerrit-PatchSet: 2
      Gerrit-Owner: Philipp Hancke <philipp...@googlemail.com>
      Gerrit-Reviewer: Harald Alvestrand <h...@chromium.org>
      Gerrit-Reviewer: Henrik Boström <hb...@chromium.org>
      Gerrit-Attention: Philipp Hancke <philipp...@googlemail.com>
      Gerrit-Comment-Date: Thu, 25 Sep 2025 07:36:52 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Henrik Boström (Gerrit)

      unread,
      Sep 25, 2025, 3:41:42 AM (yesterday) Sep 25
      to Philipp Hancke, Harald Alvestrand, chromium...@chromium.org
      Attention needed from Philipp Hancke

      Henrik Boström voted and added 1 comment

      Votes added by Henrik Boström

      Code-Review+0

      1 comment

      File content/browser/webrtc/resources/webrtc_internals.js
      Line 373, Patchset 2 (Latest): // increasing order.
      Harald Alvestrand . unresolved

      suggest keeping sortStatsReport() as a function, since I suspect that we'll want to tweak this many more times. And don't undo hbos' sort (outbound < inbound < other).

      Henrik Boström

      Instead of type localeCompare we can do statsTypeToSortPriority (returning an int) and use that here such that this remains compact

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Philipp Hancke
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Id8f6fb2b27a2a97802debc12cea2b6bd74579d91
      Gerrit-Change-Number: 6973537
      Gerrit-PatchSet: 2
      Gerrit-Owner: Philipp Hancke <philipp...@googlemail.com>
      Gerrit-Reviewer: Harald Alvestrand <h...@chromium.org>
      Gerrit-Reviewer: Henrik Boström <hb...@chromium.org>
      Gerrit-Attention: Philipp Hancke <philipp...@googlemail.com>
      Gerrit-Comment-Date: Thu, 25 Sep 2025 07:41:25 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Harald Alvestrand <h...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Philipp Hancke (Gerrit)

      unread,
      Sep 25, 2025, 6:47:39 AM (yesterday) Sep 25
      to Henrik Boström, Harald Alvestrand, chromium...@chromium.org
      Attention needed from Harald Alvestrand and Henrik Boström

      Philipp Hancke added 1 comment

      File content/browser/webrtc/resources/webrtc_internals.js
      Line 373, Patchset 2: // increasing order.
      Harald Alvestrand . unresolved

      suggest keeping sortStatsReport() as a function, since I suspect that we'll want to tweak this many more times. And don't undo hbos' sort (outbound < inbound < other).

      Henrik Boström

      Instead of type localeCompare we can do statsTypeToSortPriority (returning an int) and use that here such that this remains compact

      Philipp Hancke

      Moved to a function for easier changes. Problem is we are never going to agree on the "right" order... most logical would actually be by creation timestamp but we don't have that.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Harald Alvestrand
      • Henrik Boström
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Id8f6fb2b27a2a97802debc12cea2b6bd74579d91
      Gerrit-Change-Number: 6973537
      Gerrit-PatchSet: 3
      Gerrit-Owner: Philipp Hancke <philipp...@googlemail.com>
      Gerrit-Reviewer: Harald Alvestrand <h...@chromium.org>
      Gerrit-Reviewer: Henrik Boström <hb...@chromium.org>
      Gerrit-Attention: Harald Alvestrand <h...@chromium.org>
      Gerrit-Attention: Henrik Boström <hb...@chromium.org>
      Gerrit-Comment-Date: Thu, 25 Sep 2025 10:47:23 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Henrik Boström <hb...@chromium.org>
      Comment-In-Reply-To: Harald Alvestrand <h...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Henrik Boström (Gerrit)

      unread,
      Sep 25, 2025, 6:52:35 AM (yesterday) Sep 25
      to Philipp Hancke, Harald Alvestrand, chromium...@chromium.org
      Attention needed from Harald Alvestrand and Philipp Hancke

      Henrik Boström added 1 comment

      File content/browser/webrtc/resources/webrtc_internals.js
      Line 373, Patchset 2: // increasing order.
      Harald Alvestrand . unresolved

      suggest keeping sortStatsReport() as a function, since I suspect that we'll want to tweak this many more times. And don't undo hbos' sort (outbound < inbound < other).

      Henrik Boström

      Instead of type localeCompare we can do statsTypeToSortPriority (returning an int) and use that here such that this remains compact

      Philipp Hancke

      Moved to a function for easier changes. Problem is we are never going to agree on the "right" order... most logical would actually be by creation timestamp but we don't have that.

      Henrik Boström

      Order is subjective but I don't understand why you're so resisting to the idea of putting the RTP objects first, what's the harm in doing that?

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Harald Alvestrand
      • Philipp Hancke
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Id8f6fb2b27a2a97802debc12cea2b6bd74579d91
      Gerrit-Change-Number: 6973537
      Gerrit-PatchSet: 3
      Gerrit-Owner: Philipp Hancke <philipp...@googlemail.com>
      Gerrit-Reviewer: Harald Alvestrand <h...@chromium.org>
      Gerrit-Reviewer: Henrik Boström <hb...@chromium.org>
      Gerrit-Attention: Philipp Hancke <philipp...@googlemail.com>
      Gerrit-Attention: Harald Alvestrand <h...@chromium.org>
      Gerrit-Comment-Date: Thu, 25 Sep 2025 10:52:18 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Philipp Hancke <philipp...@googlemail.com>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Philipp Hancke (Gerrit)

      unread,
      Sep 25, 2025, 12:28:42 PM (22 hours ago) Sep 25
      to Henrik Boström, Harald Alvestrand, chromium...@chromium.org
      Attention needed from Henrik Boström

      Philipp Hancke added 1 comment

      File content/browser/webrtc/resources/webrtc_internals.js
      Line 373, Patchset 2: // increasing order.
      Harald Alvestrand . unresolved

      suggest keeping sortStatsReport() as a function, since I suspect that we'll want to tweak this many more times. And don't undo hbos' sort (outbound < inbound < other).

      Henrik Boström

      Instead of type localeCompare we can do statsTypeToSortPriority (returning an int) and use that here such that this remains compact

      Philipp Hancke

      Moved to a function for easier changes. Problem is we are never going to agree on the "right" order... most logical would actually be by creation timestamp but we don't have that.

      Henrik Boström

      Order is subjective but I don't understand why you're so resisting to the idea of putting the RTP objects first, what's the harm in doing that?

      Philipp Hancke

      if you only want to look at RTP filter for -rtp using the filter box?

      There are other nice stats too!

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Henrik Boström
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Id8f6fb2b27a2a97802debc12cea2b6bd74579d91
      Gerrit-Change-Number: 6973537
      Gerrit-PatchSet: 3
      Gerrit-Owner: Philipp Hancke <philipp...@googlemail.com>
      Gerrit-Reviewer: Harald Alvestrand <h...@chromium.org>
      Gerrit-Reviewer: Henrik Boström <hb...@chromium.org>
      Gerrit-Attention: Henrik Boström <hb...@chromium.org>
      Gerrit-Comment-Date: Thu, 25 Sep 2025 16:28:24 +0000
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages