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

            Bug ID: 523377
           Summary: kwin_wayland EGL context corruption
                    (GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT) when S4
                    hibernation is aborted by pre-sleep script exit 1
                    (PrepareForSleep(false)), causing black screen freeze
                    on subsequent S4 resume
    Classification: Plasma
           Product: kwin
      Version First 6.1.0
       Reported In:
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: wayland-generic
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

# Sanitize Bug Report for KDE Bugzilla (bugs.kde.org)

**Product**: `kwin`  
**Component**: `wayland-generic`  
**Version**: `6.1.0` (KDE Plasma 6 Wayland)  

---

## Summary
`kwin_wayland` EGL context corruption (`GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT`)
when S4 hibernation is aborted by a pre-sleep script
(`PrepareForSleep(false)`), causing a black screen freeze on subsequent S4
resume

---

## System Environment & Hardware Context
- **OS**: Bazzite (Fedora Linux 44 ostree / Silverblue)
- **KDE Plasma Version**: 6.1.0 (Wayland)
- **Kernel**: `7.1.3-ogc3.4.fc44.x86_64`
- **Hardware Setup**: Dual-AMD Laptop (ASUS ROG Zephyrus G14 GA402RK) — Radeon
680M iGPU + Radeon RX 6700S dGPU (SmartShift)
- **Relevant Kernel Parameters**: `resume=UUID=...`, `amdgpu.sg_display=0`,
`amd_pstate=guided`, `hibernate.compressor=lzo`

---

## Real-World Edge Case Context
On Dual-GPU laptops (e.g. AMD SmartShift iGPU + dGPU), attempting S4
hibernation while the secondary dGPU is still powered on (`active` / `D0`)
causes PCIe reset timeouts and memory snapshot corruption on wake. To prevent
hardware corruption, system pre-sleep scripts inspect
`/sys/bus/pci/devices/.../runtime_status` and return `exit 1` to abort
`systemd-hibernate.service` if the dGPU fails to autosuspend.

When this pre-sleep abort fires, `systemd` broadcasts D-Bus
`PrepareForSleep(false)`. However, `kwin_wayland` does not cleanly recover its
EGL surface bindings if sleep is canceled *after* framebuffer teardown has
already started.

---

## Steps to Reproduce
1. Initiate S4 Hibernation (`systemctl hibernate`). D-Bus broadcasts
`PrepareForSleep(true)`. `kwin_wayland` and `kscreenlocker_greet` lock the
screen and tear down offscreen render targets.
2. A system pre-sleep script returns `exit 1` because the dGPU is still
`active` (aborting hibernation to prevent hardware state corruption). `systemd`
broadcasts `PrepareForSleep(false)`.
3. `kwin_wayland` attempts to resume rendering, but fails EGL framebuffer
attachments, logging multiple OpenGL context errors into journalctl.
4. Initiate S4 Hibernation a second time (`systemctl hibernate`). This time the
dGPU is `suspended` and the pre-sleep script passes. The kernel writes the RAM
snapshot (containing KWin's corrupted EGL state) to swap and powers off.
5. Power on system to resume from S4 hibernation.

---

## Observed Result
Upon waking from swap, `dracut` unpacks the memory image into RAM cleanly, but
`kwin_wayland` fails framebuffer swapchain initialization — resulting in a
frozen black screen with no desktop output. 

A hard power button cycle is required to recover. The subsequent boot logs `PM:
Image not found (code -22)` because the forced power-off invalidated the dirty
swap header.

---

## Expected Result
When `PrepareForSleep(false)` is broadcast following a canceled hibernation
attempt, `kwin_wayland` should cleanly re-bind its EGL surfaces without leaving
invalid framebuffer attachments in memory.

---

## Log Trace Evidence (`journalctl`)

```text
Jul 22 00:15:51 localhost systemd[1]: Starting systemd-hibernate.service -
System Hibernate...
Jul 22 00:16:03 localhost kwin_wayland[2985]: 0x3: GL_INVALID_VALUE in
glTexStorage2D(width, height or depth < 1)
Jul 22 00:16:03 localhost kwin_wayland[2985]: Invalid framebuffer status:
"GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"
Jul 22 00:16:03 localhost kwin_wayland[2985]: 0x3: GL_INVALID_OPERATION in
glBindFramebuffer(non-gen name)
Jul 22 00:16:03 localhost kwin_wayland[2985]: 0x3:
GL_INVALID_FRAMEBUFFER_OPERATION in glClear(incomplete framebuffer)
Jul 22 00:16:04 localhost kwin_wayland[2985]: Could not delete texture because
no context is current
Jul 22 00:16:07 localhost systemd[1]: systemd-hibernate.service: Control
process exited, code=exited, status=1/FAILURE
Jul 22 00:16:07 localhost systemd[1]: Stopped target sleep.target - Sleep.
```

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

Reply via email to