Bug 428361 - kwin sometimes freezes for a brief moment while closing windows
Summary: kwin sometimes freezes for a brief moment while closing windows
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-27 20:44 UTC by Vlad Zahorodnii
Modified: 2022-01-19 15:41 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vlad Zahorodnii 2020-10-27 20:44:12 UTC
SUMMARY
This bug has been annoying me for quite a while. Sometimes, if you close an application, kwin will freeze and then unfreeze itself shortly after.

I have not found a reliable way to reproduce this freeze.

STEPS TO REPRODUCE
1. Close Firefox

OBSERVED RESULT
There's a 50/50 chance that kwin will freeze for some amount of time.

* thread #1, name = 'kwin_wayland', stop reason = signal SIGSTOP
  * frame #0: 0x00007f9fddf18644 libQt5Core.so.5`std::atomic<QObjectPrivate::Connection*>::load(this=0x0000560d8c692770, __m=memory_order_relaxed) const at atomic:523:32
    frame #1: 0x00007f9fddf16329 libQt5Core.so.5`QObjectPrivate::Connection* QAtomicOps<QObjectPrivate::Connection*>::loadRelaxed<QObjectPrivate::Connection*>(_q_value=0x0000560d8c692770) at qatomic_cxx11.h:239:29
    frame #2: 0x00007f9fddf12efc libQt5Core.so.5`QBasicAtomicPointer<QObjectPrivate::Connection>::loadRelaxed(this=0x0000560d8c692770) const at qbasicatomic.h:248:64
    frame #3: 0x00007f9fddf063cd libQt5Core.so.5`QObjectPrivate::ConnectionData::removeConnection(this=0x0000560d8bcf1010, c=0x0000560d8d241320) at qobject.cpp:398:103
    frame #4: 0x00007f9fddf0774d libQt5Core.so.5`QObject::~QObject(this=0x0000560d8c1dbeb0) at qobject.cpp:1062:41
    frame #5: 0x00007f9fdfa71630 libKWaylandServer.so.5`KWaylandServer::SurfaceInterface::~SurfaceInterface(this=0x0000560d8c1dbeb0) at surface_interface.cpp:400:37
    frame #6: 0x00007f9fdfa7164c libKWaylandServer.so.5`KWaylandServer::SurfaceInterface::~SurfaceInterface(this=0x0000560d8c1dbeb0) at surface_interface.cpp:402:1
    frame #7: 0x00007f9fdfa70eea libKWaylandServer.so.5`KWaylandServer::SurfaceInterfacePrivate::surface_destroy_resource(this=0x0000560d8c04e910, (null)=0x0000560d8c1fb490) at surface_interface.cpp:295:12
    frame #8: 0x00007f9fdfaa2602 libKWaylandServer.so.5`QtWaylandServer::wl_surface::destroy_func(client_resource=0x0000560d8bd7c5e0) at qwayland-server-wayland.cpp:2899:43
    frame #9: 0x00007f9fdf92ee90 libwayland-server.so.0`___lldb_unnamed_symbol21$$libwayland-server.so.0 + 96
    frame #10: 0x00007f9fdf933851 libwayland-server.so.0`___lldb_unnamed_symbol91$$libwayland-server.so.0 + 65
    frame #11: 0x00007f9fdf933d50 libwayland-server.so.0`___lldb_unnamed_symbol101$$libwayland-server.so.0 + 32
    frame #12: 0x00007f9fdf92f020 libwayland-server.so.0`wl_client_destroy + 80
    frame #13: 0x00007f9fdf92f109 libwayland-server.so.0`___lldb_unnamed_symbol23$$libwayland-server.so.0 + 121
    frame #14: 0x00007f9fdf930faa libwayland-server.so.0`wl_event_loop_dispatch + 202
    frame #15: 0x00007f9fdf9f1a51 libKWaylandServer.so.5`KWaylandServer::Display::Private::dispatch(this=0x0000560d8ad102d0) at display.cpp:136:31
    frame #16: 0x00007f9fdf9f1685 libKWaylandServer.so.5`operator(__closure=0x0000560d8b7704a0) at display.cpp:105:83
    frame #17: 0x00007f9fdf9faef0 libKWaylandServer.so.5`QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, KWaylandServer::Display::Private::installSocketNotifier()::<lambda()> >::call(f=0x0000560d8b7704a0, arg=0x00007fffb748d9f0) &, void **) at qobjectdefs_impl.h:146:14
    frame #18: 0x00007f9fdf9fa6d7 libKWaylandServer.so.5`QtPrivate::Functor<KWaylandServer::Display::Private::installSocketNotifier()::<lambda()>, 0>::call<QtPrivate::List<>, void>(f=0x0000560d8b7704a0, (null)=0x0000560d8ad100a0, arg=0x00007fffb748d9f0) &, void *, void **) at qobjectdefs_impl.h:256:83
    frame #19: 0x00007f9fdf9f8a22 libKWaylandServer.so.5`QtPrivate::QFunctorSlotObject<KWaylandServer::Display::Private::installSocketNotifier()::<lambda()>, 0, QtPrivate::List<>, void>::impl(which=1, this_=0x0000560d8b770490, r=0x0000560d8ad100a0, a=0x00007fffb748d9f0, ret=0x0000000000000000) at qobjectdefs_impl.h:443:49
    frame #20: 0x00007f9fdded252f libQt5Core.so.5`QtPrivate::QSlotObjectBase::call(this=0x0000560d8b770490, r=0x0000560d8ad100a0, a=0x00007fffb748d9f0) at qobjectdefs_impl.h:398:57
    frame #21: 0x00007f9fddf15778 libQt5Core.so.5`void doActivate<false>(sender=0x0000560d8b6ba760, signal_index=3, argv=0x00007fffb748d9f0) at qobject.cpp:3886:30
    frame #22: 0x00007f9fddf0ecd9 libQt5Core.so.5`QMetaObject::activate(sender=0x0000560d8b6ba760, m=0x00007f9fde2b2380, local_signal_index=0, argv=0x00007fffb748d9f0) at qobject.cpp:3946:26
    frame #23: 0x00007f9fddf1f530 libQt5Core.so.5`QSocketNotifier::activated(this=0x0000560d8b6ba760, _t1=(sockfd = 7), _t2=Read, _t3=QPrivateSignal @ 0x00007fffb748d9df) at moc_qsocketnotifier.cpp:178:26
    frame #24: 0x00007f9fddf1f077 libQt5Core.so.5`QSocketNotifier::event(this=0x0000560d8b6ba760, e=0x00007fffb748df40) at qsocketnotifier.cpp:302:23
    frame #25: 0x00007f9fded9fd2b libQt5Widgets.so.5`QApplicationPrivate::notify_helper(this=0x0000560d8acb7340, receiver=0x0000560d8b6ba760, e=0x00007fffb748df40) at qapplication.cpp:3632:31
    frame #26: 0x00007f9fded9d069 libQt5Widgets.so.5`QApplication::notify(this=0x00007fffb748e2d0, receiver=0x0000560d8b6ba760, e=0x00007fffb748df40) at qapplication.cpp:2972:31
    frame #27: 0x00007f9fddec0255 libQt5Core.so.5`QCoreApplication::notifyInternal2(receiver=0x0000560d8b6ba760, event=0x00007fffb748df40) at qcoreapplication.cpp:1063:24
    frame #28: 0x00007f9fddec0cac libQt5Core.so.5`QCoreApplication::sendEvent(receiver=0x0000560d8b6ba760, event=0x00007fffb748df40) at qcoreapplication.cpp:1458:27
    frame #29: 0x00007f9fddf520ed libQt5Core.so.5`QEventDispatcherUNIXPrivate::activateSocketNotifiers(this=0x0000560d8acc60d0) at qeventdispatcher_unix.cpp:304:36
    frame #30: 0x00007f9fddf52f15 libQt5Core.so.5`QEventDispatcherUNIX::processEvents(this=0x0000560d8accf610, flags=(i = 36)) at qeventdispatcher_unix.cpp:511:50
    frame #31: 0x00007f9fd8fb251c KWinQpaPlugin.so`QUnixEventDispatcherQPA::processEvents(this=0x0000560d8accf610, flags=(i = 36)) at qunixeventdispatcher.cpp:63:67
    frame #32: 0x00007f9fddebc917 libQt5Core.so.5`QEventLoop::processEvents(this=0x00007fffb748e100, flags=(i = 36)) at qeventloop.cpp:139:68
    frame #33: 0x00007f9fddebcc79 libQt5Core.so.5`QEventLoop::exec(this=0x00007fffb748e100, flags=(i = 0)) at qeventloop.cpp:232:22
    frame #34: 0x00007f9fddec0aee libQt5Core.so.5`QCoreApplication::exec() at qcoreapplication.cpp:1371:36
    frame #35: 0x00007f9fde405184 libQt5Gui.so.5`QGuiApplication::exec() at qguiapplication.cpp:1867:34
    frame #36: 0x00007f9fded9ca35 libQt5Widgets.so.5`QApplication::exec() at qapplication.cpp:2824:33
    frame #37: 0x0000560d89b5d417 kwin_wayland`main(argc=3, argv=0x00007fffb748e538) at main_wayland.cpp:702:18
    frame #38: 0x00007f9fdd542152 libc.so.6`__libc_start_main + 242
    frame #39: 0x0000560d89b53c9e kwin_wayland`_start + 46

EXPECTED RESULT
No freeze.

SOFTWARE/OS VERSIONS
KDE Plasma Version: git master
KDE Frameworks Version: git master
Qt Version: 5.15.2 (built from source code)

ADDITIONAL INFORMATION
This might be a Qt bug, not sure.
Comment 1 David Edmundson 2020-10-27 23:02:29 UTC
I also got a freeze with that exact trace quite recently!

But only once and I couldn't reproduce.

If you can reproduce can you print in frame 3:

    frame #3: 

print c->receiver

It should be the other object that's connected to SurfaceInterface that we're removing the connection for.

Given it's a freeze in QAtomicPointer it implies there's some other thread up to no good, but I have no idea what.
Comment 2 David Edmundson 2020-10-28 18:17:02 UTC
Git commit 18df2451de80c72b135b05198da27daa1491eb2c by David Edmundson.
Committed on 28/10/2020 at 18:16.
Pushed by davidedmundson into branch 'master'.

Only connect to BufferInterface::aboutToBeDestroyed once

It is allowed to call surface_attach multiple times with the same
buffer. We want to only connect once.

Found whilst debugging a freeze, going through the list of
BufferInterface connections I had multiple to the same SurfaceInterface.

M  +2    -2    src/server/surface_interface.cpp

https://invent.kde.org/plasma/kwayland-server/commit/18df2451de80c72b135b05198da27daa1491eb2c
Comment 3 David Edmundson 2020-10-28 18:17:50 UTC
Git commit 8ab52255442223c5ce43d60f99c8ce8787969120 by David Edmundson.
Committed on 28/10/2020 at 18:17.
Pushed by davidedmundson into branch 'Plasma/5.20'.

Only connect to BufferInterface::aboutToBeDestroyed once

It is allowed to call surface_attach multiple times with the same
buffer. We want to only connect once.

Found whilst debugging a freeze, going through the list of
BufferInterface connections I had multiple to the same SurfaceInterface.


(cherry picked from commit 18df2451de80c72b135b05198da27daa1491eb2c)

M  +2    -2    src/server/surface_interface.cpp

https://invent.kde.org/plasma/kwayland-server/commit/8ab52255442223c5ce43d60f99c8ce8787969120
Comment 4 David Redondo 2022-01-19 15:41:53 UTC
Seems like David fixed it