Firefox 94 to start using EGL on Linux
mozillagfx.wordpress.com
mozillagfx.wordpress.com
I did not encounter any bugs so far.
The only reason I haven't made the full change for Linux yet is because I watch a lot of Twitch.tv and the CPU usage hits 45-50% on average even at 720p.
This may or may not affect using mpv's ytdl integration (where mpv internally calls ytdl to obtain a stream).
I enabled EGL in response to seeing your comment this morning, then found myself having to turn it back off after the very first suspend/resume.
When you do 1) on the GPU (well, not exactly GPU, but video decode block on the videocard, but that's not really important now), you end up with decoded frame in VRAM. Reading it back to system RAM, just to push it back to VRAM elsewhere is expensive (if the graphic is not UMA, then you go via PCIE back and forth) and unnecessary in the end, it is more efficient to have some way to directly share content from 1) into 2) already in VRAM.
For that, both subsystems must support some way of sharing memory buffers. VA-API (for 1) and Mesa (for 2) support DMA-BUF, so that's the reason why it is used here.
[0]: https://www.khronos.org/registry/vulkan/specs/1.2-extensions...
In web browsers, things are more delicate because videos live within the complex context that is a webpage -with its own layer of hardware acceleration!-, and failures can be brutal depending on your browser, hardware and driver quality (crashes, video corruption, etc).
The pain-in-the-ass-ness to enable it on a given browser varies with time and browser/OS and along regressions, stack changes, and maintainer priorities. From personal experience during the past years, it has never been great on Linux:
- In Firefox, regressions have been frequent.
- In Chrome, the feature is here but Google disables it at build time in their official builds (my personal intuition is that they do enable it for their Chromebooks, but they don't want to support the wild west of broader Linux configuration and old/broken driver fun). However, out of official Chrome builds, several distributions builds (Arch, Debian) of Chromium now enable it at build time, so it's possible to try to use it.
So, it's finnicky to enable, but sometimes feasible, until it's no longer :D . To give it a try on a Linux box, the well-maintained Arch wiki is what you want (and these sections are mostly not specific to Arch):
- Firefox: https://wiki.archlinux.org/title/Firefox#Hardware_video_acce...
- Chrome: https://wiki.archlinux.org/title/Chromium#Hardware_video_acc...
Since announcing support for HW video initially on Wayland, Firefox has been off to the races on this [0]. Despite requiring lots of hacks to enable flags as you linked on the Arch Wiki, one of which now suggests disabling the sandbox for content processes and a major red flag, it somehow worked.
For one reason or another [1], Firefox chose to lock the video drivers to the old i965 drivers instead of choosing the newer iHD driver. A weird decision that still applies to current builds.
There have been incompatibility issues with video codecs. In my experience I can play h264 videos with hardware acceleration but not vp9 with the flatpak distribution. With vanilla package, both h264 and vp9 video is hw accelerated.
I could also have sworn that video acceleration support has gotten worse over time since the introduction.
I now get a weird artifact at the bottom half of the screen only when watching YouTube videos. [2]
Video hardware acceleration is not entirely doomed on Linux. Even if Chromium does not want to make any move toward this direction in this century. Gnome web or rather Epiphany has stellar video acceleration support by using Gstreamer plugins. So it is possible to get hw video working on a browser.
[0] https://mastransky.wordpress.com/2020/06/03/firefox-on-fedor...
Ubuntu 21.10 currently comes with the 470 series driver.
You can set `MOZ_ENABLE_WAYLAND=1` in your environment to launch Firefox under Wayland natively.
You can check what window protocol your Firefox at `about:support` (Window Support).
X11_EGL
DMABUF
and should say something like "available by default"/enabled or similar wording. Otherwise it'll either say unsupported/disabled or will be missing.
[0] https://wiki.archlinux.org/title/systemd/User#Environment_va...
The headline is kind of wrong, then. This is about X11. Firefox on modern (Wayland) desktops is already using EGL.
Nvidea seems to jump on the GBM wagon, at least for some GPUS.
> Generic Buffer Management (GBM) is an API that provides a mechanism for allocating buffers for graphics rendering tied to Mesa. GBM is intended to be used as a native platform for EGL on DRM or openwfd. The handle it creates can be used to initialize EGL and to create render target buffers.
Where
> The Direct Rendering Manager (DRM) is a subsystem of the Linux kernel responsible for interfacing with GPUs of modern video cards. DRM exposes an API that user-space programs can use to send commands and data to the GPU
https://en.wikipedia.org/wiki/Mesa_(computer_graphics)#Gener... and https://en.wikipedia.org/wiki/Direct_Rendering_Manager
What does it mean for nvidia to jump on the GBM bandwagon? Firefox would just talk (perhaps via some intermediate API like EGL or BGM) to the Linux kernel for talking to an nvidia card, if I understand it correctly?
yes, I'm not sure how everything is divvied up. NVIDIA ships multiple kernel modules in their driver, and one of them is called ‘nvidia_drm’. So idk, maybe you have to use their DRM implementation or something
But it does matter for developers of Wayland compositors. A lot.
This e.g. mean developer cost for gnome/kde would be reduced and sway(wlroots) would work on devices with Nvidia cards (at least some).
I.e. in general it makes it easier for everyone, except maybe Nvidea. But even for them it (long term) could make maintenance simpler.
I've seen many webapps that are completely unrelated to Google, that are more performant on Chromium browsers, just because most developers are using them for development. It's also easier to justify spending time fixing bugs/improving performance if it affects the majority of users, instead of spending effort for 4% of users.
It's not just that they passively focus on Chromium, they will deliberately trash performance on every other browser without a second thought.
Or having two different frontends, or stopping feature development to make Firefox developers happy. Which are terrible choices.
And going beyond of what standards offer is pretty much how web evolution had always happened.
Google built their redesign on top of a prototype set of APIs that didn't end up being standardized. That's their own fault, and it should be their problem.
It's not just Firefox devs, it's everyone else apart from Chrome, because Chrome had gone and implemented said APIs that were never standardized, so they didn't need a polyfill. And I would bet money that ShadowDOM v0 would have been removed from the Chrome codebase earlier if not for the fact that Youtube was using it - they wouldn't have forced themselves to use the same polyfill as everyone else.
Shipping a new, standards incompliant frontend was a choice, not an immutable fact of nature. There was nothing wrong with the previous frontend apart from the fact that nobody is going to get promoted for not shipping the new thing. And since the consequences of shipping impact everyone except for Google, who cares, let's ship the garbage UI anyway.
Don't make excuses for this kind of behavior. Google absolutely has the resources to do these things properly but they didn't.
There is a real problem here and it's absolutely related to the fact that Google is only incentivized to develop/test on their own browser, but that's really orthogonal to other browsers being slow or not being able to improve performance of a polyfill.
Google did not have to publicly ship their pre-standard experimental "v0" web components implementation so early in Chrome. They chose to do so regardless of what other browser vendors expressed.
Likewise they did not have to make YouTube use them so soon, thus forcing other browsers to rely on a polyfill that could not feasibly be made remotely performant compared to just implementing web components more quickly, wink wink.
They chose to do these things the way they did. They wanted to ship it on their timeline, and to hell with what other browsers wanted to spend time on first instead. They wanted to look like they were heroes for pushing the web forward, while in reality they were just holding other vendors and APIs back to get the one they valued the most done first, no matter how much of a mess they caused in the process (the transition from v0 to v1 was hardly quick or painless). And that's just web components.
When is the last time you saw Firefox ship such a major web API in such a non-final and un-vetted state, and then use one of the largest web properties on Earth to get others to prioritize it as they wished? Or even Apple, for that matter?
It's flat out ridiculous to try equating the vendors in this manner. They don't have the market dominance or even the same force of apologists burying the lede on their bad behaviour.
I'm sure the other browsers also have their own Project Fugus underway too, where they're just shipping a slurry of new APIs regardless of whether anyone else will ever implement them? Or is that the others' fault somehow too, because they should also be trying to fragment the web as much as possible as quickly as possible?
If we collectively just want Chromium to be the only engine because we value rapidly iterating on new APIs more than anything, then let's at least be honest about it.
I'm not trying to be a downer here. Realistically, there will always be a browser out in front that is going to iterate on features faster than the others. That's normal as long as you have more than one browser. If we want to criticize Google for practicing anti-competitive behavior then let's do that, but it just really doesn't make sense to me to put "they shipped a feature that someone else didn't" in that category.
Google didn't merely "ship a feature someone else didn't". They keep shipping new features as they wish, whether others even agree. They have in fact accelerated that attitude with Project Fugu. Some of them are quite complex or consequential APIs.
They do not deserve a free pass for it because Mozilla once shipped one or two relative minor features before Chrome did, or Apple added some weird CSS visual property for their latest iPhones without consensus. We're talking orders of magnitude of difference here.
The problem isn't who is first to ship. It's the casual disregard for even reaching consensus on the basics before shipping something, the sheer rate of output, the interop issues left in the wake, and the anti-competitive tactics being applied. Those are not "hypotheticals" in the slightest.
What is hypothetical is acting like anyone else could just magically compete on those terms. Microsoft couldn't keep up with them. Opera couldn't. No new engine has even come close to breaking into a general market yet, though a couple are feverishly trying.
Is that really ok with us? If so, then let's just be honest. Let's just say "new APIs are more important to us than engine diversity, and we don't mind Google being as evil as possible to kill the other engines off." As a webcompat worker, I'd love to see that honesty.
That is, it all depends on the full context. Competition is fine, but not anti-competitive behaviour. I maintain that we have had too much of the latter from Google, and that it is only increasing as folks intentionally look the other way and try to boil arguments away to mere deflections and other apologia.
Example: Our startup's product (https://benaco.com).
WebGL is slower on Firefox (e.g. this bug on Linux: https://bugzilla.mozilla.org/show_bug.cgi?id=1010527), so I use Chromium to work on it, despite using Firefox for everything else, for 19 years.
This is literally one of the big things changed by what's described in the article (for those still using X11; it's already been solved for quite some time on Wayland)
> Even wirh webrender, EGL and dmabuf all enabled, performance is still not at par with chrome. Bug 1684224
which shows 5x higher FPS in Chromium than in Firefox.
There will be more to do until general parity, even past FF 94.
Firefox isn't terrible, but there is a noticeable startup lag and I get random freezes a lot more often.
https://github.com/KhronosGroup/Vulkan-Guide/blob/master/cha...
GL and GLES do the actual rendering. EGL and friends are basically just the glue layer to get things to the screen. (Well, to the window manager)"
https://www.reddit.com/r/opengl/comments/11q0oz/what_is_the_...
EGL can also be used directly with kernel mode setting and buffer management. No window managers necessary!
A simple example I found:
It doesn't really accomplish interop between different APIs on its own, though of course various interop methods are based on it — e.g. if you want to import a dmabuf, you'd use EGL_EXT_image_dma_buf_import. But, say, on the Vulkan side you'd use VK_EXT_external_memory_dma_buf — there is no EGL with Vulkan, Vulkan has its own WSI subsystem.
Reading that helps a bit, but you still won't understand the complicated graphics stack without prior knowledge. Is there a good introduction that systematically goes through all (or most) of the components for the average Python, C, database etc. programmer who knows absolutely nothing about computer graphics?
Edit: See also thread https://news.ycombinator.com/item?id=29048815
It seems like it's a standardized interface for a windowing library like wayland/x11 to talk to a graphics driver, specifically for setting up regions of the screen which will be rendered into by something (opengl etc.)? So there were non-standard ways before?
– IRC, #freebsd-desktop
https://matrix.to/#/!KYWCpFvqYdeGYJdkxS:libera.chat/$ZOJrjgp...
some of us like our software to be stable and reliable, and not switch to the newest bullshit just because they can. I'm still bitter about being forced to find a workaround for FF requiring pulseaudio. Am I now gonna need to find a workaround for this? I run FF 94 right now, and will upgrade with trepidation...
(shoutout to https://github.com/i-rinat/apulse. THANKS.)