WebRTC Diagnostic Logging API

Draft Community Group Report,

This version:
https://wicg.github.io/webrtc-diagnostic-logging/
Issue Tracking:
GitHub
Editor:
Guido Urdaneta (Google)

Abstract

This specification defines an API to manage internal WebRTC diagnostic logs.

Status of this document

This specification was published by the Web Platform Incubator Community Group. It is not a W3C Standard nor is it on the W3C Standards Track. Please note that under the W3C Community Contributor License Agreement (CLA) there is a limited opt-out and other conditions apply. Learn more about W3C Community and Business Groups.

1. Introduction

The WebRTC Diagnostic Logging API provides a programmatic interface for web applications to start, finish, and discard the collection of internal diagnostic logs for WebRTC-related operations performed by the user agent. These diagnostic logs are never exposed to the application. Instead they are stored in a location controlled by the user and may be shared with the user agent vendor. The collection and storage of diagnostic logs requires explicit authorization by user and the application never knows if diagnostic logging operations succeed or fail. The contents of the diagnostic logs are also an implementation detail. The use cases intended to be supported by this API are the following:

2. Security and Privacy

These diagnostic logs collect information about internal operations performed by the user agent to implement WebRTC-related features. These diagnostic logs may contain information not exposed to the Web application and therefore, the API cannot expose these logs to the Web application in any way. The logs may, subject to user authorization, be shared (via out-of-band uploads, for example) with the user-agent vendor so that they can be used to assist in fixing user-agent bugs or providing other improvements to the user agent.

The collection, storage and upload of diagnostic logs requires explicit authorization by the user. The specific mechanism for this authorization is implementation-defined. Some options to implement authorization include, but are not limited to, dedicated UI, configuration files, enterprise policies, prompts, or a combination thereof. Authorization may be limited to specific origins. The status of these authorizations is never exposed to the application. Therefore, the APIs provide no guarantees of success.

3. Extensions to the RTCPeerConnection Interface

The API is exposed as a set of static methods on the RTCPeerConnection interface.

[
  Exposed=Window
] partial interface RTCPeerConnection {
  static Promise<DOMString> startDiagnosticLogging(optional RTCDiagnosticLoggingOptions options = {});
  static Promise<undefined> finishDiagnosticLogging(optional RTCDiagnosticLoggingOptions options = {});
  static Promise<undefined> discardDiagnosticLogging();
};

3.1. Dictionaries

The RTCDiagnosticLoggingOptions provides configuration for the logging session.

dictionary RTCDiagnosticLoggingOptions {
  record<DOMString, DOMString> metadata;
};

3.2. Internal slots

Let the the relevant global object have an [[RTCDiagnosticLoggingSessionId]] internal slot, initialized to null.

3.3. Methods

3.3.1. startDiagnosticLogging(options)

The startDiagnosticLogging(options) method attempts to start a diagnostic logging session.

When this method is invoked, the user agent MUST run the following steps:

  1. Let options be the first argument of this method.

  2. Let metadata be options’s metadata member.

  3. If metadata’s size is greater than 5, or if any entry keyvalue of metadata has a length greater than 100, return a promise rejected with a TypeError.

  4. Let p be a new promise.

  5. In parallel, perform the following steps:

    1. Let uuid be a randomly generated UUID [rfc4122]. To avoid fingerprinting, implementations SHOULD use the form in section 4.4 of RFC 4122 when generating UUIDs.

    2. Let doc be the relevant global object’s associated document.

    3. If the [[RTCDiagnosticLoggingSessionId]] internal slot is not null, reject p with a DOMException object whose name attribute has the value "InvalidStateError" and abort these steps.

    4. Store uuid in the [[RTCDiagnosticLoggingSessionId]] internal slot.

    5. Resolve p with uuid.

    6. Start a logging session of internal WebRTC activity identified with uuid.

  6. Return p.

Once a logging session starts, any WebRTC-related activity generated by doc MAY be logged by the user agent after p resolves. The log MAY include metadata or information derived from it. The logging session is identified with uuid, which can be used to reference logs (e.g., in bug reports).

3.3.2. finishDiagnosticLogging(options)

The finishDiagnosticLogging(options) method ends an ongoing diagnostic logging session.

When this method is invoked, the user agent MUST run the following steps:

  1. Let options be the first argument of this method.

  2. Let metadata be options’s metadata member.

  3. If metadata’s size is greater than 5, or if any entry keyvalue of metadata has a length greater than 100, return a promise rejected with a TypeError.

  4. Let p be a new promise.

  5. In parallel, perform the following steps:

    1. If the [[RTCDiagnosticLoggingSessionId]] internal slot is null, reject p with a DOMException object whose name attribute has the value "InvalidStateError" and abort these steps.

    2. Stop the logging session identified with [[RTCDiagnosticLoggingSessionId]].

    3. Set [[RTCDiagnosticLoggingSessionId]] to null.

    4. Resolve p with undefined.

  6. Return p.

The user agent MUST NOT log any WebRTC-related activity generated by doc after p resolves.

3.3.3. discardDiagnosticLogging()

The discardDiagnosticLogging() method discards an ongoing diagnostic logging session and deletes all logged data associated with the session.

When this method is invoked, the user agent MUST run the following steps:

  1. Let p be a new promise.

  2. In parallel, perform the following steps:

    1. If the [[RTCDiagnosticLoggingSessionId]] internal slot is null, reject p with a DOMException object whose name attribute has the value "InvalidStateError" and discard these steps.

    2. Let uuid be the value of the [[RTCDiagnosticLoggingSessionId]].

    3. Discard the logging session identified with [[RTCDiagnosticLoggingSessionId]].

    4. Set [[RTCDiagnosticLoggingSessionId]] to null.

    5. Resolve p with undefined.

  3. Return p.

After p resolves:

Conformance

Document conventions

Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.

All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]

Examples in this specification are introduced with the words “for example” or are set apart from the normative text with class="example", like this:

This is an example of an informative example.

Informative notes begin with the word “Note” and are set apart from the normative text with class="note", like this:

Note, this is an informative note.

Index

Terms defined by this specification

Terms defined by reference

References

Normative References

[DOM]
Anne van Kesteren. DOM Standard. Living Standard. URL: https://dom.spec.whatwg.org/
[HTML]
Anne van Kesteren; et al. HTML Standard. Living Standard. URL: https://html.spec.whatwg.org/multipage/
[INFRA]
Anne van Kesteren; Domenic Denicola. Infra Standard. Living Standard. URL: https://infra.spec.whatwg.org/
[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://datatracker.ietf.org/doc/html/rfc2119
[WEBIDL]
Edgar Chen; Timothy Gu. Web IDL Standard. Living Standard. URL: https://webidl.spec.whatwg.org/
[WEBRTC]
Cullen Jennings; et al. WebRTC: Real-Time Communication in Browsers. URL: https://w3c.github.io/webrtc-pc/

Non-Normative References

[RFC4122]
K. Davis; B. Peabody; P. Leach. Universally Unique IDentifiers (UUIDs). May 2024. Proposed Standard. URL: https://www.rfc-editor.org/info/rfc9562/

IDL Index

[
  Exposed=Window
] partial interface RTCPeerConnection {
  static Promise<DOMString> startDiagnosticLogging(optional RTCDiagnosticLoggingOptions options = {});
  static Promise<undefined> finishDiagnosticLogging(optional RTCDiagnosticLoggingOptions options = {});
  static Promise<undefined> discardDiagnosticLogging();
};

dictionary RTCDiagnosticLoggingOptions {
  record<DOMString, DOMString> metadata;
};