#1004060 lightdm-gtk-greeter: on startup, the greeter may fail to appear with a multiple-monitor setup - race condition

Package:
lightdm-gtk-greeter
Source:
lightdm-gtk-greeter
Description:
simple display manager (GTK+ greeter)
Submitter:
Vincent Lefevre
Date:
2022-01-25 10:57:03 UTC
Severity:
important
#1004060#5
Date:
2022-01-20 04:08:53 UTC
From:
To:
The upgrade to systemd 250.3-1 breaks lightdm / lightdm-gtk-greeter:
the menu bar and login dialog no longer appear.

Downgrading systemd back to 250-2.3 makes this issue disappear.

I've attached the logs from lightdm, but they may not really be useful.

#1004060#10
Date:
2022-01-20 04:24:37 UTC
From:
To:
There seem to be no additional messages compared to when it is working.
#1004060#15
Date:
2022-01-20 08:54:00 UTC
From:
To:
Am 20.01.22 um 05:08 schrieb Vincent Lefevre:

I quickly checked the changelog between 250.2 and 250.3 [1] but didn't
find anything which might appear relevant (the closest maybe being
19fbd7764d)

In a next step, I tried lightdm in VM and it came up just fine with
250.3-1 (see attached screenshot). It is thus likely that this issue is
specific to your system.

I'm thererfor marking the issue as unreproducible for now.

I guess your best bet is to run git bisect to find the offending commit.

Regards,




[1]

#1004060#24
Date:
2022-01-20 12:59:21 UTC
From:
To:
(removing "unreproducible" after adding "in a multiple-monitor setup"
in the title)
setup: 2 or 3 monitors (but the 3rd monitor, if any, is always ignored,
probably because the nVidia driver cannot handle 3 active monitors at
the same time)... so, in short, the laptop screen and an external monitor.

The second point is that there is a race condition in the detection of
the monitors on startup, so that the behavior varies.

This issue is actually also now reproducible with systemd 250.2, but
the systemd version seems to have an effect of the possible behaviors
(A, B and C below):

With systemd 250.2:
  A. 2 monitors detected, the greeter appears.
  B. 2 monitors detected, the greeter does not appear.

With systemd 250.3:
  B. 2 monitors detected, the greeter does not appear.
  C. 1 monitor detected (the laptop screen), the greeter appears on
     this monitor.

Case C is actually like a one-monitor setup (it could occur in the
past, perhaps still currently with systemd 250.2, but I haven't
done many tests with this version, mainly focusing on 250.3).
Note that when 2 monitors are detected, they are always mirrored.

Case B has never appeared before (I was always in case A or C),
while my monitor setup hasn't changed. 2 things have changed on
my laptop in the last few days:

  1. Some packages have been upgraded, but lightdm-gtk-greeter is
     still from November 2020 (2.0.8-2). Concerning lightdm, this
     is lightdm 1.26.0-8 from 11 January 2022, but only with minor
     changes compared to lightdm 1.26.0-7 from Febrary 2020.
     I might check later.

  2. I have changed the SSD disk of my laptop, and the new one is
     much faster (with 50× up to more than 1000× speedups according
     to iozone). So it is possible that delays with the old disk
     avoided the race condition.

Additional details:

The resolution of the laptop screen is 3200×1800.
The resolution of the external monitor is 3840×2160.
A 3840×2160 virtual screen is used.

I suspect that the greeter thinks that there is a second separate
screen (instead of a mirrored screen), and it puts the menu bar
and login dialog there, so that I cannot see them. The following
workaround would confirm that: set active-monitor=1 in the greeter
config file (/etc/lightdm/lightdm-gtk-greeter.conf). With this
setting, the issue on startup seems to have completely disappeared
(still no issues either with a one-monitor setup). Note: some users
say active-monitor=0, e.g.

https://forum.mxlinux.org/viewtopic.php?t=61677

but the value 0 doesn't solve the problem for me.

However, when I select a menu, the login dialog disappears and the
menu bar appears only on the right part[*] (Debian bug 993752 may be
related, but with fewer side effects), and when I click on "Restart"
or "Shut Down", the confirmation dialog does not appear (same issue?);
I can still hit Enter to confirm (default choice) or Esc to cancel.
But I can't login again since the login dialog is no longer visible
and cannot reappear.

[*] I think that the greeter assumes that the screen resolution is
3200×1800 and displays the menu bar on the right, like that:

┌─────────────────────────────┬────────┐
│                             │[-menu-]│
│                             │        │
│                             │        │
│                             │        │
│                             │        │
│                             │        │
├─────────────────────────────┘        │
│                                      │
│                                      │
└──────────────────────────────────────┘

Switching to a VT and doing a "service lightdm restart" allows one to
get the login dialog back (whether active-monitor=1 is used or not).

Another user with a similar setup seems to have almost the same issue:

https://unix.stackexchange.com/questions/636580/empty-login-screen-with-two-monitors-lightdm

#1004060#43
Date:
2022-01-20 13:29:14 UTC
From:
To:
Am 20.01.22 um 13:59 schrieb Vincent Lefevre:

[...]

Thanks for the detailed follow-up.

#1004060#48
Date:
2022-01-20 14:51:28 UTC
From:
To:
(i.e. no active-monitor=1 in lightdm-gtk-greeter.conf).

First reboot: case B, i.e. the bug also occurred.
Second reboot: case A (so that case can also occur with systemd 250.3).

I doubt that the systemd matters at all, possible except by slightly
changing the timing, which might make some case more/less likely than
before.

#1004060#53
Date:
2022-01-20 16:09:33 UTC
From:
To:
[...]

I now have a better workaround than setting active-monitor=1 (which
has issues with the menu as I've said, perhaps because the knowledge
of lightdm about the connected monitors and their configuration is
inconsistent due to the race condition): delay the setup in order to
avoid the race condition.

Adding a script /etc/lightdm/display-setup-script with "sleep 1"
and setting

  display-setup-script=/etc/lightdm/display-setup-script

in /etc/lightdm/lightdm.conf seems to solve the problem.

Note: this does not have any effect on the detected monitors, i.e.
one may still have randomly 1 or 2 detected monitors[*], but in the
case of 2 detected monitors, the greeter is visible.

[*] This is probably taken into account when lightdm starts X (which
occurs before, as seen in the lightdm.log debug log). If one wants
to fix that, one could do that with xrandr (not tested).

In short, even though there is a good workaround, the greeter should
do its best to display its menu bar and dialogs at a position where
there will be visible.

Finally, I don't know about the other greeters, but if they have a
similar issue, this workaround should also work since it is on the
lightdm level.

#1004060#58
Date:
2022-01-24 17:32:43 UTC
From:
To:
Hi Vincent,

out of curiosity, did you try to move the mouse (and bring it “back” to the
main screen) and see if the login dialog appears? My main setup also uses a
dual screen (docked laptop with an external screen), and I didn't (yet)
experienced the issue you describe, but both my screens have pretty similar
resolutions (laptop is 1920×1080, external screen is 1920×1200).

Also are both screens on and visible?

Regards,

#1004060#63
Date:
2022-01-24 17:52:28 UTC
From:
To:
I had tried to move the mouse, but this didn't have any effect. So
this is rather different than bug 993752 (where moving the mouse
switches the width of the screen) I had reported in September.

I'm wondering: in the lightdm-gtk-greeter logs, I got lots of warnings

  Drawing a gadget with negative dimensions. Did you forget to allocate a size? (node menubar owner GreeterMenuBar)

I also get some of such warnings when the bug doesn't occur.
But perhaps this shows that something is wrong.

#1004060#68
Date:
2022-01-25 09:52:25 UTC
From:
To:
Note that the virtual screen is the 4K one, thus only a part of the
desktop is visible on the laptop screen (there is no scrolling). The
mouse pointer cannot go beyond of the 4 edges (and corners) of this
4K virtual screen.
screen was visible, and it had the login dialog, but a fraction of
second later, it became black also for a fraction of second, then the
screen appeared on both monitors (laptop + left 4K monitor), mirrored,
but without the login dialog and menu.

So I suspect that lightdm detected that a second monitor was connected
*after* the greeter appeared. It handled it, but the greeter was then
no longer visible.

