Open Bug 1978851 Opened 1 year ago Updated 2 months ago

Testcase applying a ctx.filter blur N times on canvas is 28x slower in Firefox compared to Chrome (followup to bug 1978498)

Categories

(Core :: CSS Parsing and Computation, defect)

defect

Tracking

()

People

(Reporter: mayankleoboy1, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

Open testcase
Enter 5000000 in the input box (you can also input a smaller value)
Click Run

Chrome: https://share.firefox.dev/4kTVhMR (330ms)
Firefox : https://share.firefox.dev/450lSld (9s)

Flags: needinfo?(emilio)

So what's going on in Chrome is that they just have a fast path for setting the same filter over and over: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/canvas/canvas2d/canvas_2d_recorder_context.cc;l=1474;drc=fadc961e5da1d6cb183185a49f958d79591e91d9

How's perf if you increment a counter in the loop so that setting filter is not a no-op?

Flags: needinfo?(emilio) → needinfo?(mayankleoboy1)

Updates testcase which does this :

 for (let i = 0; i < n; i++) {
        const blurAmount = i * 0.0001; // Increase blur radius gradually
        ctx.filter = `blur(${blurAmount}px)`;

N= 5000000
Firefox: https://share.firefox.dev/3IJFpPy (9.5s)
Chrome: https://share.firefox.dev/410NVjq (2.7s)

Flags: needinfo?(mayankleoboy1)
Blocks: 1980560
See Also: 1943230

The severity field is not set for this bug.
:tlouw, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(tlouw)
Severity: -- → S3
Flags: needinfo?(tlouw)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: