Bug 431968 - Plasma 5.21 wayland crashes and has render issues
Summary: Plasma 5.21 wayland crashes and has render issues
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 5.20.90
Platform: Manjaro Linux
: NOR major
Target Milestone: ---
Assignee: Zamundaaa
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-23 02:23 UTC by Tito
Modified: 2021-02-01 11:35 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
shows render issues (27 bytes, text/plain)
2021-01-23 02:23 UTC, Tito
Details
Wayland session log file (3.89 MB, text/plain)
2021-01-30 21:15 UTC, Tito
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tito 2021-01-23 02:23:10 UTC
Created attachment 135079 [details]
shows render issues

SUMMARY

after the long waited beta release of plasma beta 5.21 for the multi gpu support on wayland and fractional scaling, the DE dosent behave normally

STEPS TO REPRODUCE
1. install plasma trough yay plasma-meta and installing the version 5.21-1 from kde-unstable repository;
install kde applications trough yay kde-applications-meta and using version 20.12-3 from extra repository;
install wayland trough yay plasma-wayland-session and installing the version 5.20.90-1 from kde-unstable repository;
2. login in to Plasma wayland
3. enjoi the bugs

OBSERVED RESULT

right and left monitors (connected trough intel's iGpu) are not rendered properly, see attachment; tho the cursor is all right
bottom bar disappears a few minutes after login, but its still clickable
searching more than one letter on the super menu (bottom left) crashes the whole plasma DE
logging out from the DE crashes the DE
most of the icons are missing (90/95% of them)
many more...

EXPECTED RESULT

no crashes and glitches and correct rendering of all the screens.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma:
(available in About System)
KDE Plasma Version: 5.20.90
KDE Frameworks Version: 5.79.0
Qt Version: 5.15.2
Kernel: 5.10.9

ADDITIONAL INFORMATION

setup:
i7 8700k at  5ghz with iGpu
rx 5700 as dedicated graphics
4 monitors:
bottom: 1080p 165hz connected trough rx 5700
top: 4k 60hz with 125% scale connected trough rx 5700
right: 1080p 60hz connected trough intel's iGpu
left: 720p that runs at 1080p connected trough intel's iGpu
any monitor setup produces the same problem.
Comment 1 Zamundaaa 2021-01-23 15:20:49 UTC
I think the problem with the broken outputs is caused by the internal GPU not supporting scanning out linear buffers. I'll have to look into using modifiers to not require linear buffers if that's the case, although I'm not sure in what timeframe that could be solved.

First though, let's see if there are some error messages. For that please run the session with the environment variable "QT_LOGGING_RULES=kwin_drm.debug=true" (for example you can put it in /etc/environment) and attach the file "~/.local/share/sddm/wayland-session.log" afer a reboot
Comment 2 Tito 2021-01-23 16:05:11 UTC
Here is attached the log file.
https://pastebin.com/EZC1mMhs
i needet to use pastebin because the Add an attachment function gives me a permession error. (ERR_ACCESS_DENIED)
Comment 3 Zamundaaa 2021-01-23 16:18:58 UTC
It looks like the environment variable is missing; I probably got it wrong, sorry about that. Try with "QT_LOGGING_RULES=kwin_*.debug=true" instead, that will enable all debugging
Comment 4 Tito 2021-01-23 17:13:17 UTC
All good. Here is the new file:
https://pastebin.com/fDGGTMyS
Comment 5 Zamundaaa 2021-01-23 19:52:46 UTC
Okay, that looks all good, and reinforces my suspicions about the linear format. I'll see what I can do
Comment 6 Zamundaaa 2021-01-30 14:27:40 UTC
It's possible that this patch could affect your setup: https://invent.kde.org/plasma/kwin/-/merge_requests/642

It most likely won't solve your problem but if you can test if it changes anything that would be nice.
Comment 7 Tito 2021-01-30 16:29:03 UTC
As of right now it just crashed to the login manager a few seconds after i try to login. although i dont really know if i did the stuff right, heres it what i did:
applied the pach using the file provided. 
compiled and installed it following this as refernece: https://community.kde.org/KWin/Building
installed a fresh copy of both plasma-meta and kde-applications-meta just to exclude any other possibilities of errors
tried both with and without the edit to the env file as suggested in the previous link

thanks for the help!
Comment 8 Zamundaaa 2021-01-30 16:53:10 UTC
That reference is for KDE4, I'm not surprised that it doesn't work. You should probably remove env file, it could potentially cause problems.

For compiling KWin you can either use kdesrc-build (https://community.kde.org/Get_Involved/development#Set_up_kdesrc-build + add a section in .kdesrc-buildrc to switch to my branch) to compile a whole session to log into (overkill but safe) or install it like this:

git clone https://invent.kde.org/zamundaaa/kwin.git -b possible-multi-gpu-fix
mkdir build && cd build
cmake ..
sudo make install -j8

And then after testing reinstall the kwin package to replace the files with stable kwin (or wait for it to update).
Comment 9 Tito 2021-01-30 19:14:51 UTC
i followed the second method, and the result was pretty similar.

the screens connected to the intel igpu behaved like shown before, tho after the loading of the logo finished, the desktop remained black, and any attempt at restarting/logging out trough the ctrl+alt+canc menu lead to weird and inconsistent behavior like poweroff or restart.

should i try the first method?
Comment 10 Zamundaaa 2021-01-30 20:12:06 UTC
Okay, that's not good but I kinda expected it. No need to try the other method, the result won't be any different.

I have one more easy thing to try that might work. For testing that use
git clone https://invent.kde.org/zamundaaa/kwin.git -b possible-mgpu-fix-2
Comment 11 Tito 2021-01-30 20:46:27 UTC
This patch seems to behave a bit better:
First try the two screens connected to the igpu didnt have any graphical issues, although i didnt managed to go all the way to the desktop as it stalled to a black screen with the cursor, this time the ctrl+alt+canc menu behaved correctly logging me out without any problems.

at a second try the two screens connected to the igpu were black (the screen was off) as they didnt recived any signal and went to power saving mode. the rest behaved as stated before.
on this last try i also got a weird behavior as i heard the cpu fan spin up while logging out of kde, when i went back to check the cpu usage was at 100, any graphical resource monitor couldnt tell me which program was cousing this, except for htop wich showed some programs at around 260% cpu usage, killing the process fixed this. sadly i didnt noted the names of those as i thought they werent the cause of the issue.
Comment 12 Zamundaaa 2021-01-30 21:01:16 UTC
Well, that's good news then! I'll have to ask if the function I used has any caveats (there is effectively 0 documentation about it) but hopefully we can get this in for the release of 5.21 then :)

I believe some of those problems may have been because of other problems in your installation / in the beta (as you stated you also had problems without any patches). Could you give me ~/.local/share/sddm/wayland-session.log again (after a reboot), so I can make sure?
Comment 13 Tito 2021-01-30 21:15:27 UTC
Created attachment 135313 [details]
Wayland session log file
Comment 14 Tito 2021-01-30 21:18:58 UTC
Attached the log file to the thread. 
This time the behavior war different, the two screens black from no signal, no deskop, but yukuake was working and applications opened from the console too (chromium).
i dont thin this matters at this point, tho it might be worth mentioning.
Comment 15 Tito 2021-01-30 21:24:37 UTC
I might add that i got the same behavior with the cpu usage, and the top cpu intensive programs are this.
as i never got anything like this, might this be another bug with the beta or the patch? 
https://imgur.com/R62OXCc
These are my top cpu intensive programs after logging out of plasma
Comment 16 Zamundaaa 2021-01-30 23:25:15 UTC
The CPU usage is definitely from the beta - I had such things happen with my git master installation a while ago. You just need to reboot and it will go away, at least until you log in and out again.

About the black screen: the log suggests that the driver doesn't accept the buffers for displaying. Are you sure that it worked correctly on the first try? Then I probably just have a bug in the patch somewhere.
Comment 17 Zamundaaa 2021-01-31 00:39:55 UTC
Hmm so I did find some more information on the function I was using and one's not supposed to use it directly, it'll only cause problems.

I'm rather confident to have found the actual source of the problem with the original code now though!
A fix in the same branch, so just re-download possible-mgpu-fix-2.
Comment 18 Bug Janitor Service 2021-01-31 14:13:42 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/649
Comment 19 Tito 2021-01-31 14:34:15 UTC
Great progress!
Now it kinda works, i still have problems with plasma, as i cant really get to the desktop, but thanks to the drop-down terminal i can run something like chromium and move it in to every monitor to see if it works or not:
https://imgur.com/a/kpFr1uU
link shows the glitches on the screens connected to the Igpu, also the logout plasma crash is back.
Comment 20 Zamundaaa 2021-01-31 15:10:05 UTC
I believe those glitches are caused by missing VSync, which should be fixed by https://invent.kde.org/plasma/kwin/-/merge_requests/642. If you could test that as well that would be very nice.

I put both of these patches together in the branch possible-mgpu-fix-3
Comment 21 Tito 2021-01-31 15:33:56 UTC
it gives me some compilation errors and it stops. i did the same thing for the previous patches, might it be a but in the code?

kwin/build/plugins/platforms/drm/KWinWaylandDrmBackend_autogen/EWIEGA46WW/../../../../../../plugins/platforms/drm/egl_gbm_backend.h:49:10: error: ‘void KWin::EglGbmBackend::cleanupDmabufForSecondaryGpuOutput(KWin::AbstractOutput*)’ marked ‘override’, but does not override
   49 |     void cleanupDmabufForSecondaryGpuOutput(AbstractOutput *output) override;

this seems to be present a few times while compiling, might it be the couse?
Comment 22 Zamundaaa 2021-01-31 15:47:15 UTC
Sorry about that, I forgot to remove that line. Instead of downloading it again you can just remove it yourself.
Comment 23 Tito 2021-01-31 16:11:54 UTC
Now it works! as far as i can test tho, as i still cat get to the desktop.
but on the igpu side everything is fine, rendering correctly, no tearing, no glitches!
Comment 24 Zamundaaa 2021-01-31 16:29:08 UTC
Thank you so much for your patience and testing! The patches are up and should get merged soon.

For the problem with the desktop not starting (or crashing) you should make a bug report for plasmashell, although it's probably been fixed already and just not in the beta yet.

If you're too impatient to wait for the release of 5.21 and the beta doesn't get updated with fixes then I would recommend you to compile a complete session with kdesrc-build. While it can take quite a while for the first run, everything currently works fine on master.
Comment 25 Tito 2021-02-01 00:23:58 UTC
Thanks so mutch for the help!
I've been trying to install and compile everything from source with kdesrc-build, but i ran in a lot of dependencies even after following this guide https://community.kde.org/Guidelines_and_HOWTOs/Build_from_source/Install_the_dependencies and installing the suggested packages.
I ran in this package kross that wouldnt install, and now im stuck on this step. am i doing something wrong? seems that its not a problem of dependency...
Comment 26 Zamundaaa 2021-02-01 01:07:30 UTC
I honestly skipped installation of dependencies and just built things with kdesrc-build and installed non-KDE dependencies as needed. No idea if that could lead to problems but worked fine for the last year or so.

If you have some sort of beta repository installed then I guess that could make problems with installing kross. I don't think it should matter though, you can just build it as well with kdesrc-build ¯\_(ツ)_/¯
Comment 27 Zamundaaa 2021-02-01 11:34:57 UTC
If you have more questions not directly related to this bug you can use the direct message function on Reddit. Thanks again for testing :)
Comment 28 Zamundaaa 2021-02-01 11:35:05 UTC
Git commit f8d9b3bc6cc8ee5ee57ce78d2d1368b77ce90f5c by Xaver Hugl.
Committed on 01/02/2021 at 11:28.
Pushed by zamundaaa into branch 'master'.

Actually use a linear buffer format for multi-GPU

M  +12   -20   plugins/platforms/drm/egl_gbm_backend.cpp
M  +0    -2    plugins/platforms/drm/egl_gbm_backend.h

https://invent.kde.org/plasma/kwin/commit/f8d9b3bc6cc8ee5ee57ce78d2d1368b77ce90f5c
Comment 29 Zamundaaa 2021-02-01 11:35:31 UTC
Git commit 9679beace6dd44c2910988f2139f357eb657d84e by Xaver Hugl.
Committed on 01/02/2021 at 11:35.
Pushed by zamundaaa into branch 'Plasma/5.21'.

Actually use a linear buffer format for multi-GPU


(cherry picked from commit f8d9b3bc6cc8ee5ee57ce78d2d1368b77ce90f5c)

M  +12   -20   plugins/platforms/drm/egl_gbm_backend.cpp
M  +0    -2    plugins/platforms/drm/egl_gbm_backend.h

https://invent.kde.org/plasma/kwin/commit/9679beace6dd44c2910988f2139f357eb657d84e