Closed Bug 1848171 Opened 10 months ago Closed 10 months ago

High CPU usage with WebGL content on GTK backend

Categories

(Core :: Graphics: CanvasWebGL, defect)

defect

Tracking

()

RESOLVED FIXED
118 Branch
Tracking Status
firefox118 --- fixed

People

(Reporter: david.turner, Assigned: david.turner)

References

(Blocks 2 open bugs)

Details

Attachments

(2 files)

Attached file about_support.txt

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0

Steps to reproduce:

Load this UFO test: https://www.testufo.com/stutter#demo=smooth&foreground=ffffff&background=000000&pps=720

Actual results:

  • On an i7-12700H using Firefox 116.0, MOZ_ENABLE_WAYLAND=1, on Debian Bookworm with GNOME, I see CPU usage of 50% of a core. See attached about:support
  • On a Raspberry Pi 4 the CPU usage is about 120% of a core and the content only renders around 50fps.
  • CPU usage is similar with Xwayland and with native X11.
  • CPU usage is the same in current bookmarks/central

Expected results:

On Windows CPU usage is only about 3% of a core, so I expect Firefox CPU usage to be similar on Linux.

See profile at https://share.firefox.dev/3QzkBfI

Looking at the CanvasRenderer thread, I noticed that we are creating a new DMABufSurface for every frame, so a lot of CPU time is going into the GBM BO allocations.

Looking in GLScreenBuffer.cpp I can see a DMA buffer pooling mechanism used on Android to limit the number of surface allocations (bug 1646073). I did a quick hack to enable this buffer pool on Linux/GTK and this halved the CPU usage. I'll push up a patch for this after I've done some clean-up and testing.

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

Component: Untriaged → Graphics: CanvasWebGL
Product: Firefox → Core

I think the texture-recycling part of this is equivalent to Bug 1800205 so I will talk to sotaro

Depends on: 1800205

Currently WebGL on the GTK backend constantly creates new DMAbuf
surfaces for every frame, causing high CPU usage (Bug 1848171). At
60fps on a high-end Intel CPU this uses 50% of a core. On a Raspberry Pi
4 this uses around 100% of a core and limits FPS to about 50.

This patch allows DMABufSurfaces to be recycled and so greatly reduces
CPU usage on WebGL content (on a Raspberry Pi 4 this halves the CPU
usage on https://www.testufo.com/stutter#demo=smooth&foreground=ffffff&background=000000&pps=720

This patch was originally authored by Sotaro Ikeda but did not solve
their problem, I am co-opting it to fix Bug 1848171.

Assignee: nobody → david.turner
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Pushed by lsalzman@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/9ea3b1eb1a63
Recycle SharedSurface_DMABUF on WebGL with RemoteTexture r=gfx-reviewers,sotaro
Status: ASSIGNED → RESOLVED
Closed: 10 months ago
Resolution: --- → FIXED
Target Milestone: --- → 118 Branch
Duplicate of this bug: 1800205
Blocks: 1835275
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: