Bug 436053

Summary: Plasma Wayland hangs when booting in basic graphics mode
Product: [Plasma] kwin Reporter: Neal Gompa <ngompa13>
Component: wayland-genericAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: critical CC: aleixpol, alex765, bcotton, nate, rdieter
Priority: VHI    
Version: 5.21.3   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In: 5.22
Attachments: weston on fbdev with nomodeset

Description Neal Gompa 2021-04-22 17:52:40 UTC
SUMMARY
When booting Fedora Linux 34 in basic graphics mode, it hangs when trying to load the KDE Plasma Wayland desktop session.

STEPS TO REPRODUCE
1. Boot the system with "nomodeset"
2. Select Plasma (Wayland) session and try to log in

OBSERVED RESULT
Hangs at a black screen.

EXPECTED RESULT
KDE Plasma desktop loads.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Fedora 34 (KDE Plasma)
(available in About System)
KDE Plasma Version: 5.21.3
KDE Frameworks Version: 5.80
Qt Version: 5.15.2

ADDITIONAL INFORMATION
This is a blocker bug for Fedora Linux 34 release: https://bugzilla.redhat.com/show_bug.cgi?id=1952431

It can be trivially reproduced with the RC ISO: https://dl.fedoraproject.org/pub/alt/stage/34_RC-1.1/Spins/x86_64/iso/Fedora-KDE-Live-x86_64-34-1.1.iso
Comment 1 Neal Gompa 2021-04-22 18:03:33 UTC
When running it manually and having the output captured locally, I get the following output from kwin:

> kwin_wayland_drm: Did not find a GPU

When attempting to force framebuffer mode, I get this instead:

> terminate called after throwing an instance of 'std::out_of_range'
>   what():  vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)
> Compositor crashed, respawning
Comment 2 Neal Gompa 2021-04-22 18:08:20 UTC
Unfortunately, I couldn't get a crash trace because gdb doesn't think that it's crashing when I do this. :(
Comment 3 Neal Gompa 2021-04-22 18:25:07 UTC
This still happens with Plasma 5.21.4...
Comment 4 Vlad Zahorodnii 2021-04-22 19:44:43 UTC
> kwin_wayland_drm: Did not find a GPU

Well, it's not very surprising. If you want to run kwin with the fbdev backend (as a normal user), make sure that you have the right group (video).
Comment 5 Neal Gompa 2021-04-22 19:54:07 UTC
(In reply to Vlad Zahorodnii from comment #4)
> > kwin_wayland_drm: Did not find a GPU
> 
> Well, it's not very surprising. If you want to run kwin with the fbdev
> backend (as a normal user), make sure that you have the right group (video).

I tried that, and nothing changed. Actually, I don't expect us to fallback to fbdev for an environment with no kernel modesetting. I tried fbdev only as a last-ditch attempt to see if something would work.
Comment 6 Vlad Zahorodnii 2021-04-22 20:12:01 UTC
The fbdev backend should work even with nomodeset=1. Can you check whether kwin starts with KWIN_FB_NO_HW_VSYNC=1? By default, kwin tries to synchronize compositing to hardware vblank events. Some (bad) fbdev drivers don't implement FBIO_WAITFORVSYNC.
Comment 7 Neal Gompa 2021-04-22 20:22:38 UTC
Nope, no dice.
Comment 8 Vlad Zahorodnii 2021-04-22 20:31:34 UTC
Weird, works for me. In order to start kwin with fbdev, I did

sudo chgrp video /data/projects/usr/bin/kwin_wayland
sudo chmod g+s /data/projects/usr/bin/kwin_wayland

env KWIN_FB_NO_HW_VSYNC=1 dbus-run-session kwin_wayland --framebuffer --exit-with-session=konsole

note that I'm also running kwin from git master. I need to try 5.21.4...
Comment 9 Neal Gompa 2021-04-22 20:46:26 UTC
I didn't know about those steps around making it a setgid binary (!!!), but I just tried that and nothing changed.
Comment 10 Vlad Zahorodnii 2021-04-22 20:55:11 UTC
Odd, 5.21 works fine for me too. As is, I guess the env var wouldn't make a difference because kwin crashes...

(In reply to Neal Gompa from comment #2)
> Unfortunately, I couldn't get a crash trace because gdb doesn't think that
> it's crashing when I do this. :(

I think you need to set a catchpoint (catch throw).
Comment 12 Vlad Zahorodnii 2021-04-22 21:12:15 UTC
Hmm, nvm. It must be something else. I'll download the iso tomorrow and try to reproduce the issue myself.
Comment 13 Aleix Pol 2021-04-23 12:25:43 UTC
I can reproduce the issue locally on my distro by adding "nomodeset" as a kernel argument, at the very end.

Even without, passing --framebuffer instead of --drm makes my kwin experience a tad worse.
Comment 14 Vlad Zahorodnii 2021-04-23 12:28:48 UTC
(In reply to Aleix Pol from comment #13)
> I can reproduce the issue locally on my distro by adding "nomodeset" as a
> kernel argument, at the very end.
> 
> Even without, passing --framebuffer instead of --drm makes my kwin
> experience a tad worse.

Does weston start with fbdev backend?

   weston --backend fbdev-backend.so
Comment 15 Aleix Pol 2021-04-23 14:11:36 UTC
Created attachment 137829 [details]
weston on fbdev with nomodeset

It looks a bit wonky but it works fine. KWin doesn't seem to refresh. I added some debug info:
void FramebufferVsyncMonitorHelper::poll()
{
    qDebug() << "poll!";
    if (ioctl(m_fileDescriptor, FBIO_WAITFORVSYNC)) {
        qDebug() << "poll error!" << strerror(errno);
        emit errorOccurred();
    } else {
        qDebug() << "poll vblank!";
        emit vblankOccurred(std::chrono::steady_clock::now().time_since_epoch());
    }
}

When running from nomodeset I get:
 KWin::FramebufferVsyncMonitorHelper::poll poll!
 KWin::FramebufferVsyncMonitorHelper::poll poll error! Inappropriate ioctl for device
Comment 16 Bug Janitor Service 2021-04-23 14:50:10 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/890
Comment 17 Aleix Pol 2021-04-23 14:52:09 UTC
With the patch in the MR kwin starts for me. The whole Plasma session doesn't start yet though, but I don't think it's KWin's fault. Or at least not this actual issue we're seeing here.
Comment 18 Bug Janitor Service 2021-04-23 15:23:12 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/891
Comment 19 Aleix Pol 2021-04-26 12:49:50 UTC
Git commit 4b3b5fa36808090a48fa5e4619a25c8fbc0270a6 by Aleix Pol Gonzalez, on behalf of Aleix Pol.
Committed on 26/04/2021 at 12:46.
Pushed by apol into branch 'master'.

fb: make it easier to run on nomodeset

In the few cases where the framebuffer is needed, we'd get problems
because ioctl(KWIN_FB_NO_VSYNC) fails.
This removes the code entirely to just use a timer to refresh.

M  +0    -1    src/plugins/platforms/fbdev/CMakeLists.txt
M  +2    -7    src/plugins/platforms/fbdev/fb_backend.cpp
M  +1    -1    src/plugins/platforms/fbdev/fb_backend.h
D  +0    -77   src/plugins/platforms/fbdev/fbvsyncmonitor.cpp
D  +0    -63   src/plugins/platforms/fbdev/fbvsyncmonitor.h

https://invent.kde.org/plasma/kwin/commit/4b3b5fa36808090a48fa5e4619a25c8fbc0270a6
Comment 20 Aleix Pol 2021-04-26 13:00:52 UTC
Git commit a21571c832202d53cc1305011b05a99656938ce9 by Aleix Pol Gonzalez, on behalf of Aleix Pol.
Committed on 26/04/2021 at 12:57.
Pushed by apol into branch 'master'.

Do not run with the drm backend if there's no dri drivers

Only defaults to the drm backend if there is a /dev/dri directory.

M  +5    -1    src/main_wayland.cpp

https://invent.kde.org/plasma/kwin/commit/a21571c832202d53cc1305011b05a99656938ce9