[effects] Delay creation of EffectFrames in WindowGeometryEffect
ClosedPublic

Authored by graesslin on Nov 14 2017, 7:18 PM.

Details

Summary

Without Xwayland KWin starts so fast that the creation of the EffectFrame
triggers a crash in the Wayland integration as the KWin internal
connection isn't fully setup.

To workaround this crash the creation of the EffectFrame is delayed till
the first usage. It doesn't make sense to try to fix the actual crash as
it would require to defer the creation of all Effects.

Test Plan

New test case added which crashes without this fix.

Diff Detail

Repository
R108 KWin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
graesslin created this revision.Nov 14 2017, 7:18 PM
Restricted Application added a project: KWin. · View Herald TranscriptNov 14 2017, 7:18 PM
Restricted Application added subscribers: kwin, plasma-devel. · View Herald Transcript
broulik accepted this revision.Nov 14 2017, 7:44 PM
This revision is now accepted and ready to land.Nov 14 2017, 7:44 PM

New test case added which crashes without this fix.

I wanted to see the backtrace of what we're working round, so applied just the test and not the changes to the effect.
It didn't crash. Any ideas?

New test case added which crashes without this fix.

I wanted to see the backtrace of what we're working round, so applied just the test and not the changes to the effect.
It didn't crash. Any ideas?

Two ideas: did you run the waylandonly variant or the "normal" variant? Only the waylandonly variant crashes and that one is timing dependent so it might be that you will never see it on your system. I also only got it on my notebook but never on my desktop. I'll add the backtrace.

As I just made my kwin crash just to get the backtrace I'm adding nevertheless:

(gdb) bt
#0  0x00007f8d550626b0 in KWayland::Client::Compositor::operator wl_compositor*() () at /workspace/build/src/client/compositor.cpp:131
#1  0x00007f8d428b377d in KWin::QPA::NativeInterface::nativeResourceForIntegration (this=0x1e00120, resource=...) at /home/martin/src/kde/workspace/kwin/plugins/qpa/nativeinterface.cpp:57
#2  0x00007f8d550623a3 in KWayland::Client::Compositor::fromApplication (parent=0x7f8c90f5e3a0) at /workspace/build/src/client/compositor.cpp:63
#3  0x00007f8c90d55ab2 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/org.kde.kwindowsystem.platforms/KF5WindowSystemKWaylandPlugin.so
#4  0x00007f8c90d55ce1 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/org.kde.kwindowsystem.platforms/KF5WindowSystemKWaylandPlugin.so
#5  0x00007f8c90d569c5 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/kf5/org.kde.kwindowsystem.platforms/KF5WindowSystemKWaylandPlugin.so
#6  0x00007f8d578ad40c in ?? () from /usr/lib/x86_64-linux-gnu/libKF5Plasma.so.5
#7  0x00007f8d578a3347 in Plasma::Theme::Theme(QObject*) () from /usr/lib/x86_64-linux-gnu/libKF5Plasma.so.5
#8  0x00007f8d5ab92936 in KWin::EffectFrameImpl::EffectFrameImpl (this=0x2db1320, style=<optimized out>, staticSize=<optimized out>, position=..., alignment=...)
    at /home/martin/src/kde/workspace/kwin/effects.cpp:1835
#9  0x00007f8d5ab92a8b in KWin::EffectsHandlerImpl::effectFrame (this=<optimized out>, style=KWin::EffectFrameUnstyled, staticSize=<optimized out>, position=..., alignment=...)
    at /home/martin/src/kde/workspace/kwin/effects.cpp:1449
#10 0x00007f8d58007652 in KWin::WindowGeometry::WindowGeometry (this=0x2dafcb0) at /home/martin/src/kde/workspace/kwin/effects/windowgeometry/windowgeometry.cpp:53
#11 0x00007f8d57fadcb6 in KWin::BuiltInEffects::createHelper<KWin::WindowGeometry> () at /home/martin/src/kde/workspace/kwin/effects/effect_builtins.cpp:84
#12 0x00007f8d5ab9ac80 in KWin::BuiltInEffectLoader::loadEffect (this=this@entry=0x2b07a10, name=..., effect=effect@entry=<incomplete type>, flags=..., flags@entry=...)
    at /home/martin/src/kde/workspace/kwin/effectloader.cpp:159
#13 0x00007f8d5ab9b1bf in KWin::BuiltInEffectLoader::loadEffect (this=0x2b07a10, effect=effect@entry=<incomplete type>, flags=flags@entry=...)
    at /home/martin/src/kde/workspace/kwin/effectloader.cpp:125
#14 0x00007f8d5aba0884 in KWin::EffectLoadQueue<KWin::BuiltInEffectLoader, KWin::BuiltInEffect>::dequeue (this=0x2b07740) at /home/martin/src/kde/workspace/kwin/effectloader.h:258
#15 0x00007f8d58eabc59 in QObject::event (this=0x2b07740, e=<optimized out>) at kernel/qobject.cpp:1246
#16 0x00007f8d592973fc in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x2b07740, e=0x2daa860) at kernel/qapplication.cpp:3717
#17 0x00007f8d5929ee07 in QApplication::notify (this=0x7ffd08fa6ae0, receiver=0x2b07740, e=0x2daa860) at kernel/qapplication.cpp:3476
#18 0x00007f8d58e7e798 in QCoreApplication::notifyInternal2 (receiver=0x2b07740, event=event@entry=0x2daa860) at kernel/qcoreapplication.cpp:1018
#19 0x00007f8d58e80f7b in QCoreApplication::sendEvent (event=0x2daa860, receiver=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:233
#20 QCoreApplicationPrivate::sendPostedEvents (receiver=receiver@entry=0x0, event_type=event_type@entry=0, data=0x1dcc710) at kernel/qcoreapplication.cpp:1678
#21 0x00007f8d58ed07e7 in QEventDispatcherUNIX::processEvents (this=0x1dff980, flags=...) at kernel/qeventdispatcher_unix.cpp:466
---Type <return> to continue, or q <return> to quit---
#22 0x00007f8d428ec6fd in QUnixEventDispatcherQPA::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/KWinQpaPlugin.so
#23 0x00007f8d58e7c7ca in QEventLoop::exec (this=this@entry=0x7ffd08fa67b0, flags=..., flags@entry=...) at kernel/qeventloop.cpp:212
#24 0x00007f8d58e85704 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1291
#25 0x00007f8d52ce32ec in QGuiApplication::exec () at kernel/qguiapplication.cpp:1679
#26 0x00007f8d59297355 in QApplication::exec () at kernel/qapplication.cpp:2905
#27 0x0000000000408c28 in main (argc=2, argv=<optimized out>) at /home/martin/src/kde/workspace/kwin/main_wayland.cpp:836

As we can see it crashes because PlasmaFrame accesses the internal connection before it's fully setup.

This revision was automatically updated to reflect the committed changes.