Closed Bug 1498291 Opened 6 years ago Closed 3 months ago

CSS blur effects are highly inefficient and very slow in canvas filters (Sister bug of Chrome bug #726143).

Categories

(Core :: Graphics: Canvas2D, defect, P4)

defect

Tracking

()

RESOLVED DUPLICATE of bug 1912897

People

(Reporter: patrick.martin.r, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: parity-edge, perf)

Attachments

(1 obsolete file)

User Agent: Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0 Steps to reproduce: I have been developing a Advanced Substation Alpha subtitle renderer and have run into a bug with both Firefox and chrome in all versions that work with canvas filters. A complex example can be found at: http://ec2-54-193-19-209.us-west-1.compute.amazonaws.com/demo/ Some of the chrome devs produced a test case that causes chrome to replicate the slowness via a different method than the complex version but it's not guaranteed to do the same in firefox: https://jsfiddle.net/0vLruL2x/1/ Here's one with an FPS counter: https://jsfiddle.net/mroqd18a/ Actual results: Css blurring in canvas filters causes extreme rendering lag, firefox is not as bad at this as chrome but it's still bad enough to cause 5-10 fps even on the highest end computers. Chrome produces 1-5 fps. Expected results: A reasonable framerate should be expected. It shouldn't really lag at all, it might make sense to take a look at the gaussian blur algorithm in the libass open source subtitle renderer as it's been heavily optimized for performing high-speed gaussian blurs on the CPU, but really this should be performed on the gpu.
Note that if you have canvas filters turned off this bug will not appear.
Edge is quite smooth.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: parity-edge, perf
Blocks: 1498321
This is running an older build of my code, but the new version still triggers this bug.
Priority: -- → P4
:lsalzman, can you comment to the bug?
Flags: needinfo?(lsalzman)
Whiteboard: [gfx-noted]
I have a more extreme demo that I can upload instead
*a more extreme example of this issue
Here is a video that is a better test case of this as it's specifically designed to stress the blurring functions: http://ec2-54-193-19-209.us-west-1.compute.amazonaws.com/test_blur/
(In reply to Patrick Martin from comment #7) > Here is a video that is a better test case of this as it's specifically > designed to stress the blurring functions: > http://ec2-54-193-19-209.us-west-1.compute.amazonaws.com/test_blur/ profile: https://perfht.ml/2J2j1xX
Flags: needinfo?(lsalzman)
Whiteboard: [gfx-noted]
(In reply to Mayank Bansal from comment #8) > (In reply to Patrick Martin from comment #7) > > Here is a video that is a better test case of this as it's specifically > > designed to stress the blurring functions: > > http://ec2-54-193-19-209.us-west-1.compute.amazonaws.com/test_blur/ > > profile: https://perfht.ml/2J2j1xX From profile, WebGL and Canvas2D(D2D backend) were used. And VideoDecoderManagerChild::Readback() appeared in the profile, since MP4 video is normally decoded in GPU process.
Yeah, the player uses webgl for compositing of subtitles and canvas 2d for rendering text.

I also am noticing an extreme performance degradation when using CSS filters. It doesn't matter if the filter is applied in the Javascript canvas context or in CSS directly.

See a very simple example here: https://codepen.io/anon/pen/NoJwJR

(In reply to chrisc from comment #11)

I also am noticing an extreme performance degradation when using CSS filters. It doesn't matter if the filter is applied in the Javascript canvas context or in CSS directly.

See a very simple example here: https://codepen.io/anon/pen/NoJwJR

Profile: https://perfht.ml/2V264sA

Any updates on this? Here's an updated link to a more extreme case: https://about.ilovepie.dev/test_blur/

Flags: needinfo?(lsalzman)

it does seem that performance has improved somewhat since i last checked though.

(In reply to Patrick Martin from comment #14)

it does seem that performance has improved somewhat since i last checked though.

Good enough to close?

Flags: needinfo?(lsalzman) → needinfo?(patrick.martin.r)

I haven't tested this in a while, as far as I know though, the algorithms used in gaussian blurring for CSS filters are still very slow compared with some other implementations out there (for example the Gaussian blur implementation in libass) and force the canvas to use software rendering. I've had to work around it using a WebGL shader that implements Gaussian blur. What i would suggest is a simple test case with 4 or five spinning rectangles that are drawn in canvas 2D using the Gaussian blur filter with a large sigma (> 80) that overlap each other. That should demonstrate the issue. I'll fix the link i posted in comment 13 and re link it in a bit.

Flags: needinfo?(patrick.martin.r)
Severity: normal → S3

This could be fixed by using SIMD when not using the GPU. It's been a while since I have checked CSS bluring's performance as I have since switched to using WebGL for my blur needs so someone might want to reverify this.

Attachment #9384938 - Attachment is obsolete: true

I will dupe it over to bug 1912897

Status: NEW → RESOLVED
Closed: 3 months ago
Duplicate of bug: 1912897
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: