Bug 397767 - Selecting Desktop On-Screen Display Crashes Kwin on Virtual Desktop Change
Summary: Selecting Desktop On-Screen Display Crashes Kwin on Virtual Desktop Change
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: 5.13.4
Platform: Other Linux
: NOR crash
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-23 02:13 UTC by dD_
Modified: 2018-09-13 09:19 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Kwin Crash file (5.93 KB, text/plain)
2018-08-23 02:13 UTC, dD_
Details
output of qdbus org.kde.KWin /KWin supportInformation (6.74 KB, text/plain)
2018-08-23 12:39 UTC, dD_
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dD_ 2018-08-23 02:13:15 UTC
Created attachment 114555 [details]
Kwin Crash file

I turned on Desktop Switch On-Screen Display, and everytime I change desktop kwin crashes.  I stop getting a title bar, can't switch desktops anymore, and my keyboard shortcuts stop working.  I'm using a dell Precision 5530 with an NVIDIA GP107GLM [Quadro P2000 Mobile] card on arch linux. 

This is a pastebin of my command line showing how kwin crashed:

https://pastebin.com/hhg2tZQb

The problem persists with XRender and OpenGL 2.0.  The moment I disable the Desktop Switch On-Screen Display, Kwin stops crashing. 

Not sure what the component would be so I chose general.
Comment 1 Martin Flöser 2018-08-23 04:23:48 UTC
Crash happens in the proprietary Nvidia driver. Nothing we can do.
Comment 2 David Edmundson 2018-08-23 10:08:29 UTC
This is relevant in the stderr:

QOpenGLContext::swapBuffers() called with non-exposed window, behavior is undefined

if it is undefined, we can't necessarily blame nvidia just yet.

dD can you post output of

 qdbus org.kde.kwin /KWin supportInformation

and clarify which  Desktop Switch On-Screen Display you're referring to
Comment 3 dD_ 2018-08-23 12:39:37 UTC
Created attachment 114559 [details]
output of qdbus org.kde.KWin /KWin supportInformation

This is the output of org.kde.KWin /KWin support information. 

The output does not change if I select or remove the desktop on-screen display.
Comment 4 dD_ 2018-08-23 12:44:06 UTC
> qdbus org.kde.kwin /KWin supportInformation

Attached the output for qdbus org.kde.KWin /KWin supportInformation above.  Output does not change with Desktop Switch On-Screen Display.

> and clarify which Desktop Switch On-Screen Display you're referring to

I'm not sure what this means, but I selected the Desktop Switch On-Screen Display, with 500 msec and show desktop indicators selected.  I tried with and without the desktop cube animation, and it crashes no matter which desktop I'm changing from.  


About the crash happening in the nvidia driver (if it does).  It  happens only when a particular trivial setting is on (that does not require additional animation), even if it is an issue with nvidia drivers, wouldn't that make it is fixable? 

Let me know if you need anything else.
Comment 5 David Edmundson 2018-08-23 14:54:22 UTC
Please can you run with

QSG_RENDER_LOOP=basic kwin_x11 --replace

and report back
Comment 6 dD_ 2018-08-23 15:02:53 UTC
Sure, just so I understand, you want me to reenable the desktop switch on-screen display with kwin as: QSG_RENDER_LOOP=basic kwin_x11 --replace and then try to crash it, correct?
Comment 7 dD_ 2018-08-23 15:22:03 UTC
I tried it as you said and I cannot make it crash.  Just to be sure I returned to my previous settings, and it wouldn't crash either.  

So I opened chromium on both screens (which is what I had done yesterday) and it crashes again on my previous settings, but not with OSG_RENDER_LOOP=basic.  I've been trying it for several minutes with all rendering backends (open gl 3.1, xrender, and opengl 2.0) and cannot make it crash at all. 

So it seems that was the problem, thank you!  Would you mind explaining to me what is happening? And how can I make the changes permanent?
Comment 8 David Edmundson 2018-08-23 16:17:26 UTC
>Would you mind explaining to me what is happening?

We have a bug.

I don't get a crash if I force my system to be threaded, but I do see in the logs it doing something stupid and the wrong way round.

We have destruction and cleanup in a separate thread in QtQuick, and we're pulling out the surface and context at a weird point.

scripting.cpp
    connect(window, &QWindow::visibilityChanged, [window](QWindow::Visibility visibility) {

         if (visibility == QWindow::Hidden) {
             window->destroy();
         }

fine if you're synced. Qt has special code if you're in the window destructor, but not for calling destroy on the platform window explicitly.
Comment 9 David Edmundson 2018-09-13 09:19:27 UTC
Git commit d485dfe7ef1910a7f6652610388ae2d93cdec29f by David Edmundson.
Committed on 13/09/2018 at 09:19.
Pushed by davidedmundson into branch 'master'.

Avoid crash with on scripted window teardown with threaded quick render loop

Summary:
Qt render loops behave quite differently to each other.

KWin scripting as a workaround for another situation cleans
(17553e5a1fb72a92dbbff3fa6bc7d55b8f1a0123) handles tracking of script
windows by deleting the underlying window handle on hide.

This currently happens before the window gets the hideEvent.

Arguably this is a quirk with Qt, but in the current state:

- QSGThreadedRenderLoop deletes the platform window and cleans up
- We then get the hide() event. This no-ops because there's no window.
   (else branch of     case WM_TryRelease in qsgthreadedrenderloop.cpp)
- We carry on rendering animations despite having no platform
- undefined behaviour

Normally this isn't a problem as typically destruction of the platform window
happens only when a window is being deleted, we're messing with Qt
internals here.

If we make sure the QHideEvent is processed by the render loop first,
things seem fine.

Test Plan:
Ran QSG_RENDER_LOOP=threaded
Read output with scenegraph logging rules on

Reviewers: #kwin, broulik

Reviewed By: broulik

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15025

M  +2    -2    scripting/scripting.cpp

https://commits.kde.org/kwin/d485dfe7ef1910a7f6652610388ae2d93cdec29f