Bug 135082 - [iOS][WK2] Improve event throttling for Scroll Events
Summary: [iOS][WK2] Improve event throttling for Scroll Events
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Benjamin Poulain
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-18 20:40 PDT by Benjamin Poulain
Modified: 2014-07-21 21:08 PDT (History)
2 users (show)

See Also:


Attachments
Patch (22.91 KB, patch)
2014-07-18 21:41 PDT, Benjamin Poulain
no flags Details | Formatted Diff | Diff
Patch (22.95 KB, patch)
2014-07-18 21:58 PDT, Benjamin Poulain
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Poulain 2014-07-18 20:40:04 PDT
[iOS][WK2] Improve event throttling for Scroll Events
Comment 1 Benjamin Poulain 2014-07-18 21:41:49 PDT
Created attachment 235166 [details]
Patch
Comment 2 Benjamin Poulain 2014-07-18 21:58:42 PDT
Created attachment 235168 [details]
Patch
Comment 3 Sam Weinig 2014-07-18 22:39:42 PDT
Comment on attachment 235168 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=235168&action=review

> Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:372
> +        if (WebPage *webPage = WebProcess::shared().webPage(pageID)) {

I don't think it safe to call WebProcess::shared().webPage() from a background queue.
Comment 4 Benjamin Poulain 2014-07-19 02:08:57 PDT
Comment on attachment 235168 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=235168&action=review

>> Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:372
>> +        if (WebPage *webPage = WebProcess::shared().webPage(pageID)) {
> 
> I don't think it safe to call WebProcess::shared().webPage() from a background queue.

Yeah, that's really dumb. That code should be in the dispatch_async(). I used the PageID specifically to avoid races and then I create one 3 lines bellow...

I'll move it in the right place.
Comment 5 Simon Fraser (smfr) 2014-07-21 16:54:08 PDT
Comment on attachment 235168 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=235168&action=review

> Source/WebCore/page/ChromeClient.h:239
> +    virtual double eventThrottlingDelay() { return 0; };

Should this use std::chrono something?

> Source/WebKit2/WebProcess/WebPage/WebPage.cpp:2881
> +        m_estimatedMainThreadLatency = m_estimatedMainThreadLatency * 0.80 + elapsed * 0.20;

I'm not sure the "main thread" here is interesting.

> Source/WebKit2/WebProcess/WebPage/WebPage.cpp:4472
> +    m_estimatedMainThreadLatency = 1 / 60.;

60.0?

> Source/WebKit2/WebProcess/WebPage/WebPage.h:514
> +    double eventThrottlingDelay() const;

std::chrono would tell me what the units are.

> Source/WebKit2/WebProcess/WebPage/WebPage.h:754
> +    void updateVisibleContentRects(const VisibleContentRectUpdateInfo&, double);

Please give the double a name.

> Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm:1680
> +    if (m_isInStableState || m_estimatedMainThreadLatency <= 1. / 60)

Why not 1/60.0 like you used before?

> Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm:1683
> +    return std::min<double>(m_estimatedMainThreadLatency * 2, 1);

Explain the * 2 in a comment. What units are we in here?
Comment 6 Benjamin Poulain 2014-07-21 20:58:09 PDT
(In reply to comment #5)
> (From update of attachment 235168 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=235168&action=review
> 
> > Source/WebCore/page/ChromeClient.h:239
> > +    virtual double eventThrottlingDelay() { return 0; };
> 
> Should this use std::chrono something?

That is wasting performance and accuracy...but whatever, I'll do it.
Comment 7 Benjamin Poulain 2014-07-21 21:00:33 PDT
Committed r171336: <http://trac.webkit.org/changeset/171336>
Comment 8 Simon Fraser (smfr) 2014-07-21 21:03:53 PDT
(In reply to comment #6)
> (In reply to comment #5)
> > (From update of attachment 235168 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=235168&action=review
> > 
> > > Source/WebCore/page/ChromeClient.h:239
> > > +    virtual double eventThrottlingDelay() { return 0; };
> > 
> > Should this use std::chrono something?
> 
> That is wasting performance and accuracy...but whatever, I'll do it.

Isn't it just syntactic sugar?
Comment 9 Benjamin Poulain 2014-07-21 21:05:28 PDT
(In reply to comment #8)
> (In reply to comment #6)
> > (In reply to comment #5)
> > > (From update of attachment 235168 [details] [details] [details])
> > > View in context: https://bugs.webkit.org/attachment.cgi?id=235168&action=review
> > > 
> > > > Source/WebCore/page/ChromeClient.h:239
> > > > +    virtual double eventThrottlingDelay() { return 0; };
> > > 
> > > Should this use std::chrono something?
> > 
> > That is wasting performance and accuracy...but whatever, I'll do it.
> 
> Isn't it just syntactic sugar?

Nope, chrono is long integers. By picking milliseconds you lose the sub-milliseconds accuracy (like the 0.6 in 16.6ms per frame). It is also a lot more work to use long type on ARMv7 while the double were just going through VFP.
Comment 10 Simon Fraser (smfr) 2014-07-21 21:06:37 PDT
(In reply to comment #9)
> Nope, chrono is long integers. By picking milliseconds you lose the sub-milliseconds accuracy (like the 0.6 in 16.6ms per frame). It is also a lot more work to use long type on ARMv7 while the double were just going through VFP.

That sucks. Feel free to go back to doubles, but name the functions (or add comments) saying what the units are.
Comment 11 Benjamin Poulain 2014-07-21 21:08:20 PDT
(In reply to comment #10)
> (In reply to comment #9)
> > Nope, chrono is long integers. By picking milliseconds you lose the sub-milliseconds accuracy (like the 0.6 in 16.6ms per frame). It is also a lot more work to use long type on ARMv7 while the double were just going through VFP.
> 
> That sucks. Feel free to go back to doubles, but name the functions (or add comments) saying what the units are.

As far as I can remember, we have always used double for seconds (take Timer.h for example).

I don't think it is worth changing everything back. We don't need much perf or accuracy here.