Bug 348753

Summary: more issues with nvidia legacy (304.xxx) blob and explicit syncing (here on login)
Product: [Plasma] kwin Reporter: Jordyn Carattini <jordyncarattini>
Component: scene-openglAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED WORKSFORME    
Severity: normal CC: jordyncarattini, sergio.callegari, summersons96-squareformat
Priority: NOR Flags: thomas.luebking: NVIDIA+
Version: 5.3.1   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=343551
https://bugs.kde.org/show_bug.cgi?id=349238
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Xorg Log
glxinfo output
KWin Problem's Fix Bash Script

Description Jordyn Carattini 2015-06-05 16:57:58 UTC
when i logon to plasma 5, the plasma shell freezes and then flickers
then i get a notification says kwin has been reset due to a graphical reset
i have to kill kwin via a tty and then use a diffrent window manager

Hardware And Software Detail's
Computer:Dell Latitude D820
Processer:32-bit
Distrobution: Arch Linux 32-Bit
Output Of uname -a: Linux Latitude-D820 4.0.4-2-ARCH #1 SMP PREEMPT Fri May 22 03:19:32 UTC 2015 i686 GNU/Linux


Reproducible: Always

Steps to Reproduce:
1.Logout
2.Enter Password
3.Log Back In

Actual Results:  
Kwin Crashed Again

Expected Results:  
Not Crash
Comment 1 Thomas Lübking 2015-06-05 17:33:19 UTC
if you have to kill kwin, it certainly didn't crash.

i assume suspending the compositor (SHIFT+alt+F12) is sufficient?

please attach the output of "glxinfo" and /var/log/Xorg.0.log
Comment 2 Jordyn Carattini 2015-06-05 17:49:37 UTC
Created attachment 93025 [details]
Xorg Log
Comment 3 Jordyn Carattini 2015-06-05 17:50:02 UTC
Created attachment 93026 [details]
glxinfo output
Comment 4 Jordyn Carattini 2015-06-05 17:50:33 UTC
now kwin is saying: kwin_x11: error while loading shared libraries: libkdecorations2.so.5: cannot open shared object file: No such file or directory
Comment 5 Jordyn Carattini 2015-06-05 18:11:22 UTC
nevermind on the missing .so file i just had to reinstall a package
but kwin is still messed up
Comment 6 Thomas Lübking 2015-06-05 18:33:11 UTC
Leaving aside that broken installations do not inspire much confidence ;-)

> OpenGL vendor string: NVIDIA Corporation
> OpenGL renderer string: GeForce Go 7400/PCIe/SSE2
> OpenGL version string: 2.1.2 NVIDIA 304.125
> OpenGL shading language version string: 1.20 NVIDIA via Cg compiler

Please try

export KWIN_EXPLICIT_SYNC=0
kwin_x11 --replace &
Comment 7 Jordyn Carattini 2015-06-05 18:40:33 UTC
One What Does This Mean: Leaving aside that broken installations do not inspire much confidence ;-)

And The
export KWIN_EXPLICIT_SYNC=0 
kwin_x11 --replace &
Commands

Worked!
Comment 8 Thomas Lübking 2015-06-05 18:50:01 UTC
System with broken package installation isn't exactly trustworthy regarding bugs ;-)

Can you gdb into the hanging KWin process and check where it's pondering?


@Martin, we might have to to default this off for the legacy driver?
Comment 9 Jordyn Carattini 2015-06-05 18:55:27 UTC
how do i gdb
the terminal says:
bash: gdb: command not found
Comment 10 Thomas Lübking 2015-06-05 19:16:14 UTC
(In reply to Jordyn Carattini from comment #9)
> how do i gdb

That means "rather not" :-(
gdb is a (commandline) debugger that will allow you to inspect the process stack, but debugging this case likely won't be trivial (you'll have to check threads, maybe forward a bit etc.), ie. you should ideally have basic experience with the tool. It's not exactly an enduser job.
Comment 11 Jordyn Carattini 2015-06-05 19:18:08 UTC
oh ok and sometimes when i try to unlock some of the font is missing and someimes when i start plasma
Comment 12 Jordyn Carattini 2015-06-05 19:49:10 UTC
so am i going to have to run those commands every time i logon
Comment 13 Thomas Lübking 2015-06-05 20:20:13 UTC
no

$ kwrite ~/.config/plasma-workspace/env/kwin_env.sh
--------
#!/bin/sh
export KWIN_EXPLICIT_SYNC=0 
--------
$ chmod +x ~/.config/plasma-workspace/env/kwin_env.sh

The variable will then be exported when the session starts (kwin will pick it up)
Comment 14 Jordyn Carattini 2015-06-05 20:28:26 UTC
Thanks That Worked And What Is That File, What Will Happend If A Add A Program Into That File?
Comment 15 Thomas Lübking 2015-06-05 20:53:41 UTC
If you don't fork and disown the process and it doesn't exit "fast" - bad things. (the session won't start or you won't be able to logout)
Comment 16 Jordyn Carattini 2015-06-05 21:02:12 UTC
Wow Well Thank You
Comment 17 Jordyn Carattini 2015-06-05 21:05:53 UTC
Oh That Flile Gets Added To Autostart
Comment 18 Jordyn Carattini 2015-06-06 16:14:27 UTC
Well, When I Start Kwin Under A Different Desktop Environment (Like XFCE4)
Kwin Still Resets And Freezes, And The Command export KWIN_EXPLICIT_SYNC=0 Doesn't Help
Comment 19 Thomas Lübking 2015-06-06 16:52:14 UTC
Sure it's set?

    tr '\0' '\n' < /proc/`pidof kwin_x11`/environ | grep KWIN_EXPLICIT_SYNC

Notice that setting it in some  ~/.config/plasma-workspace/env/* script has NO impace, xfce doesn't even remotely look at that directory.
Comment 20 Jordyn Carattini 2015-06-06 17:03:43 UTC
output of " tr '\0' '\n' < /proc/`pidof kwin_x11`/environ | grep KWIN_EXPLICIT_SYNC":
bash: /proc/`pidof kwin_x11`/environ: No such file or directory
Comment 21 Thomas Lübking 2015-06-06 17:05:16 UTC
This does of course only work if kwin is running.
Comment 22 Jordyn Carattini 2015-06-06 17:07:38 UTC
ohh ok
heres the output when kwin is running
KWIN_EXPLICIT_SYNC=0
Comment 23 Thomas Lübking 2015-06-06 17:25:11 UTC
While the results may be similar, it'll then be a different issue (and it's extremely odd that this should depend on the desktop environment)

a) does suspending the compositor still help?
b) please attach the output of "qdbus org.kde.KWin /KWin supportInformation" (from the xfce session)
Comment 24 Jordyn Carattini 2015-06-06 17:27:47 UTC
https://paste.kde.org/pqgo5ijzx
Comment 25 Thomas Lübking 2015-06-17 08:32:40 UTC
(In reply to Jordyn Carattini from comment #24)
> https://paste.kde.org/pqgo5ijzx

Sorry, I missed the post and now the file is gone.
Please attach the file (or a new dump) *here* - and please never use any (temporary!) pastebin for relevant bug informations.
Comment 26 Thomas Lübking 2015-06-17 08:38:07 UTC
bug #349238 blames the feature for crashes deep in the nvidia blob (from glxSwapBuffers)

=> we might have to default it off for the legacy blob :-\
Comment 27 Jordyn Carattini 2015-06-19 05:02:01 UTC
I Have Another Problem Related TO This One
I Have Installed Manjaro Linux
UNAME -A:Linux Latitude-D820-Manjaro 4.0.5-1-MANJARO #1 SMP PREEMPT Sat Jun 6 21:19:29 UTC 2015 i686 GNU/Linux
 Every Time I Run Kwin It Seg Fault's

With Error:

Constructing a KPluginInfo object from old style JSON. Please use kcoreaddons_desktop_to_json() for "/usr/lib/qt/plugins/org.kde.kdecoration2/kwin5_aurorae.so" instead of kservice_desktop_to_json() in your CMake code.
Trying to load decoration plugin:  "/usr/lib/qt/plugins/org.kde.kdecoration2/kwin5_aurorae.so"
Comment 28 Thomas Lübking 2015-06-19 06:52:13 UTC
That's not an error but a friendly notice to developers to adapt to new build system API - and certainly not the cause of a segfault.

Whether that segfault is related to this issue is related to this bug is questionable: you'll get a DrKonqui dialog; if the backtrace ("developer information") doesn't match bug #349238, please file a *new* bug with the backtrace and we'll then check whether or not it is related.
Comment 29 Jordyn Carattini 2015-06-19 14:49:02 UTC
how can i get the backtrace the dialog doesnt come up
i just have kwin installed not a full kde desktop
Comment 30 Thomas Lübking 2015-06-19 16:19:01 UTC
(In reply to Jordyn Carattini from comment #29)
> how can i get the backtrace the dialog doesnt come up
> i just have kwin installed not a full kde desktop

sudo pacman -Sy drkonqi

Should have littele dependency overhead and makes things much simpler.
Otherwise see https://community.kde.org/KWin/Debugging
Comment 31 Jordyn Carattini 2015-06-19 16:24:43 UTC
got it
Comment 32 Jordyn Carattini 2015-06-19 17:17:22 UTC
With All The Problem's I Have Been Having With KWin 
Tearing Prevension Not Working
Freezing, etc, etc
I Decided To Do More Googleing
And I Found This https://bugs.kde.org/show_bug.cgi?id=322060
And I Edited The Bash Script You Made For KWin
And It Fixed All The Problem's I Have Been Having
Comment 33 Jordyn Carattini 2015-06-19 17:18:45 UTC
Created attachment 93237 [details]
KWin Problem's Fix Bash Script
Comment 34 Sergio 2015-08-12 07:51:48 UTC
On a geoforce 7025 (integrated on an ASRock mainboard with AMD Phenom II processor), Kubuntu vivid, the situation is substantially worsened recently (I guess after the latest set of upgraded packages with framework 5.12 and plasma 5.3.2).

Until now, I was able to work with  the KWIN_EXPLICIT_SYNC=0 trick either with or without compositing.

Now with compositing kwin_x11 goes to 100% cpu use, and without it plasma every now and then freezes.

Same setup seems to work fine on an Intel haswell laptop, though.
Comment 35 Sergio 2015-08-12 16:37:59 UTC
Things appeared to have improved after I erased all the plasma related stuff in .cache...
Got hint to do this googling. Let's see for how long it can last.
Comment 36 Thomas Lübking 2015-08-12 16:51:32 UTC
please check
tr '\0' '\n' < /proc/`pidof kwin_x11`/environ | grep -E '(KWIN_EXPLICIT_SYNC|__GL_YIELD)'
and
grep -i triple /var/log/Xorg.0.log

High CPU load can be caused by synced swapping on double buffer setups.

Also there's quite a bug in QML which makes (some) animations in plasmashell repaint like hell, spiking the CPU of that process (and KWin in the composited case)
Also run kwin_x11 from konsole and check whether it says something about graphic card resets.
Comment 37 Sergio 2015-08-13 13:34:13 UTC
Thanks Thomas for the advice.

I knew about the KWIN_EXPLICIT_SYNC=0 (in fact, I've been running with it until I first received plasma 5 with Kubuntu 15.04).  Didn't know what __GL_YIELD was until a minute ago, and I'm running with the default.

I think that the issue with my system was that after the update to the new plasma 5.3.2 or framework 5.12 (and possibly in a way totally unrelated with this upgrade), something weird got written into plasma files in .cache.

After I removed all the plasma related stuff from .cache, the machine stopped having erratic plasmashell freezes.  It is now two days it is working fine (apart from some occasional segfaults and glitches I was already used to).

Wonder if some cleaning of the plasma .cache stuff can be performed automatically after bad crashes or freezes are seen.
Comment 38 Thomas Lübking 2015-08-13 17:21:17 UTC
the ~/.cache issue is indeed reported *very* often - it would affect (likely) libplasma, maybe is ksharedmemory. I've however not seen it yet.

This could be done by some kconfi_update script, but of course preferable there should be no freezes on "cache corruption" (where I wonder whether it actually is or libplasma just happily alters the cache binary structure with ever minor update ...)
Comment 39 Jordyn Carattini 2015-09-09 03:40:18 UTC
try my script
Comment 40 Sergio 2015-11-29 12:07:45 UTC
Just upgraded my machine (AsRock board with NVIDIA 7025 on it) from Kubuntu 15.04 to 15.10, with the side effect of moving from plasma 5.3 to 5.4.  Unfortunately, this broke kwin again on my hardware.

I had just succeeded in finding a configuration with the KWIN_EXPLICIT_SYNC for plasma 5.3 (in 15.04) and now, with plasma 5.4.2 kwin compositing causes everything to freeze again, no matter the EXPLICIT_SYNC script. Is some more hack needed now?

Is there anyone who has success with 5.4.2 and kwin compositing on a similar hardware or nvidia 304.131?
Comment 41 Thomas Lübking 2015-11-29 12:39:52 UTC
What's the xorg server version (for if it's already 1.18, the nvidia drivers need to updated to ABI v20 for compatibility)
Comment 42 Sergio 2015-11-29 14:19:12 UTC
Should be 1.17.2 in (k)ubuntu 15.10.  I'm sticking to the distro version.
Comment 43 Sergio 2015-12-08 15:57:20 UTC
Hi, I have just noticed that the version of kwin in 5.4.3 (that I got from the kubuntu ppa) works again with the KWIN_EXPLICIT_SYNC=0 trick.  It was only 5.4.2 failing. Good news on this front.
Comment 44 Thomas Lübking 2015-12-08 15:59:24 UTC
Did you *only* update KWin? (I don't recall we touched anything in that area at all)
Comment 45 Sergio 2015-12-08 16:09:12 UTC
I got the whole of the array of updates that arrived via the Kubuntu ppa and that included 5.4.3.

It may have not been kwin in the end, but maybe some animation effect or something in the theme. I must admit that I have not been diligent enough to try disabling the effects one by one or try changing the theme.

The issue was as follow:

- Plasma started providing a screen that was looking OK
- Immediately after that the bottom panel got distorted and everything hung
- Using Ctrl-Alt-F1 and Ctrl-Alt+F7 I could go back and forth between the text console and X and in this way plasma seemed to be able to perform operations one step "per switch".

In any case, the system with 7025 and nvidia 304 is usable again.
Comment 46 Thomas Lübking 2015-12-08 19:55:38 UTC
ftr, after the last nvidia update to 358.x (meeting X API v20) I got quite some trouble on randr event (adding/removing screen) and by that I mean the kernel stalls (and that's not related to compositing), so there're simply monsters in this area atm ;-)

Good to hear however, that things work for you again.
The description of the issue and the behavior sounds as if the scanout buffer was only updated on VT changes...
Comment 47 summersons96-squareformat 2015-12-18 01:12:13 UTC
(In reply to Jordyn Carattini from comment #33)
> Created attachment 93237 [details]
> KWin Problem's Fix Bash Script

Where can this file be placed?

Previously I used /etc/profile.d to place a simple kwin.sh script.

Is there a preferred path for this file of yours?

Thanking for your efforts
Comment 48 Thomas Lübking 2015-12-18 09:51:19 UTC
You can add random environments to /etc/profile - do NOT source that script there!
It's a script to shadow the actual kwin binary, but I wrote it for KDE SC4 (to control some GL variables for kwin only), so don't try it on KF5 either.

Putting "export KWIN_EXPLICIT_SYNC=0" into /etc/profile or some /etc/profile.* source will do fine itr.
Comment 49 summersons96-squareformat 2015-12-18 23:28:20 UTC
(In reply to Thomas Lübking from comment #48)
> You can add random environments to /etc/profile - do NOT source that script
> there!
> It's a script to shadow the actual kwin binary, but I wrote it for KDE SC4
> (to control some GL variables for kwin only), so don't try it on KF5 either.
> 
> Putting "export KWIN_EXPLICIT_SYNC=0" into /etc/profile or some
> /etc/profile.* source will do fine itr.

Oh thanks for advice - it was K5 I was going to try it on! Thank goodness I didn't try it.

As for /etc/profile.d in that folder is an executable kwin.sh containing my nvidia tearing fix/workaround:
"export __GL_YIELD="USLEEP"
If I add:
"export KWIN_EXPLICIT_SYNC=0"

That will be OK, yes? And it is Plasma, KDE, and Frameworks 5, I am speaking of here.

Incidentally the freezing and "desktop effects were restarted due to graphics reset" is not confined to the nvidia 304 driver it is also present on the nvidia 340.xx legacy driver. I have never experienced freezing on KDE4, I only began seeing it when I began testing Plasma 5 etc. since last year. It is present on arch; tumbleweed; leap 42.1; Kaos; netrunner - all freeze and offer the error message.

Thanks again