Bug 461338 - Kwin hangs when pressing Alt+Tab
Summary: Kwin hangs when pressing Alt+Tab
Status: REPORTED
Alias: None
Product: kwin
Classification: Plasma
Component: tabbox (other bugs)
Version First Reported In: 5.26.2
Platform: Arch Linux Linux
: NOR major
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-02 23:30 UTC by Puspam Adak
Modified: 2023-02-06 16:51 UTC (History)
4 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 Puspam Adak 2022-11-02 23:30:01 UTC
Kwin hangs when pressing Alt+Tab for the 1st time. In the subsequent times also, kwin hangs if there are a lot of windows open and the Alt+Tab module is taking time to render.

STEPS TO REPRODUCE
1. Restart your computer or drop caches in Linux.
2. Start an application such as Chrome, which does a lot of disk I/O.
3. Press Alt+Tab and see the whole screen just hangs. You will be unable to click on any other application or any panel item.

OBSERVED RESULT
Kwin hangs for some time after pressing Alt+Tab, maybe because it takes some time to load the Alt+Tab module. It renders the whole desktop useless during that time.
This is mostly noticeable on systems with rotational hard disk due to its read latency.

EXPECTED RESULT
Kwin shouldn't hang.

SOFTWARE/OS VERSIONS
Linux: 5.15.76-1
(available in About System)
KDE Plasma Version: 5.26.2-1
KDE Frameworks Version: 5.99.0-1
Comment 1 Nate Graham 2022-11-08 16:13:28 UTC
*** Bug 461573 has been marked as a duplicate of this bug. ***
Comment 2 Puspam Adak 2022-11-13 11:11:08 UTC
(In reply to Nate Graham from comment #1)
> *** Bug 461573 has been marked as a duplicate of this bug. ***

Bug 461573 says that there's a crash when switching between windows. But in this case, nothing crashes. Kwin only hangs for a few moments between switching windows.
Comment 3 Marcos Dione 2023-01-26 09:17:00 UTC
I'm not sure this is the same bug, but the trigger is the same: switching between apps with Alt-TAB.

Version info:
mdione@nimbus:~/src/projects$ dpkg -l | grep kwin
ii  kwin-addons:amd64                                    4:5.25.5-0ubuntu1                           amd64        additional desktop and window switchers for KWin
ii  kwin-common                                          4:5.25.5-0ubuntu2                           amd64        KDE window manager, common files
ii  kwin-data                                            4:5.25.5-0ubuntu2                           all          KDE window manager data files
ii  kwin-decoration-oxygen:amd64                         4:5.25.5-0ubuntu1                           amd64        KWin decoration for the Oxygen desktop theme
ii  kwin-style-breeze                                    4:5.25.5-0ubuntu1                           amd64        KWin Breeze Style
ii  kwin-wayland                                         4:5.25.5-0ubuntu2                           amd64        KDE window manager, wayland version, PREVIEW release
ii  kwin-wayland-backend-drm                             4:5.25.5-0ubuntu2                           amd64        KDE window manager drm plugin
ii  kwin-x11                                             4:5.25.5-0ubuntu2                           amd64        KDE window manager, X11 version
ii  libkwineffects13                                     4:5.25.5-0ubuntu2                           amd64        KDE window manager effects library
ii  libkwinglutils13                                     4:5.25.5-0ubuntu2                           amd64        KDE window manager gl utils library
ii  libkwinxrenderutils13                                4:5.25.5-0ubuntu2                           amd64        KDE window manager render utils library
ii  qml-module-org-kde-kwindowsystem:amd64               5.98.0-0ubuntu1                             amd64        provides integration of QML and KDE frameworks - kwindowsystem
ii  libqt5core5a:amd64                                   5.15.6+dfsg-1                               amd64        Qt 5 core module

et al.

I have to be honest, I never waited more than a few tens of seconds (I'm usually working) before killing kwin and running it again from a virtual console.

if I run it like:

    mdione@nimbus:~$ DISPLAY=:0 kwin --replace 2>&1

and using a tool to prepend output lines with a timestamp, I can see the following lines being written around the time the freeze occurs:

    2023-01-26T09:54:52.285623: kwin_core: XCB error: 3 (BadWindow), sequence: 65393, resource id: 31460269, major code: 129 (SHAPE), minor code: 6 (Input)
    2023-01-26T09:54:52.285734: qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 65394, resource id: 31460269, major code: 2 (ChangeWindowAttributes), minor code: 0
    2023-01-26T09:54:58.937467: kwin_core: XCB error: 3 (BadWindow), sequence: 456, resource id: 31460284, major code: 129 (SHAPE), minor code: 6 (Input)
    2023-01-26T09:54:58.937589: qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 457, resource id: 31460284, major code: 2 (ChangeWindowAttributes), minor code: 0
    2023-01-26T09:55:00.973904: kwin_core: XCB error: 3 (BadWindow), sequence: 831, resource id: 31460292, major code: 129 (SHAPE), minor code: 6 (Input)
    2023-01-26T09:55:00.974015: qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 832, resource id: 31460292, major code: 2 (ChangeWindowAttributes), minor code: 0
    2023-01-26T09:55:07.445426: qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 1292, resource id: 119539066, major code: 18 (ChangeProperty), minor code: 0
    2023-01-26T09:55:07.484790: qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 1296, resource id: 102760742, major code: 18 (ChangeProperty), minor code: 0
    2023-01-26T09:55:17.008395: kwin_core: XCB error: 3 (BadWindow), sequence: 2460, resource id: 31460309, major code: 129 (SHAPE), minor code: 6 (Input)
    2023-01-26T09:55:17.008541: qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 2461, resource id: 31460309, major code: 2 (ChangeWindowAttributes), minor code: 0
    2023-01-26T09:59:30.504059: kwin_core: XCB error: 3 (BadWindow), sequence: 5752, resource id: 31460333, major code: 129 (SHAPE), minor code: 6 (Input)
    2023-01-26T09:59:30.504214: qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 5753, resource id: 31460333, major code: 2 (ChangeWindowAttributes), minor code: 0
    2023-01-26T10:03:00.764531: kwin_core: XCB error: 3 (BadWindow), sequence: 7072, resource id: 31460405, major code: 129 (SHAPE), minor code: 6 (Input)
    2023-01-26T10:03:00.764641: qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 7073, resource id: 31460405, major code: 2 (ChangeWindowAttributes), minor code: 0
    2023-01-26T10:03:04.520815: qt.qpa.xcb: QXcbConnection: XCB error: 2 (BadValue), sequence: 7394, resource id: 31460433, major code: 149 (Unknown), minor code: 4
    2023-01-26T10:03:04.520909: qt.qpa.xcb: QXcbConnection: XCB error: 136 (Unknown), sequence: 7395, resource id: 31460434, major code: 148 (Unknown), minor code: 1
    2023-01-26T10:03:06.023922: qt.qpa.xcb: QXcbConnection: XCB error: 2 (BadValue), sequence: 7967, resource id: 31460438, major code: 149 (Unknown), minor code: 4
    2023-01-26T10:03:06.024062: qt.qpa.xcb: QXcbConnection: XCB error: 136 (Unknown), sequence: 7972, resource id: 31460439, major code: 148 (Unknown), minor code: 1
    2023-01-26T10:03:06.024125: qt.qpa.xcb: QXcbConnection: XCB error: 2 (BadValue), sequence: 7974, resource id: 31460441, major code: 149 (Unknown), minor code: 4
    2023-01-26T10:03:06.024193: qt.qpa.xcb: QXcbConnection: XCB error: 136 (Unknown), sequence: 7975, resource id: 31460442, major code: 148 (Unknown), minor code: 1
    2023-01-26T10:03:06.048255: kwin_core: XCB error: 3 (BadWindow), sequence: 7995, resource id: 31460427, major code: 129 (SHAPE), minor code: 6 (Input)
    2023-01-26T10:03:06.048318: qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 7996, resource id: 31460427, major code: 2 (ChangeWindowAttributes), minor code: 0

    ^C^C^C^Z
    [1]+  Stopped                 DISPLAY=:0 kwin --replace 2>&1
    mdione@nimbus:~$ kill -9 %1

    [1]+  Stopped                 DISPLAY=:0 kwin --replace 2>&1
    mdione@nimbus:~$
    [1]+  Done                    DISPLAY=:0 kwin --replace 2>&1

Similar log lines appear once I start the new kwin instance, so I'm not sure this really helps you tracking it down.

Also, as you can see, C-c does not kill it, and I have to use kill -9 to finish it. Next time it happens (1-2 times a day, sometimes more like 5-10) I'll try to attach a strace to see where it's hung.

I also see this in the logs:

    2023-01-26T10:03:40.992345: kwin_xkbcommon: XKB: inet:334:58: unrecognized keysym "XF86EmojiPicker"

Again, not sure what of all this helps you.
Comment 4 Marcos Dione 2023-01-26 13:56:19 UTC
Slightly more info:

mdione@nimbus:~$ ps faux | grep kwin
mdione   1217293  0.0  0.0  11356  3892 tty2     S+   14:50   0:00      \_ screen -dR kwin
mdione    777758  0.0  0.0  12172  2872 ?        Ss   Jan25   0:00 SCREEN -dR kwin
mdione   1077754  0.3  0.5 2120404 185308 pts/15 Sl+  10:03   1:02  |   \_ kwin --replace
mdione   1217448  0.0  0.0   8924  2276 pts/19   S+   14:51   0:00      \_ grep --color=auto kwin

mdione@nimbus:~$ sudo strace -p 1077754
strace: Process 1077754 attached
futex(0x7fa6c400f7d0, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)

It was stuck in that futex() call, the ERESTARTSYS is because I C-z'ed it. Maybe I should attach gdb instead?
Comment 5 Marcos Dione 2023-01-31 14:49:15 UTC
(gdb) bt
#0  __futex_abstimed_wait_common64 (private=0, cancel=true, abstime=0x0, op=393, expected=0, futex_word=0x555e85127e24) at ./nptl/futex-internal.c:57
#1  __futex_abstimed_wait_common (cancel=true, private=0, abstime=0x0, clockid=0, expected=0, futex_word=0x555e85127e24) at ./nptl/futex-internal.c:87
#2  __GI___futex_abstimed_wait_cancelable64 (futex_word=futex_word@entry=0x555e85127e24, expected=expected@entry=0, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=private@entry=0) at ./nptl/futex-internal.c:139
#3  0x00007f97d368f338 in __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x555e85127dd0, cond=0x555e85127df8) at ./nptl/pthread_cond_wait.c:503
#4  ___pthread_cond_wait (cond=0x555e85127df8, mutex=0x555e85127dd0) at ./nptl/pthread_cond_wait.c:627
#5  0x00007f97d48d2b1b in QWaitCondition::wait(QMutex*, QDeadlineTimer) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007f97d2c176e8 in ?? () from /lib/x86_64-linux-gnu/libQt5Quick.so.5
#7  0x00007f97d2c84100 in QQuickWindow::event(QEvent*) () from /lib/x86_64-linux-gnu/libQt5Quick.so.5
#8  0x00007f97d3f6bf32 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#9  0x00007f97d4abae38 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#10 0x00007f97d4f31343 in QPlatformWindow::windowEvent(QEvent*) () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
#11 0x00007f97d3f7324d in QApplication::notify(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#12 0x00007f97d4abae38 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#13 0x00007f97d4b13e71 in QTimerInfoList::activateTimers() () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#14 0x00007f97d4b12390 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#15 0x00007f97ce2fab62 in ?? () from /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#16 0x00007f97d4ab97cb in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#17 0x00007f97d4ac1c2a in QCoreApplication::exec() () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#18 0x0000555e82ef73a1 in ?? ()
#19 0x00007f97d3623510 in __libc_start_call_main (main=main@entry=0x555e82ef6f70, argc=argc@entry=2, argv=argv@entry=0x7fff309e4fc8) at ../sysdeps/nptl/libc_start_call_main.h:58
#20 0x00007f97d36235c9 in __libc_start_main_impl (main=0x555e82ef6f70, argc=2, argv=0x7fff309e4fc8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fff309e4fb8) at ../csu/libc-start.c:381
#21 0x0000555e82ef8755 in ?? ()

I got this backtrace, but unluckily there seem not to be any debug symbols for qtquick in Debian/Ubuntu?
Comment 6 Benjamen Meyer 2023-02-03 19:20:57 UTC
Glad I found this, as I'm seeing the same thing (PopOS 22.04 + KDE PPA - Ubuntu Jammy). I first came across it with Chrome; but have mostly reproduced it while trying to deduplicate some email in Thunderbird where Thunderbird is taking extensive time to re-index data and locking it's UI up.

I have let it sit for up to a day at times to try to allow it to come to its own resolution, but that doesn't seem to have helped. As the description said, nothing is responsive aside from using ALT+F2 to go to a terminal to kill applications; but based on the description not sure if that would make matters worse or not. IIRC that helped resolve it when it was just Chrome but that's not helpful with my Thunderbird tasks (this last time, deduplication 1,000,000 records; moving most to the Thunderbird Trash and then re-indexing; the mbox data move  itself doesn't necessarily take long, it's the indexing in Thunderbird that is sub-optimal).

This has been relatively easy for me to reproduce, but never on purpose. Seems it happens when I ALT+TAB through and some how land on Thunderbird while it's processing, or perhaps pause on Thunderbird for something for a bit while tabbing. It's very annoying because it's always at in-opportune times.

NOTE: I am using an SSD, not a rotational disk.
Comment 7 Benjamen Meyer 2023-02-06 16:51:38 UTC
Just to update - I left it sit over the weekend (it locked up sometime on Friday 2/3, finally got back to it mid-morning Monday 2/6; left it go Sat-Sun on purpose) and it still hadn't resolved; my other process had finished its work though, but I finally killed kwin_x11, which then let the konsole terminal start responding and some other windows that were up and  active; which let me restart kwin_x11 from the terminal window   and at least let me close things out gracefully and verify that my other tasks had finished up before logging out and restarting the whole session.

NOTE: I decided to logout and restart the session since there were still some screen artifacts that were not getting cleaned up after restarting kwin_x11.

Any how...while I'd like to see this resolved I do at least have a kind of work around now, and hope this helps others that find this while it's getting fixed.