Description
This is a followup to:
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.