Closed Bug 1788205 Opened 2 years ago Closed 1 year ago

X11+Xwayland: black window when launched. Possibly caused by Xwayland-on-demand or Firefox race condition when switching between composited/non-composited X11

Categories

(Core :: Widget: Gtk, defect, P2)

Firefox 104
Desktop
Linux
defect

Tracking

()

RESOLVED MOVED

People

(Reporter: guterrien, Unassigned, NeedInfo)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: regression)

Attachments

(9 files)

Attached image Capture.png

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

Steps to reproduce:

Boot.
Enter your password's user.
Simple left-click on the Firefox's menu icon.

Actual results:

A window opens which is totally black and remains black.

Expected results:

A Firefox window should have opened correctly.

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

Component: Untriaged → Widget: Gtk
Product: Firefox → Core

Original issue was filed downstream, and contains more details: https://bugs.launchpad.net/ubuntu/+source/firefox/+bug/1987976.

This seems to happen only with the firefox snap, and not consistently.

Blocks: snap
Summary: firefox black window → firefox snap - black window when launched

The reporter wrote in the Launchpad bug report that an apparently reliable workaround is to run firefox with MOZ_ENABLE_WAYLAND=1.

Could you please run firefox with MOZ_ENABLE_WAYLAND=1, browse to about:support, copy the raw data into the clipboard and share it here?

Flags: needinfo?(guterrien)
Flags: needinfo?(guterrien)
Component: Widget: Gtk → Third Party Packaging
Product: Core → Firefox Build System

This morning I forgot to launch Firefox with the command line, I mean I launched Firefox by clicking the icon and it worked! I rebooted to try again but unfortunately it didn't work the second time.

I've just found something which seems strange to me.
I would like to show you screenshots but I cannot attach them...

On this screenshot CaptureBugzilla1788205_1.png of Ubuntu Software, I can see one update available: Firefox!!! How is that possible whereas my system is up to date as you can see on attachment CaptureBugzilla1788205_2.png????

Are there two different ways for updating???
Why the Firefox update does not appear in the update manager window, which is so far, for me, the only way to update my system??

That's a question for Ubuntu people, looks like the update is for Snap package while your second screenshot is the apt update status

Can you share the output of the following commands?

apt policy firefox

snap info firefox
Flags: needinfo?(guterrien)

nicolas@nicolas-fixe:$ apt policy firefox
firefox:
Installé : 1:1snap1-0ubuntu2
Candidat : 1:1snap1-0ubuntu2
Table de version :
*** 1:1snap1-0ubuntu2 500
500 http://fr.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
100 /var/lib/dpkg/status
nicolas@nicolas-fixe:
$ snap info firefox
name: firefox
summary: Mozilla Firefox web browser
publisher: Mozilla✓
store-url: https://snapcraft.io/firefox
contact: https://support.mozilla.org/kb/file-bug-report-or-feature-request-mozilla
license: unset
description: |
Firefox is a powerful, extensible web browser with support for modern web
application technologies.
commands:

  • firefox
  • firefox.geckodriver
    snap-id: 3wdHCAVyZEmYsCMFDE9qt92UV8rC8Wdk
    tracking: latest/stable/ubuntu-22.04
    refresh-date: aujourd'hui à 09h04, heure des Rocheuses
    channels:
    latest/stable: 104.0.2-1 2022-09-06 (1810) 185MB -
    latest/candidate: 104.0.2-1 2022-09-05 (1810) 185MB -
    latest/beta: 105.0b8-1 2022-09-07 (1814) 187MB -
    latest/edge: 106.0a1 2022-09-07 (1818) 183MB -
    esr/stable: 91.13.0esr-1 2022-09-02 (1791) 161MB -
    esr/candidate: 102.2.0esr-2 2022-09-02 (1793) 182MB -
    esr/beta: ↑
    esr/edge: 102.2.0esr-2 2022-09-02 (1793) 182MB -
    installed: 104.0.2-1 (1810) 185MB -
Flags: needinfo?(guterrien)

Oh sorry for the strikethrough. I thing it came automatically with the syntax. Let's try this way:

nicolas@nicolas-fixe:$ apt policy firefox
firefox:
Installé : 1:1snap1-0ubuntu2
Candidat : 1:1snap1-0ubuntu2
Table de version :
*** 1:1snap1-0ubuntu2 500
500 http://fr.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
100 /var/lib/dpkg/status
nicolas@nicolas-fixe:$ snap info firefox
name: firefox
summary: Mozilla Firefox web browser
publisher: Mozilla✓
store-url: https://snapcraft.io/firefox
contact: https://support.mozilla.org/kb/file-bug-report-or-feature-request-mozilla
license: unset
description: |
Firefox is a powerful, extensible web browser with support for modern web
application technologies.
commands:

  • firefox
  • firefox.geckodriver
    snap-id: 3wdHCAVyZEmYsCMFDE9qt92UV8rC8Wdk
    tracking: latest/stable/ubuntu-22.04
    refresh-date: aujourd'hui à 09h04, heure des Rocheuses
    channels:
    latest/stable: 104.0.2-1 2022-09-06 (1810) 185MB -
    latest/candidate: 104.0.2-1 2022-09-05 (1810) 185MB -
    latest/beta: 105.0b8-1 2022-09-07 (1814) 187MB -
    latest/edge: 106.0a1 2022-09-07 (1818) 183MB -
    esr/stable: 91.13.0esr-1 2022-09-02 (1791) 161MB -
    esr/candidate: 102.2.0esr-2 2022-09-02 (1793) 182MB -
    esr/beta: ↑
    esr/edge: 102.2.0esr-2 2022-09-02 (1793) 182MB -
    installed: 104.0.2-1 (1810) 185MB -

Does Ubuntu Software still offer an update for firefox?

Flags: needinfo?(guterrien)
Attached image Capture2022-09-12.png

No update offered anymore.

Flags: needinfo?(guterrien)

I mean: for Firefox.

The severity field is not set for this bug.
:gerard-majax, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(lissyx+mozillians)

I have the same black window problem. Can I help?

I can reproduce it with upstream "firefox" unpacked from firefox-104.0.2.tar.bz2 ! (As well as by using the snap)

It seems not to happen if instead of the "firefox" launcher binary, I run "firefox-bin" directly. What's the difference?

