Bug 375539

Summary: [Qt 5.8] Plasmashell windows are not marked as Desktop
Product: [Plasma] plasmashell Reporter: Bhushan Shah <bhush94>
Component: generic-waylandAssignee: Plasma Bugs List <plasma-bugs>
Status: RESOLVED FIXED    
Severity: critical CC: bugseforuns, demm, kde, kdebugs.20.orzelf, kyle.devir, lbeltrame, mgraesslin, notmart, patrick.auernig, rdieter, simonandric5, tobi291019
Priority: VHI    
Version: master   
Target Milestone: 1.0   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: plasmashell log

Description Bhushan Shah 2017-01-25 12:17:40 UTC
With Qt5.8 plasmashell windows are not marked as Desktop windows which results in funny setups like this : http://imgur.com/a/VLzfI

From what I investigated Surface::fromWindow is not returning wl_surface and returns nullptr because that is what gets handed by Qt to it. I believe this might be Qt window, but then given kwin internal windows get proper type so I don't know if its Qt bug.
Comment 1 Bhushan Shah 2017-01-25 12:18:45 UTC
I also believe that this can be as well kwayland regression?
Comment 2 Martin Flöser 2017-01-25 15:09:51 UTC
As kwayland didn't change it is not a kwayland regression. The problem must be in the native interface of QtWayland.

KWin's internal windows don't use QtWayland which explains why they still work.

I don't have Qt 5.8 yet, so I cannot really investigate.
Comment 3 Martin Flöser 2017-01-25 15:18:27 UTC
I don't see any change in the native interface. Maybe the platform window is not yet created or or plugins might need to be recorded against 5.8?
Comment 4 Bhushan Shah 2017-01-25 15:23:08 UTC
What do you mean by plugins might need to recorded against 5.8?
Comment 5 Martin Flöser 2017-01-25 15:23:13 UTC
Found it: https://code.qt.io/cgit/qt/qtwayland.git/tree/src/client/qwaylandwindow.cpp#n126

No idea what we can do about this. This we need to create a critical bug to Qt.
Comment 6 Martin Flöser 2017-01-25 15:25:27 UTC
Am 25. Januar 2017 16:23:08 MEZ schrieb Bhushan Shah <bugzilla_noreply@kde.org>:
>https://bugs.kde.org/show_bug.cgi?id=375539
>
>--- Comment #4 from Bhushan Shah <bhush94@gmail.com> ---
>What do you mean by plugins might need to recorded against 5.8?
Stupid auto correction. That should have been recompiled.
Comment 8 Marco Martin 2017-01-25 15:33:26 UTC
(In reply to Martin Gräßlin from comment #5)
> Found it:
> https://code.qt.io/cgit/qt/qtwayland.git/tree/src/client/qwaylandwindow.
> cpp#n126
> 
> No idea what we can do about this. This we need to create a critical bug to
> Qt.

doesn't seem to be, that commit is much older and removing that line doesn't solve the issue
Comment 9 Martin Flöser 2017-01-25 15:34:40 UTC
Hmm, I think we have an auto test for the in kwayland. Does it still work? Let's figure out whether it is a general issue or an issue just with desktop windows.
Comment 10 Bhushan Shah 2017-01-25 15:37:06 UTC
All autotests in kwayland passes for me :-(
Comment 11 Bhushan Shah 2017-01-25 15:38:18 UTC
Also, problem is not only for desktop windows, as you see panel window is also not "tagged" correctly..
Comment 12 Marco Martin 2017-01-25 15:48:41 UTC
here desktopview seems to be hidden when setupwaylandintegration is called, which is a problem.
calling show just before getting the surface seems to solve that problem, but just uncovers other ones
Comment 13 Marco Martin 2017-01-25 15:55:01 UTC
all tests working here as well
Comment 14 Martin Flöser 2017-01-25 16:03:46 UTC
OK, so the fromWindow seems to work and the problem is somewhere else. That we get a null pointer must be a side effect of the root problem.
Comment 15 Marco Martin 2017-01-25 16:15:42 UTC
that's a crash it gets uncovered when i "fix" the desktop window, don't know if related:
#0  0x00007ffff0aaaa29 in wl_proxy_marshal () from /usr/lib/x86_64-linux-gnu/libwayland-client.so.0
#1  0x00007fffe4ee912f in wl_surface_destroy (wl_surface=0x0)
    at ../../include/QtWaylandClient/5.8.1/QtWaylandClient/private/wayland-wayland-client-protocol.h:1416
#2  0x00007fffe4eebab2 in QtWayland::wl_surface::destroy (this=0x156dd88) at qwayland-wayland.cpp:1107
#3  0x00007fffe4ec6156 in QtWaylandClient::QWaylandWindow::reset (this=0x156dd60)
    at qwaylandwindow.cpp:228
#4  0x00007fffe4ec69b5 in QtWaylandClient::QWaylandWindow::setVisible (this=0x156dd60, visible=false)
    at qwaylandwindow.cpp:331
#5  0x00007fffe017571f in QtWaylandClient::QWaylandEglWindow::setVisible (this=0x156dd60, visible=false)
    at ../../../../hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp:160
#6  0x00007ffff2749135 in QWindow::setVisible (this=0x157b250, visible=false) at kernel/qwindow.cpp:552
#7  0x00007ffff7981a5b in PlasmaQuick::Dialog::componentComplete (this=0x157b250)
    at /home/diau/git/kf5/frameworks/plasma-framework/src/plasmaquick/dialog.cpp:1260
#8  0x00007ffff4e226fe in QQmlObjectCreator::finalize (this=0x15643f0, interrupt=...)
    at qml/qqmlobjectcreator.cpp:1234
#9  0x00007ffff4d82961 in QQmlIncubatorPrivate::incubate (this=0x155b080, i=...)
    at qml/qqmlincubator.cpp:347
#10 0x00007ffff4d8249a in QQmlIncubatorPrivate::forceCompletion (this=0x155b080, i=...)
    at qml/qqmlincubator.cpp:269
#11 0x00007ffff4d83206 in QQmlIncubator::forceCompletion (this=0x7fffffffcb00)
    at qml/qqmlincubator.cpp:598
#12 0x00007ffff5e75d79 in KDeclarative::QmlObject::createObjectFromComponent (this=0x9026f0,
Comment 16 Bhushan Shah 2017-01-25 16:39:51 UTC
One more datapoint, all other windows for example Konsole doesn't have titlebar at all..
Comment 17 Martin Flöser 2017-01-25 16:59:31 UTC
Am 25. Januar 2017 17:15:42 MEZ schrieb Marco Martin <bugzilla_noreply@kde.org>:
>https://bugs.kde.org/show_bug.cgi?id=375539
>
>--- Comment #15 from Marco Martin <notmart@gmail.com> ---
>that's a crash it gets uncovered when i "fix" the desktop window, don't
>know if
>related:
>#0  0x00007ffff0aaaa29 in wl_proxy_marshal () from
>/usr/lib/x86_64-linux-gnu/libwayland-client.so.0
>#1  0x00007fffe4ee912f in wl_surface_destroy (wl_surface=0x0)

Pretty sure it is related: the surface is null
Comment 18 Marco Martin 2017-01-25 17:07:13 UTC
i tried to bisect as back as qtwayland still builds on top of Qt 5.8, but didn't conclude much, as it stops compiling correctly pretty soon (and the 5.7 version doesn't build on 5.8 at all)
Comment 19 Bhushan Shah 2017-01-25 17:07:54 UTC
https://codereview.qt-project.org/#/c/181146/

That crash is fixed it seems upstream..
Comment 20 Bhushan Shah 2017-01-25 17:11:09 UTC
But still doesn't explain surface being null :S
Comment 21 Martin Flöser 2017-01-25 17:26:43 UTC
Could someone report a regression bug at Qt? I think it's pretty major if they break or Wayland desktop. Maybe they have ideas...
Comment 22 Bhushan Shah 2017-01-25 17:35:13 UTC
Created attachment 103639 [details]
plasmashell log

I am writing bug report, also attaching the plasmashell log with WAYLAND_DEBUG env var..

(Ignore the debugging lines with BSHAH though :p)
Comment 23 Marco Martin 2017-01-25 17:45:12 UTC
that qt code review seems to fix the crash for me, even tough the panel is still misplaced, the desktop still the wrong type, and terminating plasmashell kills kwin too
(ASSERT: "source" in file /home/diau/git/kf5/frameworks/kwayland/src/server/dataoffer_interface.cpp, line 96
(EE) )
so looks like they are two separate issues
Comment 24 Bhushan Shah 2017-01-25 17:47:37 UTC
Reported : https://bugreports.qt.io/browse/QTBUG-58423
Comment 25 Martin Flöser 2017-01-25 18:50:11 UTC
*** Bug 375559 has been marked as a duplicate of this bug. ***
Comment 26 Marco Martin 2017-01-26 12:38:55 UTC
test case:
http://notmart.org/misc/qwindow-wl-surface.tar.bz2

what happens: QPlatformSurfaceEvent(surfacecreated) arrives,
but trying to get the surface, it's a nullptr, not created yet
Comment 27 Marco Martin 2017-01-26 13:24:16 UTC
to me, the problem is just that qwindow::create, always sends a surfacecreatedevent, *but* qwayland does not (anymore?) create the surface in qwaylandintegration::createplatformwindow
so in the end.. does that event is actually supposed to guarantee a wayland surface has been created, or were we doing it wrong all along?
Comment 28 Martin Flöser 2017-01-26 17:19:54 UTC
Am 26. Januar 2017 14:24:16 MEZ schrieb Marco Martin <bugzilla_noreply@kde.org>:
>https://bugs.kde.org/show_bug.cgi?id=375539
>
>--- Comment #27 from Marco Martin <notmart@gmail.com> ---
>to me, the problem is just that qwindow::create, always sends a
>surfacecreatedevent, *but* qwayland does not (anymore?) create the
>surface in
>qwaylandintegration::createplatformwindow
>so in the end.. does that event is actually supposed to guarantee a
>wayland
>surface has been created, or were we doing it wrong all along?

The event is called platform surface created. If our code was wrong that would be highly unexpected and a very misleading naming.
Comment 29 Marco Martin 2017-05-22 16:06:12 UTC
is the current state, "fixed" enough?