Open Bug 2038926 Opened 27 days ago Updated 23 days ago

Repeated drawImage from the same WebGL canvas repeatedly SnapshotExternalCanvas instead of reusing unchanged source snapshot

Categories

(Core :: Graphics: Canvas2D, defect)

Firefox 150
defect

Tracking

()

UNCONFIRMED

People

(Reporter: iamdjj, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36

Steps to reproduce:

  1. Open the attached firefox-webgl-drawimage-repro.html in Firefox/Nightly on macOS.
  2. Use the default settings: 120 items, 6 columns, 160px cells, DPR cap 1.
  3. Let the animation run.
  4. Compare with Chromium/Chrome on the same machine.

Note: for testing cells below 128px, the gfx.canvas.accelerated.min-size = 128; setting bypass the accelerated SnapshotExternalCanvas path.

Actual results:

Firefox is much slower than Chromium/Chrome.

I see a lot of PWebGL::Msg_SyncPing using the profiler.

I was able to test that the optimized path (SnapshotExternalCanvas) related to D243399 (fixing bug 1938053) is used, at least for accelerated Canvas2D destinations.

However, Firefox appears to perform one SnapshotExternalCanvas per
drawImage() call, even when all calls use the same unchanged WebGL canvas source in the same animation frame/JS task.

With 120 destination canvases, this means roughly 120 external snapshots per frame from the same unchanged WebGL source.

Expected results:

Firefox should avoid repeatedly snapshotting the same unchanged WebGL canvas source for multiple Canvas2D drawImage() calls in the same frame/recording batch.

A local experiment that reuses the external snapshot for repeated same-source draws made the repro smooth, with performance similar to Chromium/Chrome.

Attached file My local edits

The Bugbug bot thinks this bug should belong to the 'Core::Graphics: Canvas2D' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Graphics: Canvas2D
Product: Firefox → Core
Severity: -- → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: