[webkit-dev] setTimeout and Safari

Evan Martin evan at chromium.org
Fri Oct 8 09:54:57 PDT 2010


On Thu, Oct 7, 2010 at 12:41 PM, Simon Fraser <simon.fraser at apple.com> wrote:
> On Oct 7, 2010, at 12:23 PM, Steve Conover wrote:
>
>> So that I don't have to guess whether a page is "done" rendering.
>> Many developers defer rendering using setTimeout, I'd like to wait
>> until setTimeouts are done and then just after check the result.  This
>> would be superior to guessing at a sleep interval in the calling code.
>
> Are you trying to choose a good time to snapshot the page?
>
> There are many things that can cause the page to keep changing; chained
> setTimeouts, setInterval, CSS transitions and animations, SVG animation,
> plugins etc etc. This is not a simple question to answer.

Also <img> tags that are taking a long time to load.


It's a pretty ugly hack, but to performance test the new tab page in
Chrome we use a timeout keyed on painting.  If the page hasn't painted
in two seconds or so, we call it "done", and record that it took up to
the time of the last seen paint to finish loading.  This metric at
least captures what matters to a user: whether the page contents have
settled, at the cost of the assumption that we never sit still for
more than two seconds while loading.


More information about the webkit-dev mailing list