It happens the first time I start firefox after logging in. If I quit firefox and start it again, it works. (The window may start black, but it changes after a few seconds. As reported here: https://bugs.launchpad.net/ubuntu/+source/firefox/+bug/1838963 )

My GPU description is "Mesa DRI Intel(R) HD Graphics 2000 (SNB GT1)". (No secondary GPU). I use Ubuntu 22.04.1 (x86_64).

It seems not to happen if instead of the "firefox" launcher binary, I run "firefox-bin" directly. What's the difference?

Nevermind. I think it can happen with either. It's just a bit random whether it happens or not.

(In reply to Alan Jenkins from comment #20)

It seems not to happen if instead of the "firefox" launcher binary, I run "firefox-bin" directly. What's the difference?

Nevermind. I think it can happen with either. It's just a bit random whether it happens or not.

Just to clavify, you reproduce with both Snap and tarball downloaded from mozilla.org ?
Can you share about:support ? Can you verify with MOZ_ENABLE_WAYLAND=1 firefox if the issue disappears?

Flags: needinfo?(lissyx+mozillians)

Sorry, I can't deal with the randomness. Let's simplify -

$ sudo snap disable firefox
firefox disabled

$ cat ~/.local/share/applications/firefox2.desktop
[Desktop Entry]
Version=1.0
Name=Firefox Web Browser 2
Exec=/bin/bash -c "/home/alan/firefox-104.0.2/firefox/firefox"
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=firefox
Categories=GNOME;GTK;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;video/webm;application/x-xpinstall;
StartupNotify=true
StartupWMClass=firefox
$

With the above, if I log in and click firefox, I get stuck at the black window. If I quit firefox and try again, I get a temporary black window, and then a working firefox.

If I edit the file and change it to "MOZ_ENABLE_WAYLAND=1 /home/alan/firefox-104.0.2/firefox/firefox", then two things change:

  1. When I log in and click firefox, firefox works the first time. I don't have to quit it and click it again before I can use firefox.
  2. When firefox starts, there is no temporary black screen either.

When I was trying to launch firefox from the terminal, I also noticed a difference in debug messages:

$ /bin/bash -c "/home/alan/firefox-104.0.2/firefox/firefox"
ATTENTION: default value of option mesa_glthread overridden by environment.
ATTENTION: default value of option mesa_glthread overridden by environment.
ATTENTION: default value of option mesa_glthread overridden by environment.
[2022-09-19T12:44:36Z ERROR viaduct::backend::ffi] Missing HTTP status
[2022-09-19T12:44:36Z ERROR viaduct::backend::ffi] Missing HTTP status
$

$ /bin/bash -c "MOZ_ENABLE_WAYLAND=1 /home/alan/firefox-104.0.2/firefox/firefox"
Unsupported modifier, resource creation failed.
XXX: resource creation failed
Unsupported modifier, resource creation failed.
XXX: resource creation failed
Unsupported modifier, resource creation failed.
XXX: resource creation failed
[2022-09-19T12:44:43Z ERROR viaduct::backend::ffi] Missing HTTP status
[2022-09-19T12:44:43Z ERROR viaduct::backend::ffi] Missing HTTP status
$

The severity field is not set for this bug.
:gerard-majax, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(lissyx+mozillians)

(In reply to Alan Jenkins from comment #22)

Sorry, I can't deal with the randomness. Let's simplify -

$ sudo snap disable firefox
firefox disabled

So you dont use Snap anymore from that point

$ cat ~/.local/share/applications/firefox2.desktop
[Desktop Entry]
Version=1.0
Name=Firefox Web Browser 2
Exec=/bin/bash -c "/home/alan/firefox-104.0.2/firefox/firefox"

This is a mozilla-downloaded binary right?

Terminal=false
X-MultipleArgs=false
Type=Application
Icon=firefox
Categories=GNOME;GTK;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;video/webm;application/x-xpinstall;
StartupNotify=true
StartupWMClass=firefox
$

With the above, if I log in and click firefox, I get stuck at the black window. If I quit firefox and try again, I get a temporary black window, and then a working firefox.

That means you repro the black window issue without using Snap, right?

If I edit the file and change it to "MOZ_ENABLE_WAYLAND=1 /home/alan/firefox-104.0.2/firefox/firefox", then two things change:

  1. When I log in and click firefox, firefox works the first time. I don't have to quit it and click it again before I can use firefox.
  2. When firefox starts, there is no temporary black screen either.

So does it means that forcing Wayland on mozilla's binary fixes the issue completely?

Flags: needinfo?(lissyx+mozillians) → needinfo?(alan.christopher.jenkins)
Severity: -- → S2
Priority: -- → P2

Yes to all of the above.

I disabled the Firefox snap. I used this download from mozilla.org, and I still had the black window issue.

And forcing Wayland seems to fix that completely.

Flags: needinfo?(alan.christopher.jenkins)
Blocks: wayland
No longer blocks: snap
Component: Third Party Packaging → Graphics
Product: Firefox Build System → Core
Summary: firefox snap - black window when launched → black window when launched
No longer blocks: wayland

Alan, since you happen to repro without snap, was there a release you got working correctly? Can you try and go back in time and find with mozregression maybe which patch triggered the issue ? https://mozilla.github.io/mozregression/quickstart.html

Flags: needinfo?(alan.christopher.jenkins)

Another interesting point would be if setting gfx.x11-egl.force-disabled (in about:config) to true helps with the issue.

Also, I suppose gfx.webrender.software:true works around the issue?

Nice tool. It seemed like nightlies default to Wayland, so I had to test with MOZ_ENABLE_WAYLAND=0.

Bisecting the temporary black window gave:

9:33.09 INFO: Last good revision: d1eb6fe5a1fa5457425c5a33f212516a5eeaa381
9:33.09 INFO: First bad revision: 498e0e6f9b19107c8c17525a3d01a659f89002e8
9:33.09 INFO: Pushlog:
https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=d1eb6fe5a1fa5457425c5a33f212516a5eeaa381&tochange=498e0e6f9b19107c8c17525a3d01a659f89002e8

With the mozilla-central (nightly?) builds downloaded by mozregression, I could not reproduce the main issue, the black window that remains black. Any suggestions there?

So the following was tested back on my 104.0.2 (originally downloaded from https://download.mozilla.org/?product=firefox-latest-ssl&os=linux64&lang=fr ) :

Another interesting point would be if setting gfx.x11-egl.force-disabled (in about:config) to true helps with the issue.

No.

Also, I suppose gfx.webrender.software:true works around the issue?

No.

Based on the bisection result, I also tried XDG_CURRENT_DESKTOP="". This changed the main issue but did not solve it. The window did not remain black, but it did not show firefox controls either.

Flags: needinfo?(alan.christopher.jenkins)

Oh, that's really interesting...so does launching with MOZ_GTK_TITLEBAR_DECORATION=system also solve the issue?

(In reply to Robert Mader [:rmader] from comment #32)

Oh, that's really interesting...so does launching with MOZ_GTK_TITLEBAR_DECORATION=system also solve the issue?

It does about the same as XDG_CURRENT_DESKTOP="". Instead of remaining black, basically nothing gets drawn. The inside of the window just shows my desktop wallpaper.

(I think XDG_CURRENT_DESKTOP="" shows a titlebar, and MOZ_GTK_TITLEBAR_DECORATION=system doesn't).

So the fact that even software rendering (gfx.webrender.software:true) is broken strongly suggest that something with the affected setup is deeply broken - disabling hardware acceleration is usually our last resort for such issues.

Alan, have you tested a few other Xwayland apps and do they all work correctly? And is this on a clean system without weird modifications? :P

Weird!

I can run xterm. Including immediately after login, which is how I've been reproducing this Firefox issue.

I can change my hacked-up .desktop file to run "WAYLAND_DISPLAY='' libreoffice" instead, and the libreoffice window seems fine.

I can run glxgears, xeyes, and xvidtune ok :-). (Didn't bother trying those immediately after login).

The system should be clean of development or debug hacks. It's a desktop that runs Ubuntu, and I'm not the person who uses it normally. I have some setup scripts (Ansible), that mostly just install the right packages.

You might have noticed from the Launchpad bug, some reddit users reported this on June 30. The poster thought it "just started happening with Firefox 102.0". I don't know if that was the problem. On the system I have, I had it as soon as I updated to Ubuntu 22.04, which was a bit later.

Reddit link: https://old.reddit.com/r/Ubuntu/comments/voat7x/firefox_1020_snap_in_ubuntu_2204_launches_to/

Of course the Launchpad bug is only voted as "affects 4 people", so it doesn't sound like it's universal.

(In reply to Alan Jenkins from comment #31)

Nice tool. It seemed like nightlies default to Wayland, so I had to test with MOZ_ENABLE_WAYLAND=0.

Bisecting the temporary black window gave:

9:33.09 INFO: Last good revision: d1eb6fe5a1fa5457425c5a33f212516a5eeaa381
9:33.09 INFO: First bad revision: 498e0e6f9b19107c8c17525a3d01a659f89002e8
9:33.09 INFO: Pushlog:
https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=d1eb6fe5a1fa5457425c5a33f212516a5eeaa381&tochange=498e0e6f9b19107c8c17525a3d01a659f89002e8

Emilio, could it be a regression from bug 1756903 ?

Flags: needinfo?(emilio)

Seems possible, but I don't know what might be going on in the reporter's machine, since that's a setup that works ~everywhere else?

To double-check, can you confirm that MOZ_GTK_TITLEBAR_DECORATION=system works, but MOZ_GTK_TITLEBAR_DECORATION=client doesn't? Also does enabling the system titlebar (from the customize page) prevent it from happening?

Flags: needinfo?(emilio)

(In reply to Alan Jenkins from comment #35)

Weird!

Indeed :( But thanks for testing!

I can run glxgears, xeyes, and xvidtune ok :-). (Didn't bother trying those immediately after login).

I think these are all apps with server side decorations (SSD). Could you try GDK_BACKEND=x11 cheese or GDK_BACKEND=x11 gedit? So we have GTK apps with client side decorations (CSD)?

To double-check, can you confirm that MOZ_GTK_TITLEBAR_DECORATION=system works

No, I say MOZ_GTK_TITLEBAR_DECORATION=system fails. Just slightly differently. Instead of a black window, only a border (drop shadow?) is drawn. See screenshot. The gnome notification bubble "firefox is ready" is flickering, constantly and quickly.

  1. If I launch gedit with GDK_BACKEND=x11, as the first app after logging in, it appears usable. However the window is incorrectly drawn with a square window border. See screenshot.

    If I then launch firefox, using the snap for convenience, firefox is usable.

  2. (As before) If I launch firefox using the snap for convenience, as the first app after logging in, it is not usable. Because the entire window is black.

    If I then launch gedit with GDK_BACKEND=x11, its window borders are drawn correctly.

It feels like the problem is to do with socket-activated Xwayland.

I can suppress the issue where firefox remains black, by editing my .desktop file to run "xlsclients" first. I.e.:

Exec=/bin/bash -c "xlsclients; MOZ_ENABLE_WAYLAND=0 /home/alan/firefox-104.0.2/firefox/firefox"

Similarly, the issue with gedit drawing square window border corners is suppressed if I use

Exec=/bin/bash -c "xlsclients; GDK_BACKEND=x11 gedit"

(With less confidence: it seemed that if I ran weston, then "Xwayland :2", then "MOZ_ENABLE_WAYLAND=0 DISPLAY=:2 firefox", then the resulting firefox window was usable).

Hm, this pretty much sounds like Gnome-Shell bug around Xwayland-on-demand to me - so maybe a better place for that would be https://gitlab.gnome.org/GNOME/mutter/-/issues (or a Ubuntu bug, in case they ship some custom patches).

Setting Regressed by field after analyzing regression range found by mozregression in comment #31.

Keywords: regression
Regressed by: 1756903

Something similar happened on Fedora. So I've reported to GNOME.

"Timing/race condition with Xwayland-on-demand breaks firefox & confuses gedit etc"
Link: https://gitlab.gnome.org/GNOME/mutter/-/issues/2472

(In reply to Robert Mader [:rmader] from comment #42)

Hm, this pretty much sounds like Gnome-Shell bug around Xwayland-on-demand to me - so maybe a better place for that would be https://gitlab.gnome.org/GNOME/mutter/-/issues (or a Ubuntu bug, in case they ship some custom patches).

...

Thanks @sourcejedi! I've so far been unable to reproduce this on four different systems with Fedora 36 or Manjaro,

Hi Robert. I got a new reproducer for Firefox, which doesn't use Xwayland. I ran this on my Fedora 36 system, the system that required a quick hand to reproduce with my .desktop file method.

WARNING for people with photosensitive epilepsy. This will cause full-screen flickering.

  1. Make sure user X is logged out, or at least not running Firefox.
  2. Switch to a text console (ctrl + alt + f6) and log in.
  3. startx /usr/bin/fvwm
  4. Left click on the desktop to open the app menu. Open an xterm.
  5. Open a second xterm.
  6. In xterm 1, run while true; do picom; sleep 0.1; killall picom; done. The screen will now start flickering.
  7. In xterm 2, run firefox

Result: Firefox doesn't draw anything inside its window, or is completely black.

Duplicate of this bug: 1797800
Flags: needinfo?(emilio)

[Firefox 109]
If I am not mistaken:

  1. it is consistently happening (i.e., completely black right after after boot), and
  2. when closed for the first time, and reopened, it opens and asks whether to restore previous session or not, and
  3. I always close Firefox before shutting down, so point 2 should not be applicable

Robert, do you know what we should be trying to do here? Should it remain an S2 for Firefox?

Flags: needinfo?(robert.mader)

Since this was reported for a device running the Crocus Mesa driver in situations where implicit drm modifiers are most likely used (Xwayland, X11 compositor), there's certain chance that it will be fixed by https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21209

Michelet/Alan, any chance you could test that commit?

Flags: needinfo?(robert.mader) → needinfo?(guterrien)

Oh wow, I think I just managed to reproduce this on my Iris laptop - in a fresh session with Xwayland on demand. That and comment 45 points to a race condition in the FF code regarding switching between composited and non-composited X11.

Duplicate of this bug: 1817252
Duplicate of this bug: 1822374
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Unspecified → Linux
Hardware: Unspecified → Desktop
Summary: black window when launched → X11+Xwayland: black window when launched. Possibly caused by Xwayland-on-demand or Firefox race condition when switching between composited/non-composited X11
Component: Graphics → Widget: Gtk
Depends on: wayland-stable

Redirect a needinfo that is pending on an inactive user to the triage owner.
:stransky, since the bug has high severity and recent activity, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(guterrien) → needinfo?(stransky)

When Bug 1725245 lands we'll test it and see results on Wayland/XWayland environment.

Flags: needinfo?(stransky)

In Ubuntu 23.04 kernel 6.1 or 6.2 Firefox does not start at all using his .desktop file, starts with a black screen the 1st time is started from terminal with 'firefox' or 'snap run firefox' and start fine the 2nd time is started from terminal with 'firefox' or 'snap run firefox'

No longer duplicate of this bug: 1822374
See Also: → 1822374
Duplicate of this bug: 1825991

It's shipping as a SRU (23.04) this week. Older releases will come after.

Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
See Also: → 1828244
Resolution: FIXED → MOVED
Duplicate of this bug: 1830482
Duplicate of this bug: 1832688
Duplicate of this bug: 1833474
Duplicate of this bug: 1834232
Duplicate of this bug: 1829390
Duplicate of this bug: 1831711
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: