Closed
Bug 1289975
Opened 8 years ago
Closed 8 years ago
Do not reset layer when setting the same dimension to canvas
Categories
(Core :: Graphics: Canvas2D, defect)
Core
Graphics: Canvas2D
Tracking
()
RESOLVED
FIXED
mozilla51
Tracking | Status | |
---|---|---|
firefox51 | --- | fixed |
People
(Reporter: ethlin, Assigned: ethlin)
References
Details
Attachments
(2 files, 1 obsolete file)
(deleted),
text/html
|
Details | |
(deleted),
patch
|
nical
:
review+
|
Details | Diff | Splinter Review |
We always reset layer when doing setDimension. I think we can reuse the layer and buffer if the dimension is the same. Then the layer doesn't need to realloate buffer.
Assignee | ||
Comment 1•8 years ago
|
||
:nical, do you think we should do it?
Flags: needinfo?(nical.bugzilla)
Comment 2•8 years ago
|
||
Per spec, touching the canvas size (even without changing it) resets the canvas drawing state. If we want to reuse the buffer, it's fine but we need to be very careful about not keeping around any additional drawing state like transforms, clips or whatnot.
I don't feel very strongly for or against keeping the canvas buffer in that case as long as it doesn't complicate the code too much, although I would rather encourage web authors to not use SetDimension as a way to clear the canvas since it is going to be slower in any case.
Do you have an idea of how often web authors touch the dimensions of a canvas without changing the actual values?
Flags: needinfo?(nical.bugzilla)
Assignee | ||
Comment 3•8 years ago
|
||
(In reply to Nicolas Silva [:nical] from comment #2)
> Per spec, touching the canvas size (even without changing it) resets the
> canvas drawing state. If we want to reuse the buffer, it's fine but we need
> to be very careful about not keeping around any additional drawing state
> like transforms, clips or whatnot.
>
> I don't feel very strongly for or against keeping the canvas buffer in that
> case as long as it doesn't complicate the code too much, although I would
> rather encourage web authors to not use SetDimension as a way to clear the
> canvas since it is going to be slower in any case.
>
> Do you have an idea of how often web authors touch the dimensions of a
> canvas without changing the actual values?
I don't know how often the web authors set the same dimension. But I tried this case on chrome and safari and I believe they reused the buffer. From my test, if a page keeps setting the same dimension to a large canvas, firefox will use a lot of CPU resource and will have memory fragment problem in the end, then crash.
So yes, if the code doesn't complicate, I think it's good to have the reusing buffer mechanism.
Assignee | ||
Comment 4•8 years ago
|
||
Keep the buffer provider while the dimension is the same.
Assignee | ||
Comment 5•8 years ago
|
||
This html keeps setting the same dimension for each frame.
Assignee | ||
Comment 6•8 years ago
|
||
In this patch, I check the dimension before ClearTarget. If the dimension is the same, then keep the BufferProvider and clear the buffer data.
I tried the testcase attachment 8777213 [details] With BufferProviderShared, the FPS increased to 24 from 18 on windows.
Attachment #8776896 -
Attachment is obsolete: true
Attachment #8777215 -
Flags: review?(nical.bugzilla)
Updated•8 years ago
|
Attachment #8777215 -
Flags: review?(nical.bugzilla) → review+
Assignee | ||
Comment 7•8 years ago
|
||
Assignee | ||
Updated•8 years ago
|
Keywords: checkin-needed
Pushed by cbook@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/e3758ab7ee78
Reuse canvas buffer when setting the same dimension. r=nical
Keywords: checkin-needed
Comment 9•8 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 8 years ago
status-firefox51:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
Updated•8 years ago
|
You need to log in
before you can comment on or make changes to this bug.
Description
•