Skip to content

Spec to record "next paint time" #35

Open
@bmaurer

Description

@bmaurer

This is a followup to:

https://groups.google.com/a/chromium.org/d/msgid/progressive-web-metrics/CAHTsfZD1zJp6unenAyu%2BKoDJLAfKG41Mm2mmbT9gUKzoMvnxWQ%40mail.gmail.com

At Facebook when we measure performance, we want to know when the user sees the thing that we're measuring. For example, we don't care when newsfeed was put in the DOM, we want to know when the pixels painted on the screen. So far the best way we've discovered to do this is doing a rAF and then within that rAF a setTimeout(0). the rAF ensures we capture everything within the frame and the spec runs setTimeouts from within a rAF in the next frame.

This heuristic has a number of problems:

  • It behaves poorly when the tab is in the background, etc (because browsers often delay frames/timeouts in these cases)
  • We'd ideally like to know if no drawing was necessary

Tim's event timing proposal is based on the idea of measuring the "time to next paint". It'd be great to standardize this concept and create a simple API for measuring it. The way I envision this API working is that it would provide a promise for a high resolution timestamp of the time when all the DOM mutations that have currently been done are painted on the screen. If the browser does not intend to immediately render these (eg because the tab is backgrounded and it will defer drawing to a later time or because no drawing is necessary) the promise will return null.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions