Bug 70646 - Ensure periodic flushing of accelerated canvas drawing context
Summary: Ensure periodic flushing of accelerated canvas drawing context
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Matthew Delaney
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-21 13:56 PDT by Matthew Delaney
Modified: 2011-10-21 17:00 PDT (History)
3 users (show)

See Also:


Attachments
Patch (6.13 KB, patch)
2011-10-21 14:15 PDT, Matthew Delaney
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 Matthew Delaney 2011-10-21 13:56:45 PDT
If flushes don't happen regularly enough on a canvas drawing context that is accelerated, subsequent call performance can get pretty bad. "Regularly enough" is geared toward a 30-60hz paint cycle. So, this patch ensures that we're getting flushes of a rate in that range if they're not already happening (e.g. from HTMLCanvasElement::paint calls) in that range.
Comment 1 Matthew Delaney 2011-10-21 14:15:03 PDT
Created attachment 112020 [details]
Patch
Comment 2 Simon Fraser (smfr) 2011-10-21 14:23:01 PDT
Comment on attachment 112020 [details]
Patch

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

> Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp:168
> +    m_context = adoptPtr(new GraphicsContext(cgContext.get()));

Should you set m_data.m_lastFlushTime on context creation?
Comment 3 Darin Adler 2011-10-21 14:25:47 PDT
Comment on attachment 112020 [details]
Patch

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

> Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp:184
>  GraphicsContext* ImageBuffer::context() const

Is this really the best bottleneck for the timing logic? Can we instead put this at the ends of the drawing operations that accumulate state in the context? Or are those too many of those. This hook seems particularly awkward since it’s just a getter.
Comment 4 Darin Adler 2011-10-21 14:27:51 PDT
Comment on attachment 112020 [details]
Patch

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

> Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp:188
> +        double elapsedTime = currentTimeMS() - m_data.m_lastFlushTime;

What is the performance cost of doing this every time we call context()? Seems like it might be high.
Comment 5 Matthew Delaney 2011-10-21 15:08:04 PDT
(In reply to comment #2)
> Should you set m_data.m_lastFlushTime on context creation?
Yea, that's better.

(In reply to comment #3)
> > Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp:184
> >  GraphicsContext* ImageBuffer::context() const
> 
> Is this really the best bottleneck for the timing logic? Can we instead put this at the ends of the drawing operations that accumulate state in the context? Or are those too many of those. This hook seems particularly awkward since it’s just a getter.
That's what I had originally, but there are about 5-10 calls and it would require having all this logic in GraphicsContext which becomes a bit more cluttered.


(In reply to comment #4)
> (From update of attachment 112020 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=112020&action=review
> 
> > Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp:188
> > +        double elapsedTime = currentTimeMS() - m_data.m_lastFlushTime;
> 
> What is the performance cost of doing this every time we call context()? Seems like it might be high.
Running it locally, I didn't notice any difference in perf on one page I had open. I'll try it out on a handful of other pages now.
Comment 6 Matthew Delaney 2011-10-21 16:42:55 PDT
Couldn't find any performance deficit, so I think we're good. Committing now.
Comment 7 Matthew Delaney 2011-10-21 17:00:57 PDT
Committed r98171: <http://trac.webkit.org/changeset/98171>