simple tip to fix Firefox 75 performance on AMD (possibly also Intel) GPU's

UPDATE: If you're using Firefox 76 or above, this should be fixed. The issue was caused by libdrm-2.4.101. Bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1623885

  1. open https://webglsamples.org/aquarium/aquarium.html and note the framerate
  2. open about:config, find security.sandbox.content.read_path_whitelist and set it to /sys/
  3. restart firefox, open aquarium again

What's happening here is firefox (actually mesa, because of firefox security sandbox) having a problem determining the proper DRI driver to use, with amdgpu kernel module at least it tries to use amdgpu_dri and fails, since that's part of AMDGPU-PRO. Its own sandboxing is causing it, given access to /sys/ it's using radeonsi_dri as it should be.

This makes huge difference even with default basic compositing, many things are using webgl, for example google maps, the performance difference is obvious. You can also enable gfx.webrender.all and gfx.webrender.compositor for few fps more and less cpu usage (on my A8-7600 I'm getting 11fps by default, 40fps and 40% cpu usage with basic compositing but whitelist modified, and 45fps/30% cpu usage with webrender+compositing enabled - doesn't come close to 60fps with 10x the amount of fish in brave/chromium, but it's progress and google maps changes from stuttery mess to perfectly usable).

9 Likes

Nice workaround.

This boosted my WebGL framerate about 15-20 FPS.

Sad thing? This is at least 2 years old and supposedly fixed...

Interesting ...
I did also experience ~double framerate here.
I have not investigated further.

It would seem that Mesa has once again moved their stuff to another location. :slight_smile:

Yeah, that's most likely. Still, I'm not using some bleeding edge git build, just regular 20.0.4, firefox team should at least test against that for regressions.
I mean, this is obvious by launching firefox from terminal and opening any webgl page, it's throwing the same errors it was throwing 2 years ago.

Here something you can try in the command line.

MOZ_ACCELERATED=1 MOZ_WEBRENDER=1 firefox

It seem to work will for me. It another option.

It doesn't. This will just enable webrender (without compositing afaik), without touching the DRI part. WebGL performance will not be fixed by that. I know, I've tried that earlier.

This was posted today. About firefox experimenting with WebGPU.

1 Like

Saw it earlier. Interesting, unrelated though. Makes one wonder how many security holes will it open.

How is it unrelated? It will used vulkan driver that are support in mesa or amdvlk. Should make used of the gpu a lot better.

ONLY for webapps using WebGPU API. Everything so far, including any webgl content, will NOT be affected.

Just try firefox nightly. There a huge performance gain on my end. Was capping out at 62. Now I get around 115 to 132 FPS. And average around 122 to 124.

My screen is 60Hz one, won't see that many frames per second.

And on more serious note, not sure what's your point here. This is a bug, neither using your environment variables nor using firefox nightly will fix it, unless you did check the bug description at bugzilla and can confirm that it's fixed in nightly. I doubt it though, it looks like nobody noticed the regression that quite possibly started before mesa 20.x. It's a security sandbox - related issue, no amount of tweaks will change the performance when firefox (actually, mesa because of a firefox bug) falls back to software rendering for webgl. The only way around it until firefox team fixes it, is to use that whitelist setting that effectively makes mesa bypass the sandbox and work as intended.

Very interesting topic. I have nvidia graphics and not amdgpu. I compared firefox to chromium. What a huge difference!

My max fps is 60 fps due to monitor sync rate.
Firefox is going below 60 fps to 36 fps with 5.000 fishes.
Chromium is going below 60 fps to 50 fps with 25.000 fishes

And while firefox is going to a crawling 9 fps with 30.000 fishes, chromium is still delivering 42 fps.

Amazing. And this all with firefox webgl rendering on a GeForce GTX 1660 Ti

chromium is still better in this test. Just not by default.

chromium --disable-frame-rate-limit --disable-gpu-vsync

wow. That kicks up my chromium to 800-900 fps with 500 fishes.

Is there a similar setting for firefox?

My guess is that firefox copies back the webgl buffer to ram, then copies it back to the gpu, wasting memory bandwidth. They have to sort it out to do proper gpu compositing of webgl, or it simply has no chance matching chromium performance. I'm getting 15fps with 5k fishes in firefox, 60fps (capped) in brave (chromium-based), so yeah (benchmark in opening post was obviously with default 500 fishes).

There's no point in going above the refresh rate, unless damaging your hardware is the goal. For example, I'm always enforcing vsync in games via mesa/vulkan drivers, otherwise some games can display hundreds (even thousands) of fps in menu/inventory screens. Makes coils whine, even in case of integrated graphics. Hardware does not like it.

Same here, this "quick fix" doubled the framerate on the aquarium sample.

Unfortunately it completely breaks Google Maps - atleast on Firefox 75. Haven't tried anything else... :grin:
Screenshot at 2020-04-24 07-43-47

Forum kindly sponsored by