MOZ_X11_EGL/Nvidia: Black border around Pocket or webextension popup
Categories
(Core :: Graphics: WebRender, defect)
Tracking
()
People
(Reporter: jan, Assigned: rmader)
References
(Blocks 2 open bugs)
Details
Attachments
(3 files)
Gnome X11, GTX 1060, Nvidia driver 470
Click on the Pocket icon.
mozregression --launch 2021-09-16
(MOZ_X11_EGL=1 mozregression --launch 2021-09-16 --pref gfx.webrender.all:true)
May or may not be helpful:
https://github.com/qt/qtbase/commit/0712b4ff7139b5c2cc96fd40ea7bb77a9bb8fd1c
https://github.com/qt/qtbase/blob/dev/src/gui/opengl/platform/egl/qxlibeglintegration.cpp
- It uses XGetVisualInfo for EGL. Firefox uses it only for GLX.
https://github.com/qt/qtbase/blob/dev/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp
https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_platform_x11.txt
- It uses XGetVisualInfo for EGL. Firefox uses it only for GLX.
- It uses XCreateColormap for EGL. Firefox uses it only for GLX in glxtest or in gfxXlibSurface.cpp.
https://developer.nvidia.com/blog/egl-eye-opengl-visualization-without-x-server/
https://download.nvidia.com/XFree86/Linux-x86_64/304.137/README/xcompositeextension.html
Reporter | ||
Comment 2•3 years ago
•
|
||
Overview:
-
EGL benefits: It shares most code with Wayland: It enables support for partial present (bug 1648799), zero-copy Dmabuf WebGL (bug 1655026 fixes bug 1010527), VAAPI hardware decoding (bug 1610199).
-
MOZ_X11_EGL/Mesa still uses
- GLX_SGI_video_sync (there is no real alternative at the moment other than switching to a 60 Hz software timer: bug 1640779 comment 38)
- GLX visual selection (bug 1702546, https://gitlab.freedesktop.org/mesa/mesa/-/issues/149, https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12819).
-
GLX/Nvidia
- seems to have problems with GLX_SGI_video_sync (e.g. bug 1628913)
- suffers from GLX swap interval being set to 1: bug 1716049 (GLX/Xwayland/Mesa suffers as well: bug 1635186, fixed by switching to EGL which already uses swap interval 0 and shares one context for all windows)
- in some circumstances tries to display popups with wrong visual which causes a crash.
-
MOZ_X11_EGL/Nvidia uses pure EGL:
- 60 Hz software timer like software rendering because GLX_SGI_video_sync caused a crash when mixing with EGL (bug 1728473)
- pure EGL visual selection: IIUC, current code selects the first fitting visual, but not the one with transparency that should come after it. (?)
In theory, bug 1717816 could be reverted until pure EGL visual selection has been fixed, but it was already fragile with pure GLX. - Partial present is supported as well
- Dmabuf WebGL will work here, too: https://www.phoronix.com/scan.php?page=news_item&px=NVIDIA-GBM-Works-With-Sway
Assignee | ||
Comment 3•3 years ago
•
|
||
Does this happen with SW-WR as well? If not, then bug 1479135 and bug 1710855 are likely related and we likely need to adapt https://searchfox.org/mozilla-central/source/widget/gtk/nsWindow.cpp#931-936 for this case.
Reporter | ||
Comment 4•3 years ago
|
||
Yes, all panels are fine with SW-WR:
mozregression --launch 2021-09-17 --pref gfx.webrender.software:true
HW WR:
Black borders do not show up for Protections, Site Information, Bookmark and Main menu panels. Autoscroll icon is also fine.
Black borders only show up for Pocket and uBlock Origin.
Reporter | ||
Comment 5•3 years ago
•
|
||
(In reply to Robert Mader [:rmader] from comment #3)
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12819
Back then Nvidia was apparently against the Mesa commit you are trying to revert:
https://bugs.freedesktop.org/show_bug.cgi?id=67676#c17
https://lists.x.org/archives/mesa-dev/2015-April/082140.html
We always have and will continue to support alpha blending of ARGB visuals/configs.
Wouldn't that mean that if your MR was accepted, Mesa would behave like Nvidia again?
Can you reproduce this bug if you patch your Mesa with your MR and switch to GLContextEGL::FindVisual?
If yes, could comment 0 help you to fix GLContextEGL::FindVisual?
If yes, wouldn't that be the strongest pro-argument for merging your MR we could provide?
Assignee | ||
Comment 6•3 years ago
|
||
(In reply to Darkspirit from comment #5)
Wouldn't that mean that if your MR was accepted, Mesa would behave like Nvidia again?
Yes, I think so. I'm still trying to get feedback on all of that, kinda frustrating :(
Assignee | ||
Updated•3 years ago
|
I have the same issue, but it's only around popups launched by extensions. For example - if the overflow menu is opened by hand, the popup looks fine, but if it gets popped open by an extensions - like, for example 1password, then the black border is present (looks like transparency is missing). I posted some images on Twitter - https://twitter.com/jonrandy/status/1442062264505233414
Comment 8•3 years ago
|
||
Changing severity to S2 because of pretty ugly and visible side effects, no workaround or settings mitigation available right now.
Reporter | ||
Comment 9•3 years ago
•
|
||
Workaround: gfx.x11-egl.force-disabled=true (bug 1732002)
At the moment, you can only choose which bugs you want to encounter: GLX vs. EGL
MOZ_X11_EGL (which also makes x11 glitches less likely: bug 1678804) fixes an actually severe bug:
Multiple windows with WebRender/GLX can be considered slightly broken on Nvidia (bug 1716049) and horribly broken for some non-Gnome Mesa users (bug 1732365). Only alternative to EGL would be uplifting a barely testable change to legacy GLX: bug 1732365 comment 29
A bug like this has been the default on Linux desktops with disabled compositor for many years (bug 1479135). It was fixed by enforcing software WebRender for those widgets on uncomposited desktops. Options for this bug:
a) uplift a fixed GLContextEGL::FindVisual
b) uplift SW WR enforcement for affected widgets on non-Mesa X11 (comment 3)
c) uplift bug 1732002
d) wontfix for 94, but have at least bug 1716049 fixed by using EGL.
Comment 10•3 years ago
•
|
||
Workaround: gfx.x11-egl.force-disabled=true (bug 1732002)
The exact wording for S2 is "a satisfactory workaround doesn’t exist" and from your comment I think that is the case because the above causes arguably worse problems?
(a) or (b) seem like good options, but it's not like I know what I'm talking about here :-P
Assignee | ||
Comment 11•3 years ago
|
||
I think we should just land bug 1732002 - as long as bug 1731172 is not solved, EGL should not ship to stable IMO.
Reporter | ||
Comment 12•3 years ago
|
||
For bug 1731172 Firefox should add to the release notes that package maintainers must set the required Nvidia driver flag according to the Nvidia manual.
The Ubuntu Firefox 92 snap package already ships pre-Nightly MOZ_ENABLE_WAYLAND which means EGL. The snap is already affected by bug 1731172. That's why we must ask all distributions anyway to package the Nvidia driver properly: bug 1731172 comment 18
Reporter | ||
Comment 13•3 years ago
|
||
Disabling EGL/Nvidia (bug 1732002) would require us to fix GLX/Nvidia (bug 1732365 comment 29).
Assignee | ||
Comment 14•3 years ago
|
||
(In reply to Darkspirit from comment #12)
For bug 1731172 Firefox should add to the release notes that package maintainers must set the required Nvidia driver flag according to the Nvidia manual.
I don't think that's a feasible solution. The feature does not appear to be fully ready and distributions will not suddenly enable it just because Firefox says they have to. Concerning MOZ_ENABLE_WAYLAND
: I don't think that matters - Ubuntu doesn't enable Wayland session by default on Nvidia.
would require us to fix GLX/Nvidia
It's already broken in stable - if we don't fix it in 94, that's not the end of the world.
Comment 15•3 years ago
|
||
As a workaround here we can fall back to SW rendering of all popups on X11/EGL. I don't think it matter much to have HW accelerated popup rendering :)
Comment 16•3 years ago
|
||
Comment 17•3 years ago
|
||
Comment 18•3 years ago
|
||
bugherder |
Reporter | ||
Comment 19•3 years ago
•
|
||
Screencast: I managed to get a transparent EGL window on Nvidia.
At the moment I just hardcode framebuffer_config_attrib_list[] = { EGL_CONFIG_ID, 0x008,
etc., but the conclusion seems to be:
If eglGetConfigAttrib EGL_NATIVE_VISUAL_ID (0x82) is what gdk_x11_visual_get_xvisual(gdk_screen_get_rgba_visual) gave us (0x82), then it's the correct Nvidia egl framebuffer config (0x8).
First I tried to set the visual in realize(), but then eglCreateWindowSurface failed with EGL_BAD_MATCH.
gtk_widget_set_visual() must be called with the window_widget_ptr from gtk_window_new(),
not with the widget_ptr inside the g_signal_connect realize function.
I'll attach the testcase after cleaning it up a bit.
Reporter | ||
Comment 20•3 years ago
|
||
Gnome Xwayland (GDK_BACKEND=x11): On Mesa it works slightly different, but it works as well.
$ eglinfo
shows many mesa egl framebuffer configs, but visid is always either 0x24TC or 0x25DC. If we want TrueColor, then 0x24 is the only xvisual that all of mesa's egl framebuffer configs "want", but that one is not transparent.
0x01 32 0 8 8 8 8 0 0 0 0 0x24TC a y y y win,pb,pix
But we can ignore it!
Just set the xvisual 0x505 on the widget which we can get from gdk_screen_get_rgba_visual and transparent EGL windows work on Mesa as well:
GdkScreen *gdk_screen_ptr = gtk_widget_get_screen(widget_ptr);
GdkVisual *gdk_visual_ptr = gdk_screen_get_rgba_visual(gdk_screen_ptr);
//Visual *x_visual_ptr = gdk_x11_visual_get_xvisual(gdk_visual_ptr);
//uint32_t x_visual_id = x_visual_ptr->visualid;
gtk_widget_set_visual(widget_ptr, gdk_visual_ptr);
Comment 21•3 years ago
|
||
I've just noticed that the main windows on Firefox Nightly are also exhibiting the same behaviour - the rounded top corners of the windows on the normal Ubuntu theme have a black background - https://imgur.com/a/4IIUl7X
Reporter | ||
Comment 22•3 years ago
|
||
Yes, it's in the table in bug 1733094 comment 14.
Reporter | ||
Comment 23•3 years ago
•
|
||
(Screencast in comment 19.)
Could this work for Firefox as well?
- Ask GTK for an opaque or rgba GdkVisual and set it on the GtkWidget.
(I assume this wasn't possible in the past when WebRender required depth because gdk_screen_get_rgba_visual and gdk_screen_get_system_visual select a GdkVisual with 32 (transparent) or 24 (opaque) "X visual depth", but with 0 depth.
"EGL_BAD_MATCH is generated if the pixel format of native_window does not correspond to the format, type, and size of the color buffers required by config.") - Get X Visual ID of the GdkVisual.
- Get EGL framebuffer configs that meet our criteria.
- Select the fb config that has the same X Visual id as our widget. (Nvidia: The first fb config wants an opaque x visual, the second one wants a transparent x visual.)
- Fallback for Mesa: If none matched, select the first EGL framebuffer config.
Reporter | ||
Updated•3 years ago
|
Comment 24•3 years ago
|
||
(In reply to Darkspirit from comment #23)
Created attachment 9244123 [details]
visualtest.c(Screencast in comment 19.)
Could this work for Firefox as well?
- Ask GTK for an opaque or rgba GdkVisual and set it on the GtkWidget.
(I assume this wasn't possible in the past when WebRender required depth because gdk_screen_get_rgba_visual and gdk_screen_is_composited select a GdkVisual with 32 (transparent) or 24 (opaque) "X visual depth", but with 0 depth.
"EGL_BAD_MATCH is generated if the pixel format of native_window does not correspond to the format, type, and size of the color buffers required by config.")- Get X Visual ID of the GdkVisual.
- Get EGL framebuffer configs that meet our criteria.
- Select the fb config that has the same X Visual id as our widget. (Nvidia: The first fb config wants an opaque x visual, the second one wants a transparent x visual.)
- Fallback for Mesa: If none matched, select the first EGL framebuffer config.
Hello Jan, yes, I think that can work as we don't need the z buffer any more.
Description
•