Bug 502940

Summary: After update to kwin_wayland 6.3.4, workspace.stackingOrder contains references to nonexistent windows
Product: [Plasma] kwin Reporter: Pavel Urusov <pavel.urusov>
Component: scriptingAssignee: KWin default assignee <kwin-bugs-null>
Status: REPORTED ---    
Severity: normal CC: nate, vlad.zahorodnii, xaver.hugl
Priority: NOR Keywords: regression
Version First Reported In: 6.3.4   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Pavel Urusov 2025-04-17 16:54:35 UTC
Since the update to kwin_wayland 6.3.4, workspace.stackingOrder contains references to windows that have been closed.

This breaks some scripts that rely on workspace.stackingOrder for information about window stacking.

The issue was discovered using the following script:

const windowStack = [];
for (let i = 0; i < workspace.stackingOrder.length; i++) {
    let w = workspace.stackingOrder[i];
    if (w.resourceClass == 'plasmashell' || w.resourceClass == 'xwaylandvideobridge' ||) {
        continue;
    }
    windowStack.push(w);
}

for (let i = 0; i < windowStack.length; i++) {
    print(windowStack[i].resourceClass);
}

Viewing the output of the script using journalctl (journalctl -f QT_CATEGORY=js QT_CATEGORY=kwin_scripting), I can see that there are some references to windows that have since been closed.

SYSTEM INFORMATION

Operating System: openSUSE Tumbleweed 20250411
KDE Plasma Version: 6.3.4
KDE Frameworks Version: 6.12.0
Qt Version: 6.9.0
Kernel Version: 6.12.22-1-longterm (64-bit)
Graphics Platform: Wayland
Comment 1 Pavel Urusov 2025-04-17 17:00:23 UTC
Sorry for the typo in the script, this is the version that works:

const windowStack = [];
for (let i = 0; i < workspace.stackingOrder.length; i++) {
    let w = workspace.stackingOrder[i];
    if (w.resourceClass == 'plasmashell' || w.resourceClass == 'xwaylandvideobridge') {
        continue;
    }
    windowStack.push(w);
}

for (let i = 0; i < windowStack.length; i++) {
    print(windowStack[i].resourceClass);
}