https://bugs.kde.org/show_bug.cgi?id=510337

--- Comment #12 from [email protected] ---
Reproduced on Plasma 6.8.2 — root cause and a working patch

Short version: this is not (only) about icon arrangement after wake-up. The
trigger is a *transient loss of all outputs*, and Plasma then persists the icon
grid it computes for a surrogate screen. MR !3273 does not cover this path; I
can still reproduce on 6.8.2 with !3273 included.

Environment
- OS: CachyOS, Plasma 6.8.2, KWin 6.8.2 (Wayland), Qt 6.10, AMD Strix Halo
(amdgpu)
- Monitor: 3840×2160 @ scale 1.5 → logical 2560×1440, Folder View grid 12×23
- Reproducible ~1–2 times per day, always on DPMS off / lock screen

Steps to reproduce
1. Arrange desktop icons (canonical key positions["2560x1440"], 12×23, 51–52
items).
2. Lock the screen (Meta+L) and wait until the monitor enters DPMS off; or just
let the monitor sleep.
3. Wake / unlock.

Actual result
- In ~/.config/plasma-org.kde.plasma.desktop-appletsrc:
  - positions["2560x1440"] changes from 12×23 to 12×11;
  - a new key positions["1280x720"] appears with 12×5 and all 52 items;
  - lastResolution becomes 1280x720 or 1477x831.
- Icons are visually piled up in the top-left corner and stay there.

Expected result
Positions must survive a transient output loss / geometry change unchanged.

What happens (measured)
- journalctl --user: every client logs There are no outputs - creating
placeholder screen; plasmashell additionally logs requesting unexisting screen
geometry N (up to ~244 lines per event).
- A poll of kscreen-doctor -o every ~0.3 s during a lock/DPMS event shows the
output completely absent for ~1.2 s (empty replies), while all other samples
report Geometry: 0,0 2560x1440, Scale: 1.5. The real mode never changes to
1920×1080.
- 1280x720 is exactly 1920×1080 / 1.5, i.e. the surrogate screen Plasma falls
back to (1920×1080 logical fallback with DPR 1.5) while there are no outputs.

Why the KWin placeholder is not the culprit
I also built KWin with a patch that makes PlaceholderOutput inherit
modeSize/scale/transform/refreshRate of the last active output (instead of the
hardcoded 1920×1080@60/scale 1). It did not help: with the patched KWin the
same 1280x720 key was still written. Reason: the placeholder is intentionally
not announced to clients (wayland_server.cpp, if (!output->isPlaceholder())),
so clients never see it and Plasma keeps using its own surrogate screen.
Announcing it is not a safe one-liner either (present() is qFatal, render loop
is inhibited, composite() assumes a primary view).

Where the damage is done
In containments/desktop/plugins/folder/positioner.cpp:
- setPerStripe() accepts the geometry of the surrogate screen and recomputes
the grid;
- savePositionsConfig() writes that grid and overwrites the canonical
resolution key;
- restoreChangedPositions() clips stored positions to the new perStripe and
inserts the resolution into visitedResolutions, so the canonical key can no
longer be restored later.

Proposed fix (attached)
Treat a screen topology as *untrusted* until it is stable and matches a real
named screen:
- isLayoutTrusted() = no placeholder/surrogate screen, screens() non-empty,
container geometry matches a named QScreen, and the settle window (4 s in the
local workaround; 1.5–2 s is probably enough upstream) has elapsed;
- while untrusted: setPerStripe() must not change the resolution key or re-lay
items, savePositionsConfig() must not write, restoreChangedPositions() must not
clip and must not touch visitedResolutions;
- after stabilization: re-check with a single-shot timer and reload positions
from the config.

The patch is against 6.8.2 and consists of two parts:
- 0001-…: 4 s "no save after screen change" guard (local workaround we have
been running for two days — prevents config corruption, 4 events survived);
- 0002-…: the transient-geometry fix described above (+174/−44).

Tests
positionertest: 27 passed, 0 failed (26 upstream + 1 new
tst_transientScreenGeometry). ctest -R positionertest → 100%.

Remaining limitation
The icons still visibly rearrange for about a second while Plasma is on the
surrogate screen; after the real output returns they are restored from the
config automatically. Removing the visual jump requires either KWin not losing
the output, or the containment not re-laying items for a surrogate screen —
that is a separate, larger change.

Attachments (diagnostics only; the patch itself is a merge request, per KDE
policy)
- positionertest output (27 passed)
- journal excerpt: "There are no outputs" + "requesting unexisting screen
geometry"
- appletsrc comparison: 2560x1440 12x23 → 12x11, new key 1280x720 12x5

Patches
Both patches are submitted as a merge request to plasma-desktop (link to follow
in a
comment). 0001 is the 4-second "do not save right after a screen change" guard
we have
been running locally for two days; 0002 is the upstream-oriented fix described
above.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to