Re: [webkit-dev] setTimeout and Safari
On Thu, Oct 7, 2010 at 12:41 PM, Simon Fraser 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 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. ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] setTimeout and Safari
I think a different way works: hooking window.setTimeout, window.setInterval, window.clearTimeout and window.clearInterval after the page is loaded and before any script is run, like the following: (function() { var orgSetTimeout = window.setTimeout; window.setTimeout = function(f, t) { ... var id = orgSetTimeout(function() { ... f(); }, t); ... return id; }; ... })(); In Chrome, this can be done with a run_at document_start content script in an extension. Xianzhu 2010/10/8 Steve Conover : > It's true. Maybe I'm wrong about this but it seems to me that at some > point most pages "settle". I'm also planning to put in a hard timeout > in what I'm building. And I'm slightly more concerned about js than > css. > > Do you know of a good way at getting at an event queue or something > else containing a list or a count of upcoming setTimeout/setInterval > operations, in either Safari or QtWebKit? > > > On Thu, Oct 7, 2010 at 12:41 PM, Simon Fraser 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. >> >> Simon >> >>> >>> On Wed, Oct 6, 2010 at 5:54 PM, Simon Fraser wrote: Why do you need to know if there are no more pending setTimeouts? Simon On Oct 6, 2010, at 5:52 PM, Steve Conover wrote: > Hoping someone on -dev might have an idea about this... > > -Steve > > > -- Forwarded message -- > From: Steve Conover > Date: Tue, Sep 28, 2010 at 11:19 PM > Subject: Re: setTimeout and Safari > To: webkit-h...@lists.webkit.org > > > Actually I am discovering what one might describe as a "normal" > problem here...how to know when the setTimeout's are done firing. The > ideal would that I could somehow drill into the dom implementation and > ask whether any setTimeout events are waiting to fire (and stop > polling if the queue length is zero). > > I'm sure that's way off in terms of how this is actually implemented. > Does such a thing exist? Could someone please point me to the > relevant sourcecode? > > Regards, > Steve > > On Tue, Sep 28, 2010 at 10:36 PM, Steve Conover > wrote: >> Sigh. Please disregard. After an hour of troubleshooting, I sent >> this email, and two minutes later realized the problem was bad js >> (blush). >> >> On Tue, Sep 28, 2010 at 10:22 PM, Steve Conover >> wrote: >>> I hope this is the right place to be asking this question. >>> >>> I'm using the cocoa api, and am able to load a web page in a WebView. >>> However I have some javascript in the page that uses setTimeout to >>> cause a function to fire 100ms into the future - but the page loads >>> and ignores the setTimeout's. >>> >>> How do I get my setTimeout's to fire? I suspect this has something to >>> do with the Run Loop, but my experiments so far with various parts of >>> the Run Loop api have been failures. >>> >>> Regards, >>> Steve >>> >> > ___ > webkit-dev mailing list > webkit-dev@lists.webkit.org > http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev >> >> > ___ > webkit-dev mailing list > webkit-dev@lists.webkit.org > http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev > ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] setTimeout and Safari
It's true. Maybe I'm wrong about this but it seems to me that at some point most pages "settle". I'm also planning to put in a hard timeout in what I'm building. And I'm slightly more concerned about js than css. Do you know of a good way at getting at an event queue or something else containing a list or a count of upcoming setTimeout/setInterval operations, in either Safari or QtWebKit? On Thu, Oct 7, 2010 at 12:41 PM, Simon Fraser 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. > > Simon > >> >> On Wed, Oct 6, 2010 at 5:54 PM, Simon Fraser wrote: >>> Why do you need to know if there are no more pending setTimeouts? >>> >>> Simon >>> >>> On Oct 6, 2010, at 5:52 PM, Steve Conover wrote: >>> Hoping someone on -dev might have an idea about this... -Steve -- Forwarded message -- From: Steve Conover Date: Tue, Sep 28, 2010 at 11:19 PM Subject: Re: setTimeout and Safari To: webkit-h...@lists.webkit.org Actually I am discovering what one might describe as a "normal" problem here...how to know when the setTimeout's are done firing. The ideal would that I could somehow drill into the dom implementation and ask whether any setTimeout events are waiting to fire (and stop polling if the queue length is zero). I'm sure that's way off in terms of how this is actually implemented. Does such a thing exist? Could someone please point me to the relevant sourcecode? Regards, Steve On Tue, Sep 28, 2010 at 10:36 PM, Steve Conover wrote: > Sigh. Please disregard. After an hour of troubleshooting, I sent > this email, and two minutes later realized the problem was bad js > (blush). > > On Tue, Sep 28, 2010 at 10:22 PM, Steve Conover > wrote: >> I hope this is the right place to be asking this question. >> >> I'm using the cocoa api, and am able to load a web page in a WebView. >> However I have some javascript in the page that uses setTimeout to >> cause a function to fire 100ms into the future - but the page loads >> and ignores the setTimeout's. >> >> How do I get my setTimeout's to fire? I suspect this has something to >> do with the Run Loop, but my experiments so far with various parts of >> the Run Loop api have been failures. >> >> Regards, >> Steve >> > ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev >>> >>> > > ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] setTimeout and Safari
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. Simon > > On Wed, Oct 6, 2010 at 5:54 PM, Simon Fraser wrote: >> Why do you need to know if there are no more pending setTimeouts? >> >> Simon >> >> On Oct 6, 2010, at 5:52 PM, Steve Conover wrote: >> >>> Hoping someone on -dev might have an idea about this... >>> >>> -Steve >>> >>> >>> -- Forwarded message -- >>> From: Steve Conover >>> Date: Tue, Sep 28, 2010 at 11:19 PM >>> Subject: Re: setTimeout and Safari >>> To: webkit-h...@lists.webkit.org >>> >>> >>> Actually I am discovering what one might describe as a "normal" >>> problem here...how to know when the setTimeout's are done firing. The >>> ideal would that I could somehow drill into the dom implementation and >>> ask whether any setTimeout events are waiting to fire (and stop >>> polling if the queue length is zero). >>> >>> I'm sure that's way off in terms of how this is actually implemented. >>> Does such a thing exist? Could someone please point me to the >>> relevant sourcecode? >>> >>> Regards, >>> Steve >>> >>> On Tue, Sep 28, 2010 at 10:36 PM, Steve Conover wrote: Sigh. Please disregard. After an hour of troubleshooting, I sent this email, and two minutes later realized the problem was bad js (blush). On Tue, Sep 28, 2010 at 10:22 PM, Steve Conover wrote: > I hope this is the right place to be asking this question. > > I'm using the cocoa api, and am able to load a web page in a WebView. > However I have some javascript in the page that uses setTimeout to > cause a function to fire 100ms into the future - but the page loads > and ignores the setTimeout's. > > How do I get my setTimeout's to fire? I suspect this has something to > do with the Run Loop, but my experiments so far with various parts of > the Run Loop api have been failures. > > Regards, > Steve > >>> ___ >>> webkit-dev mailing list >>> webkit-dev@lists.webkit.org >>> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev >> >> ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] setTimeout and Safari
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. On Wed, Oct 6, 2010 at 5:54 PM, Simon Fraser wrote: > Why do you need to know if there are no more pending setTimeouts? > > Simon > > On Oct 6, 2010, at 5:52 PM, Steve Conover wrote: > >> Hoping someone on -dev might have an idea about this... >> >> -Steve >> >> >> -- Forwarded message -- >> From: Steve Conover >> Date: Tue, Sep 28, 2010 at 11:19 PM >> Subject: Re: setTimeout and Safari >> To: webkit-h...@lists.webkit.org >> >> >> Actually I am discovering what one might describe as a "normal" >> problem here...how to know when the setTimeout's are done firing. The >> ideal would that I could somehow drill into the dom implementation and >> ask whether any setTimeout events are waiting to fire (and stop >> polling if the queue length is zero). >> >> I'm sure that's way off in terms of how this is actually implemented. >> Does such a thing exist? Could someone please point me to the >> relevant sourcecode? >> >> Regards, >> Steve >> >> On Tue, Sep 28, 2010 at 10:36 PM, Steve Conover wrote: >>> Sigh. Please disregard. After an hour of troubleshooting, I sent >>> this email, and two minutes later realized the problem was bad js >>> (blush). >>> >>> On Tue, Sep 28, 2010 at 10:22 PM, Steve Conover wrote: I hope this is the right place to be asking this question. I'm using the cocoa api, and am able to load a web page in a WebView. However I have some javascript in the page that uses setTimeout to cause a function to fire 100ms into the future - but the page loads and ignores the setTimeout's. How do I get my setTimeout's to fire? I suspect this has something to do with the Run Loop, but my experiments so far with various parts of the Run Loop api have been failures. Regards, Steve >>> >> ___ >> webkit-dev mailing list >> webkit-dev@lists.webkit.org >> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev > > ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] setTimeout and Safari
Why do you need to know if there are no more pending setTimeouts? Simon On Oct 6, 2010, at 5:52 PM, Steve Conover wrote: > Hoping someone on -dev might have an idea about this... > > -Steve > > > -- Forwarded message -- > From: Steve Conover > Date: Tue, Sep 28, 2010 at 11:19 PM > Subject: Re: setTimeout and Safari > To: webkit-h...@lists.webkit.org > > > Actually I am discovering what one might describe as a "normal" > problem here...how to know when the setTimeout's are done firing. The > ideal would that I could somehow drill into the dom implementation and > ask whether any setTimeout events are waiting to fire (and stop > polling if the queue length is zero). > > I'm sure that's way off in terms of how this is actually implemented. > Does such a thing exist? Could someone please point me to the > relevant sourcecode? > > Regards, > Steve > > On Tue, Sep 28, 2010 at 10:36 PM, Steve Conover wrote: >> Sigh. Please disregard. After an hour of troubleshooting, I sent >> this email, and two minutes later realized the problem was bad js >> (blush). >> >> On Tue, Sep 28, 2010 at 10:22 PM, Steve Conover wrote: >>> I hope this is the right place to be asking this question. >>> >>> I'm using the cocoa api, and am able to load a web page in a WebView. >>> However I have some javascript in the page that uses setTimeout to >>> cause a function to fire 100ms into the future - but the page loads >>> and ignores the setTimeout's. >>> >>> How do I get my setTimeout's to fire? I suspect this has something to >>> do with the Run Loop, but my experiments so far with various parts of >>> the Run Loop api have been failures. >>> >>> Regards, >>> Steve >>> >> > ___ > webkit-dev mailing list > webkit-dev@lists.webkit.org > http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev