Firefox all black when _first_ launched after login

I use Firefox on Gnome 3 on X11, installed from the current stable channel a couple of days ago. I’m a beginner with NixOS.

Every first launch of Firefox shows only a black rectangle: Firefox is not drawn. It does not seem to be frozen, though, because IIRC Firefox is now using client-side decorations, and I can click the place where the close button is (although it is invisible “in the dark”).

The second launch and 3rd, etc. are OK… until next login.

5 Likes

It might have something to do with the graphics stack. Try resizing the window to force it to redraw (eg. by dragging it to the left/right edge of the screen by mouse with Super key pressed).

Hello jtojnar. While the issue was systematic when I posted this, it stopped occurring right after that! I’ve waited for a week for the issue to occur again, and it did not. Thus I suspect a temporary issue, either in my configuration (which I progressively improved over time), or in a package that got fixed since then.
Thanks anyway! Your help has been of great value here and elsewhere :slight_smile:

I have two GNOME/Wayland systems which has the same issue. It happens seemingly randomly. On both systems I’ve configured Firefox to auto-start on login. No other app has this issue.

I’m experiencing the same issue on Nixos with Gnome. I’m using a nvidia card and it seems that wayland is being used, which might be related? I’m gonna switch to nonfree drivers and see what happens.

I can reproduce it almost 90% of the time I first run Firefox on a GNOME wayland session. Exiting and restarting Firefox solves it. It’s on a laptop with intel GPU only (from a i5-7300U CPU).

This doesn’t happen on GNOME on X.

I had this issue too. Solved it by using firefox-wayland package instead of firefox

3 Likes

Try resizing the window to force it to redraw (eg. by dragging it to the left/right edge of the screen by mouse with Super key pressed).

The Firefox window is still black. (Two different machines, both GNOME3 setups with Wayland, graphics: Intel and AMD.)

I had this issue too. Solved it by using firefox-wayland package instead of firefox

Interesting!

The only thing that package does, is running firefox with environment variable MOZ_ENABLE_WAYLAND=1. Does that mean this issue is a race? (Mis-detection of Wayland?!)

I’ve got Firefox auto-starting when I log in – what about the rest of you? Have you ever seen Firefox with black window on first launch on an idle system?

Another thing I noticed. When Firefox has black window, and I exit and re-launch, it forgets all tabs I had up.

Firefox about:support shows Window Protocol: xwayland in GNOME3 with Wayland. MOZ_ENABLE_WAYLAND=1 firefox changes it to wayland.

EDIT: Hit the 3 replies limit so continuing here:

Firefox - ArchWiki suggests using this shell snippet, which allows firefox to follow the desktop session type:

if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
    export MOZ_ENABLE_WAYLAND=1
fi

(Why doesn’t firefox behave like this in the first place? Do they consider Wayland unstable?)

EDIT 2: Now I’m running with

  environment.extraInit = ''
    if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
        export MOZ_ENABLE_WAYLAND=1
    fi
  '';

I’m also having this issue. Really annoying - nothing you can do when it renders black like this - you just have to give up all the state it’s about to lose. :man_facepalming:

Same here. Did you find that this env. variable hack actually fixes things for you?

For me the black screen-rendering issue was only once in a blue moon (so just trying this out and relaunching successfully isn’t a guarantee of a fix)

You could probably just C-S-n to restore the lost window. I’d back up the profile in .mozilla/firefox first though just to be safe.

Have you tried firefox-wayland?

Same here. Did you find that this env. variable hack actually fixes things for you?

Yes, I’m pretty sure

  environment.extraInit = ''
    if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
        export MOZ_ENABLE_WAYLAND=1
    fi
  '';

fixed it. (Alternatively, use firefox-wayland if you don’t plan on ever using X11(?).)

I haven’t experienced the issue ever since, which I would have expected would have happened a few times by now without the workaround.

I think that this proposed check should be part of the firefox wrapper, so that we can get rid of the firefox-wayland package. In any case, when installing firefox nowadays, one would expect it to be wayland-first and not opt-in.

Removal of the dedicated Wayland variants proposed in firefox, thunderbird, librewolf: Enable wayland support by default by mweinelt · Pull Request #201359 · NixOS/nixpkgs · GitHub.

4 Likes