Note also that if I type Alt-F4 to do a shutdown, a confirmation dialog
should appear, but it doesn't. I can still confirm by hitting Enter,
though.

#1004060#73
Date:
2022-01-25 10:25:49 UTC
From:
To:
Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "metamodes" "DP-3: nvidia-auto-select +0+0, DP-4: nvidia-auto-select +0+0"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

and in the /var/log/Xorg.0.log file:

[    23.807] (II) NVIDIA(0): Validated MetaModes:
[    23.807] (II) NVIDIA(0):     "DP-3:nvidia-auto-select+0+0,DP-4:nvidia-auto-select+0+0"
[    23.807] (II) NVIDIA(0): Virtual screen size determined to be 3840 x 2160
[    23.811] (--) NVIDIA(0): DPI set to (232, 240); computed from "UseEdidDpi" X config
[    23.811] (--) NVIDIA(0):     option
[    23.811] (II) NVIDIA: Using 6144.00 MB of virtual memory for indirect memory
[    23.811] (II) NVIDIA:     access.
[    23.843] (II) NVIDIA(0): Setting mode "DP-3:nvidia-auto-select+0+0,DP-4:nvidia-auto-select+0+0"

This is what selects the mirror mode for the two monitors.

#1004060#78
Date:
2022-01-25 10:28:14 UTC
From:
To:
I guess it is, yes. Could you try without that Xorg configuration, to be sure?
I'm not really familiar with the NVIDIA driver configuration file (in my case
I'm using the XRandr configuration using Xfce display profiles) so maybe
there's indeed something fishy here.

Regards,

#1004060#83
Date:
2022-01-25 10:52:47 UTC
From:
To:
  Option "metamodes" "DP-3: nvidia-auto-select +0+0, DP-4: nvidia-auto-select +0+0"

line, then, based on 2 tests, both the laptop screen and the right
4K monitor are enabled, with the laptop screen on the left and the
right 4K monitor on the right (so, not a mirror mode). The greeter
correctly appears, and when I move the mouse pointer from one
screen to the other one, the greeter switches to where the mouse
pointer goes. So it is working correctly in this case. However,
when I log in then log out, I get the following error in Xorg.0.log
(I had already noticed this issue in the past, and that's probably
why I added an explicit Xorg monitor configuration):

[    83.150] (WW) NVIDIA(0): No valid modes for
[    83.150] (WW) NVIDIA(0):     "DFP-3:nvidia-auto-select,DFP-4:nvidia-auto-select,DFP-5:nvidia-auto-select";
[    83.150] (WW) NVIDIA(0):     removing.
[    83.150] (WW) NVIDIA(0):
[    83.150] (WW) NVIDIA(0): Unable to validate any modes; falling back to the default mode
[    83.150] (WW) NVIDIA(0):     "nvidia-auto-select".
[    83.150] (WW) NVIDIA(0):
[    83.151] (WW) NVIDIA(0): No valid modes for
[    83.151] (WW) NVIDIA(0):     "DFP-3:nvidia-auto-select,DFP-4:nvidia-auto-select,DFP-5:nvidia-auto-select";
[    83.151] (WW) NVIDIA(0):     removing.
[    83.151] (EE) NVIDIA(0): Unable to use default mode "nvidia-auto-select".
[    83.151] (EE) NVIDIA(0): Failing initialization of X screen 0
[    83.719] (II) UnloadModule: "nvidia"
[    83.719] (II) UnloadSubModule: "wfb"
[    83.719] (II) UnloadSubModule: "fb"
[    83.719] (EE) Screen(s) found, but none have a usable configuration.
[    83.719] (EE)
Fatal server error:
[    83.719] (EE) no screens found(EE)
[    83.719] (EE)
Please consult the The X.Org Foundation support
         at http://wiki.x.org
 for help.
[    83.719] (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
[    83.719] (EE)
[    83.758] (EE) Server terminated with error (1). Closing log file.

Indeed, the driver cannot handle 3 monitors.

With the mirror mode, if lightdm thinks that it is in a left/right
configuration, perhaps the greeter is displayed on the right side,
while only the left side is visible.