Skip to content

JS Self-Profiling API (including the Markers extension) #717

Description

@monica-ch

WebKittens

@marcoscaceres @annevk

Title of the proposal

JS Self-Profiling API (including the Markers extension)

URL to the spec

https://wicg.github.io/js-self-profiling/

URL to the spec's repository

https://github.com/WICG/js-self-profiling

Issue Tracker URL

No response

Explainer URL

No response

TAG Design Review URL

w3ctag/design-reviews#1251

Mozilla standards-positions issue URL

mozilla/standards-positions#477

WebKit Bugzilla URL

No response

Radar URL

No response

Description

The JS Self-Profiling API lets a web app profile its own JavaScript execution using a sampling profiler. A document opts in via the Document-Policy: js-profiling header, then constructs a Profiler with a sampling interval and sample-buffer limit; calling stop() returns a ProfilerTrace (a deduplicated set of frames, stacks, and timestamped samples) that the app can upload for analysis of real-user performance. The base API is implemented in Blink and shipped in Chromium; it is not currently implemented in Gecko or WebKit. It has a Mozilla standards-position request (mozilla/standards-positions#477) and a TAG review (#366).

We are now extending the API with markers: an optional marker field on ProfilerSample indicating the user-agent activity running when each sample was taken. This is an incremental addition — no new entry point and no change to how profiling is started or gated. Exposure is gated on cross-origin isolation:

  • In a cross-origin isolated document (COOP+COEP), the full marker set is exposed: script, gc, style, layout, paint.
  • In a non-isolated document, only style and layout are exposed; script, gc, and paint are omitted.

This keeps the markers that could reveal cross-process / cross-origin timing (notably gc, and script/paint activity) behind cross-origin isolation, while still exposing the rendering markers that a document can already infer about itself. It is currently being validated via a Chromium Origin Trial (Chrome M153–M161). Spec change: WICG/js-self-profiling#89.

@marcoscaceres suggested filing a WebKit position (TAG thread). We'd welcome WebKit's position and any questions on both the base API and the markers extension. Happy to provide additional detail on the exposure/gating design.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions